1 /* $NetBSD: misc.c,v 1.11 2003/08/07 09:37:25 agc Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
37 __RCSID("$NetBSD: misc.c,v 1.11 2003/08/07 09:37:25 agc Exp $");
53 * @(#)misc.c 1.2 (Berkeley) 3/28/83
59 error(const char *str
, ...)
64 wmove(Score
, ERR_Y
, ERR_X
);
65 vwprintw(Score
, str
, ap
);
79 while ((c
= readch()) == '\n' || c
== '\r' || c
== ' ')
83 if (c
== killchar() || c
== erasechar())
88 case '1': case '2': case '3':
89 case '4': case '5': case '6':
92 case '0': case 'P': case 'p':
105 while ((c1
=readch()) != '\r' && c1
!= '\n' && c1
!= ' ')
106 if (c1
== killchar())
108 else if (c1
== erasechar()) {
123 check_ext(bool forcomp
)
128 if (Play
== PLAYER
) {
129 if (getyn(EXTENSIONPROMPT
)) {
147 op
= &Player
[PLAYER
];
148 for (safe
= 0, i
= 0; i
< NUMSAFE
; i
++)
149 if (pp
->safety
[i
] != S_UNKNOWN
)
153 if (op
->mileage
== 0 || onecard(op
)
154 || (op
->can_go
&& op
->mileage
>= 500))
156 for (miles
= 0, i
= 0; i
< NUMSAFE
; i
++)
157 if (op
->safety
[i
] != S_PLAYED
158 && pp
->safety
[i
] == S_UNKNOWN
)
160 if (miles
+ safe
== NUMSAFE
)
162 for (miles
= 0, i
= 0; i
< HAND_SZ
; i
++)
163 if ((safe
= pp
->hand
[i
]) <= C_200
)
164 miles
+= Value
[safe
];
165 if (miles
+ (Topcard
- Deck
) * 3 > 1000)
174 * Get a yes or no answer to the given question. Saves are
175 * also allowed. Return TRUE if the answer was yes, FALSE if no.
184 leaveok(Board
, FALSE
);
188 switch (c
= readch()) {
192 leaveok(Board
, TRUE
);
197 leaveok(Board
, TRUE
);
217 * Check to see if more games are desired. If not, and game
218 * came from a saved file, make sure that they don't want to restore
219 * it. Exit appropriately.
225 if (Player
[PLAYER
].total
>= 5000 || Player
[COMP
].total
>= 5000)
226 if (getyn(ANOTHERGAMEPROMPT
))
230 * must do accounting normally done in main()
232 if (Player
[PLAYER
].total
> Player
[COMP
].total
)
233 Player
[PLAYER
].games
++;
234 else if (Player
[PLAYER
].total
< Player
[COMP
].total
)
235 Player
[COMP
].games
++;
236 Player
[COMP
].total
= 0;
237 Player
[PLAYER
].total
= 0;
240 if (getyn(ANOTHERHANDPROMPT
))
242 if (!Saved
&& getyn(SAVEGAMEPROMPT
))
254 for (cnt
= 0; read(0, &c
, 1) <= 0; cnt
++)