1 /* $NetBSD: init.c,v 1.8 1999/09/30 18:01:32 jsm Exp $ */
4 * Copyright (c) 1982, 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
[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
37 __RCSID("$NetBSD: init.c,v 1.8 1999/09/30 18:01:32 jsm Exp $");
44 * @(#)init.c 1.1 (Berkeley) 4/1/82
54 memset(Numseen
, 0, sizeof Numseen
);
57 for (i
= 0; i
< 2; i
++) {
60 for (j
= 0; j
< NUM_SAFE
; j
++) {
61 pp
->safety
[j
] = S_UNKNOWN
;
64 for (j
= 1; j
< HAND_SZ
; j
++) {
65 pp
->hand
[j
] = *--Topcard
;
67 account(card
= *Topcard
);
69 pp
->safety
[card
- S_CONV
] = S_IN_HAND
;
79 pp
->new_speed
= FALSE
;
80 pp
->new_battle
= FALSE
;
81 for (j
= 0; j
< NUM_MILES
; j
++)
85 sort(Player
[PLAYER
].hand
);
97 for (i
= 0; i
< DECK_SZ
; i
++) {
98 r
= roll(1, DECK_SZ
) - 1;
99 if (r
< 0 || r
> DECK_SZ
- 1) {
100 warnx("shuffle: card no. error: %d", r
);
107 Topcard
= &Deck
[DECK_SZ
];
115 static int first
= TRUE
;
120 mvaddstr(5, 0, "--HAND--");
128 mvaddstr(13, 0, "--BATTLE--");
129 mvaddstr(15, 0, "--SPEED--");
130 mvaddstr(5, 20, "--DECK--");
131 mvaddstr(7, 20, "--DISCARD--");
132 mvaddstr(13, 20, "--BATTLE--");
133 mvaddstr(15, 20, "--SPEED--");
134 mvwaddstr(Miles
, 0, 0, "--MILEAGE--");
135 mvwaddstr(Miles
, 0, 41, "--MILEAGE--");
137 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
138 for (i
= 0; i
< HAND_SZ
; i
++)
147 for (i
= 0; i
< 5; i
++) {
153 wmove(Board
, MOVE_Y
+ 1, MOVE_X
);
155 wmove(Board
, MOVE_Y
+ 2, MOVE_X
);
159 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
160 for (i
= 0; i
< NUM_SAFE
; i
++)
161 pp
->sh_safety
[i
] = FALSE
;
162 for (i
= 0; i
< NUM_MILES
; i
++)
163 pp
->sh_nummiles
[i
] = 0;
164 pp
->sh_safescore
= -1;
174 static int was_full
= -1;
175 static int last_win
= -1;
178 was_full
= (Window
!= W_FULL
);
184 mvaddstr(0, 22, "You Comp Value");
185 mvaddstr(1, 2, "Milestones Played");
186 mvaddstr(2, 8, "Each Safety");
187 mvaddstr(3, 5, "All 4 Safeties");
188 mvaddstr(4, 3, "Each Coup Fourre");
189 mvaddstr(2, 37, "100");
190 mvaddstr(3, 37, "300");
191 mvaddstr(4, 37, "300");
194 else if ((Window
== W_FULL
|| Finished
) ^ was_full
) {
199 else if (Window
!= last_win
)
202 for (i
= 0; i
< SCORE_Y
; i
++)
204 move(SCORE_Y
- 1, 1);
205 for (i
= 0; i
< SCORE_X
; i
++)
207 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
208 pp
->sh_hand_tot
= -1;
211 pp
->sh_safescore
= -1;
214 Player
[PLAYER
].was_finished
= !Finished
;
215 Player
[COMP
].was_finished
= !Finished
;
216 if (Window
== W_FULL
|| Finished
) {
217 if (!was_full
|| new) {
218 mvaddstr(5, 5, "Trip Completed");
219 mvaddstr(6, 10, "Safe Trip");
220 mvaddstr(7, 5, "Delayed Action");
221 mvaddstr(8, 10, "Extension");
222 mvaddstr(9, 11, "Shut-Out");
223 mvaddstr(10, 21, "---- ---- -----");
224 mvaddstr(11, 9, "Hand Total");
225 mvaddstr(12, 20, "----- -----");
226 mvaddstr(13, 6, "Overall Total");
227 mvaddstr(14, 15, "Games");
228 mvaddstr(5, 37, "400");
229 mvaddstr(6, 37, "300");
230 mvaddstr(7, 37, "300");
231 mvaddstr(8, 37, "200");
232 mvaddstr(9, 37, "500");
236 if (was_full
|| new) {
237 mvaddstr(5, 21, "---- ---- -----");
238 mvaddstr(6, 9, "Hand Total");
239 mvaddstr(7, 20, "----- -----");
240 mvaddstr(8, 6, "Overall Total");
241 mvaddstr(9, 15, "Games");
242 mvaddstr(11, 2, "p: pick");
243 mvaddstr(12, 2, "u: use #");
244 mvaddstr(13, 2, "d: discard #");
245 mvaddstr(14, 2, "w: toggle window");
246 mvaddstr(11, 21, "q: quit");
248 mvaddstr(12, 21, "o: order hand");
250 mvaddstr(12, 21, "o: stop ordering");
251 mvaddstr(13, 21, "s: save");
252 mvaddstr(14, 21, "r: reprint");
255 was_full
= (Window
== W_FULL
|| Finished
);