2 * Copyright (c) 1982, 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 * @(#)init.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/mille/init.c,v 1.5 1999/12/12 06:17:24 billf Exp $
36 * @(#)init.c 1.1 (Berkeley) 4/1/82
46 memset(Numseen
, 0, sizeof Numseen
);
49 for (i
= 0; i
< 2; i
++) {
52 for (j
= 0; j
< NUM_SAFE
; j
++) {
53 pp
->safety
[j
] = S_UNKNOWN
;
56 for (j
= 1; j
< HAND_SZ
; j
++) {
57 pp
->hand
[j
] = *--Topcard
;
59 account(card
= *Topcard
);
61 pp
->safety
[card
- S_CONV
] = S_IN_HAND
;
71 pp
->new_speed
= FALSE
;
72 pp
->new_battle
= FALSE
;
73 for (j
= 0; j
< NUM_MILES
; j
++)
77 sort(Player
[PLAYER
].hand
);
89 for (i
= 0; i
< DECK_SZ
; i
++) {
90 r
= roll(1, DECK_SZ
) - 1;
91 if (r
< 0 || r
> DECK_SZ
- 1) {
92 fprintf(stderr
, "shuffle: card no. error: %d\n", r
);
99 Topcard
= &Deck
[DECK_SZ
];
107 static int first
= TRUE
;
112 mvaddstr(5, 0, "--HAND--");
120 mvaddstr(13, 0, "--BATTLE--");
121 mvaddstr(15, 0, "--SPEED--");
122 mvaddstr(5, 20, "--DECK--");
123 mvaddstr(7, 20, "--DISCARD--");
124 mvaddstr(13, 20, "--BATTLE--");
125 mvaddstr(15, 20, "--SPEED--");
126 mvwaddstr(Miles
, 0, 0, "--MILEAGE--");
127 mvwaddstr(Miles
, 0, 41, "--MILEAGE--");
129 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
130 for (i
= 0; i
< HAND_SZ
; i
++)
139 for (i
= 0; i
< 5; i
++) {
145 wmove(Board
, MOVE_Y
+ 1, MOVE_X
);
147 wmove(Board
, MOVE_Y
+ 2, MOVE_X
);
151 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
152 for (i
= 0; i
< NUM_SAFE
; i
++)
153 pp
->sh_safety
[i
] = FALSE
;
154 for (i
= 0; i
< NUM_MILES
; i
++)
155 pp
->sh_nummiles
[i
] = 0;
156 pp
->sh_safescore
= -1;
166 static int was_full
= -1;
167 static int last_win
= -1;
170 was_full
= (Window
!= W_FULL
);
176 mvaddstr(0, 22, "You Comp Value");
177 mvaddstr(1, 2, "Milestones Played");
178 mvaddstr(2, 8, "Each Safety");
179 mvaddstr(3, 5, "All 4 Safeties");
180 mvaddstr(4, 3, "Each Coup Fourre");
181 mvaddstr(2, 37, "100");
182 mvaddstr(3, 37, "300");
183 mvaddstr(4, 37, "300");
186 else if ((Window
== W_FULL
|| Finished
) ^ was_full
) {
191 else if (Window
!= last_win
)
194 for (i
= 0; i
< SCORE_Y
; i
++)
196 move(SCORE_Y
- 1, 1);
197 for (i
= 0; i
< SCORE_X
; i
++)
199 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
200 pp
->sh_hand_tot
= -1;
203 pp
->sh_safescore
= -1;
206 Player
[PLAYER
].was_finished
= !Finished
;
207 Player
[COMP
].was_finished
= !Finished
;
208 if (Window
== W_FULL
|| Finished
) {
209 if (!was_full
|| new) {
210 mvaddstr(5, 5, "Trip Completed");
211 mvaddstr(6, 10, "Safe Trip");
212 mvaddstr(7, 5, "Delayed Action");
213 mvaddstr(8, 10, "Extension");
214 mvaddstr(9, 11, "Shut-Out");
215 mvaddstr(10, 21, "---- ---- -----");
216 mvaddstr(11, 9, "Hand Total");
217 mvaddstr(12, 20, "----- -----");
218 mvaddstr(13, 6, "Overall Total");
219 mvaddstr(14, 15, "Games");
220 mvaddstr(5, 37, "400");
221 mvaddstr(6, 37, "300");
222 mvaddstr(7, 37, "300");
223 mvaddstr(8, 37, "200");
224 mvaddstr(9, 37, "500");
228 if (was_full
|| new) {
229 mvaddstr(5, 21, "---- ---- -----");
230 mvaddstr(6, 9, "Hand Total");
231 mvaddstr(7, 20, "----- -----");
232 mvaddstr(8, 6, "Overall Total");
233 mvaddstr(9, 15, "Games");
234 mvaddstr(11, 2, "p: pick");
235 mvaddstr(12, 2, "u: use #");
236 mvaddstr(13, 2, "d: discard #");
237 mvaddstr(14, 2, "w: toggle window");
238 mvaddstr(11, 21, "q: quit");
240 mvaddstr(12, 21, "o: order hand");
242 mvaddstr(12, 21, "o: stop ordering");
243 mvaddstr(13, 21, "s: save");
244 mvaddstr(14, 21, "r: reprint");
247 was_full
= (Window
== W_FULL
|| Finished
);