]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - mille/init.c
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/cdefs.h>
39 static char sccsid
[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
41 __RCSID("$NetBSD: init.c,v 1.8 1999/09/30 18:01:32 jsm Exp $");
48 * @(#)init.c 1.1 (Berkeley) 4/1/82
58 memset(Numseen
, 0, sizeof Numseen
);
61 for (i
= 0; i
< 2; i
++) {
64 for (j
= 0; j
< NUM_SAFE
; j
++) {
65 pp
->safety
[j
] = S_UNKNOWN
;
68 for (j
= 1; j
< HAND_SZ
; j
++) {
69 pp
->hand
[j
] = *--Topcard
;
71 account(card
= *Topcard
);
73 pp
->safety
[card
- S_CONV
] = S_IN_HAND
;
83 pp
->new_speed
= FALSE
;
84 pp
->new_battle
= FALSE
;
85 for (j
= 0; j
< NUM_MILES
; j
++)
89 sort(Player
[PLAYER
].hand
);
101 for (i
= 0; i
< DECK_SZ
; i
++) {
102 r
= roll(1, DECK_SZ
) - 1;
103 if (r
< 0 || r
> DECK_SZ
- 1) {
104 warnx("shuffle: card no. error: %d", r
);
111 Topcard
= &Deck
[DECK_SZ
];
119 static int first
= TRUE
;
124 mvaddstr(5, 0, "--HAND--");
132 mvaddstr(13, 0, "--BATTLE--");
133 mvaddstr(15, 0, "--SPEED--");
134 mvaddstr(5, 20, "--DECK--");
135 mvaddstr(7, 20, "--DISCARD--");
136 mvaddstr(13, 20, "--BATTLE--");
137 mvaddstr(15, 20, "--SPEED--");
138 mvwaddstr(Miles
, 0, 0, "--MILEAGE--");
139 mvwaddstr(Miles
, 0, 41, "--MILEAGE--");
141 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
142 for (i
= 0; i
< HAND_SZ
; i
++)
151 for (i
= 0; i
< 5; i
++) {
157 wmove(Board
, MOVE_Y
+ 1, MOVE_X
);
159 wmove(Board
, MOVE_Y
+ 2, MOVE_X
);
163 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
164 for (i
= 0; i
< NUM_SAFE
; i
++)
165 pp
->sh_safety
[i
] = FALSE
;
166 for (i
= 0; i
< NUM_MILES
; i
++)
167 pp
->sh_nummiles
[i
] = 0;
168 pp
->sh_safescore
= -1;
178 static int was_full
= -1;
179 static int last_win
= -1;
182 was_full
= (Window
!= W_FULL
);
188 mvaddstr(0, 22, "You Comp Value");
189 mvaddstr(1, 2, "Milestones Played");
190 mvaddstr(2, 8, "Each Safety");
191 mvaddstr(3, 5, "All 4 Safeties");
192 mvaddstr(4, 3, "Each Coup Fourre");
193 mvaddstr(2, 37, "100");
194 mvaddstr(3, 37, "300");
195 mvaddstr(4, 37, "300");
198 else if ((Window
== W_FULL
|| Finished
) ^ was_full
) {
203 else if (Window
!= last_win
)
206 for (i
= 0; i
< SCORE_Y
; i
++)
208 move(SCORE_Y
- 1, 1);
209 for (i
= 0; i
< SCORE_X
; i
++)
211 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
212 pp
->sh_hand_tot
= -1;
215 pp
->sh_safescore
= -1;
218 Player
[PLAYER
].was_finished
= !Finished
;
219 Player
[COMP
].was_finished
= !Finished
;
220 if (Window
== W_FULL
|| Finished
) {
221 if (!was_full
|| new) {
222 mvaddstr(5, 5, "Trip Completed");
223 mvaddstr(6, 10, "Safe Trip");
224 mvaddstr(7, 5, "Delayed Action");
225 mvaddstr(8, 10, "Extension");
226 mvaddstr(9, 11, "Shut-Out");
227 mvaddstr(10, 21, "---- ---- -----");
228 mvaddstr(11, 9, "Hand Total");
229 mvaddstr(12, 20, "----- -----");
230 mvaddstr(13, 6, "Overall Total");
231 mvaddstr(14, 15, "Games");
232 mvaddstr(5, 37, "400");
233 mvaddstr(6, 37, "300");
234 mvaddstr(7, 37, "300");
235 mvaddstr(8, 37, "200");
236 mvaddstr(9, 37, "500");
240 if (was_full
|| new) {
241 mvaddstr(5, 21, "---- ---- -----");
242 mvaddstr(6, 9, "Hand Total");
243 mvaddstr(7, 20, "----- -----");
244 mvaddstr(8, 6, "Overall Total");
245 mvaddstr(9, 15, "Games");
246 mvaddstr(11, 2, "p: pick");
247 mvaddstr(12, 2, "u: use #");
248 mvaddstr(13, 2, "d: discard #");
249 mvaddstr(14, 2, "w: toggle window");
250 mvaddstr(11, 21, "q: quit");
252 mvaddstr(12, 21, "o: order hand");
254 mvaddstr(12, 21, "o: stop ordering");
255 mvaddstr(13, 21, "s: save");
256 mvaddstr(14, 21, "r: reprint");
259 was_full
= (Window
== W_FULL
|| Finished
);