2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)misc.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/mille/misc.c,v 1.8.2.1 2001/06/13 13:52:14 dwmalone Exp $
31 * $DragonFly: src/games/mille/misc.c,v 1.4 2006/08/27 17:17:23 pavalos Exp $
42 * @(#)misc.c 1.2 (Berkeley) 3/28/83
48 error(const char *str, ...)
55 vw_printw(stdscr, str, arg);
70 while ((c = readch()) == '\n' || c == '\r' || c == ' ')
74 if (c == killchar() || c == erasechar())
79 case '1': case '2': case '3':
80 case '4': case '5': case '6':
83 case '0': case 'P': case 'p':
96 while ((c1=readch()) != '\r' && c1 != '\n' && c1 != ' ')
99 else if (c1 == erasechar()) {
114 check_ext(bool forcomp)
119 if (Play == PLAYER) {
120 if (getyn(EXTENSIONPROMPT)) {
138 op = &Player[PLAYER];
139 for (safe = 0, i = 0; i < NUMSAFE; i++)
140 if (pp->safety[i] != S_UNKNOWN)
144 if (op->mileage == 0 || onecard(op)
145 || (op->can_go && op->mileage >= 500))
147 for (miles = 0, i = 0; i < NUMSAFE; i++)
148 if (op->safety[i] != S_PLAYED
149 && pp->safety[i] == S_UNKNOWN)
151 if (miles + safe == NUMSAFE)
153 for (miles = 0, i = 0; i < HAND_SZ; i++)
154 if ((safe = pp->hand[i]) <= C_200)
155 miles += Value[safe];
156 if (miles + (Topcard - Deck) * 3 > 1000)
165 * Get a yes or no answer to the given question. Saves are
166 * also allowed. Return TRUE if the answer was yes, FALSE if no.
175 leaveok(Board, FALSE);
179 switch (c = readch()) {
183 leaveok(Board, TRUE);
188 leaveok(Board, TRUE);
208 * Check to see if more games are desired. If not, and game
209 * came from a saved file, make sure that they don't want to restore
210 * it. Exit appropriately.
216 if (Player[PLAYER].total >= 5000 || Player[COMP].total >= 5000)
217 if (getyn(ANOTHERGAMEPROMPT))
221 * must do accounting normally done in main()
223 if (Player[PLAYER].total > Player[COMP].total)
224 Player[PLAYER].games++;
225 else if (Player[PLAYER].total < Player[COMP].total)
226 Player[COMP].games++;
227 Player[COMP].total = 0;
228 Player[PLAYER].total = 0;
231 if (getyn(ANOTHERHANDPROMPT))
233 if (!Saved && getyn(SAVEGAMEPROMPT))
245 for (cnt = 0; read(0, &c, 1) <= 0; cnt++)