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 $
41 * @(#)misc.c 1.2 (Berkeley) 3/28/83
47 error(const char *str
, ...)
54 vw_printw(stdscr
, str
, arg
);
69 while ((c
= readch()) == '\n' || c
== '\r' || c
== ' ')
73 if (c
== killchar() || c
== erasechar())
78 case '1': case '2': case '3':
79 case '4': case '5': case '6':
82 case '0': case 'P': case 'p':
95 while ((c1
=readch()) != '\r' && c1
!= '\n' && c1
!= ' ')
98 else if (c1
== erasechar()) {
113 check_ext(bool forcomp
)
116 if (Play
== PLAYER
) {
117 if (getyn(EXTENSIONPROMPT
)) {
133 op
= &Player
[PLAYER
];
134 for (safe
= 0, i
= 0; i
< NUMSAFE
; i
++)
135 if (pp
->safety
[i
] != S_UNKNOWN
)
139 if (op
->mileage
== 0 || onecard(op
)
140 || (op
->can_go
&& op
->mileage
>= 500))
142 for (miles
= 0, i
= 0; i
< NUMSAFE
; i
++)
143 if (op
->safety
[i
] != S_PLAYED
144 && pp
->safety
[i
] == S_UNKNOWN
)
146 if (miles
+ safe
== NUMSAFE
)
148 for (miles
= 0, i
= 0; i
< HAND_SZ
; i
++)
149 if ((safe
= pp
->hand
[i
]) <= C_200
)
150 miles
+= Value
[safe
];
151 if (miles
+ (Topcard
- Deck
) * 3 > 1000)
160 * Get a yes or no answer to the given question. Saves are
161 * also allowed. Return TRUE if the answer was yes, FALSE if no.
170 leaveok(Board
, FALSE
);
174 switch (c
= readch()) {
178 leaveok(Board
, TRUE
);
183 leaveok(Board
, TRUE
);
203 * Check to see if more games are desired. If not, and game
204 * came from a saved file, make sure that they don't want to restore
205 * it. Exit appropriately.
211 if (Player
[PLAYER
].total
>= 5000 || Player
[COMP
].total
>= 5000) {
212 if (getyn(ANOTHERGAMEPROMPT
))
216 * must do accounting normally done in main()
218 if (Player
[PLAYER
].total
> Player
[COMP
].total
)
219 Player
[PLAYER
].games
++;
220 else if (Player
[PLAYER
].total
< Player
[COMP
].total
)
221 Player
[COMP
].games
++;
222 Player
[COMP
].total
= 0;
223 Player
[PLAYER
].total
= 0;
226 if (getyn(ANOTHERHANDPROMPT
))
228 if (!Saved
&& getyn(SAVEGAMEPROMPT
))
240 for (cnt
= 0; read(0, &c
, 1) <= 0; cnt
++)