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 $
31 * $DragonFly: src/games/mille/init.c,v 1.3 2006/08/27 17:17:23 pavalos Exp $
37 * @(#)init.c 1.1 (Berkeley) 4/1/82
47 bzero(Numseen
, sizeof Numseen
);
50 for (i
= 0; i
< 2; i
++) {
53 for (j
= 0; j
< NUM_SAFE
; j
++) {
54 pp
->safety
[j
] = S_UNKNOWN
;
57 for (j
= 1; j
< HAND_SZ
; j
++) {
58 pp
->hand
[j
] = *--Topcard
;
60 account(card
= *Topcard
);
62 pp
->safety
[card
- S_CONV
] = S_IN_HAND
;
72 pp
->new_speed
= FALSE
;
73 pp
->new_battle
= FALSE
;
74 for (j
= 0; j
< NUM_MILES
; j
++)
78 sort(Player
[PLAYER
].hand
);
90 for (i
= 0; i
< DECK_SZ
; i
++) {
91 r
= roll(1, DECK_SZ
) - 1;
92 if (r
< 0 || r
> DECK_SZ
- 1) {
93 fprintf(stderr
, "shuffle: card no. error: %d\n", r
);
100 Topcard
= &Deck
[DECK_SZ
];
108 static int first
= TRUE
;
113 mvaddstr(5, 0, "--HAND--");
121 mvaddstr(13, 0, "--BATTLE--");
122 mvaddstr(15, 0, "--SPEED--");
123 mvaddstr(5, 20, "--DECK--");
124 mvaddstr(7, 20, "--DISCARD--");
125 mvaddstr(13, 20, "--BATTLE--");
126 mvaddstr(15, 20, "--SPEED--");
127 mvwaddstr(Miles
, 0, 0, "--MILEAGE--");
128 mvwaddstr(Miles
, 0, 41, "--MILEAGE--");
130 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
131 for (i
= 0; i
< HAND_SZ
; i
++)
140 for (i
= 0; i
< 5; i
++) {
146 wmove(Board
, MOVE_Y
+ 1, MOVE_X
);
148 wmove(Board
, MOVE_Y
+ 2, MOVE_X
);
152 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
153 for (i
= 0; i
< NUM_SAFE
; i
++)
154 pp
->sh_safety
[i
] = FALSE
;
155 for (i
= 0; i
< NUM_MILES
; i
++)
156 pp
->sh_nummiles
[i
] = 0;
157 pp
->sh_safescore
= -1;
167 static int was_full
= -1;
168 static int last_win
= -1;
171 was_full
= (Window
!= W_FULL
);
177 mvaddstr(0, 22, "You Comp Value");
178 mvaddstr(1, 2, "Milestones Played");
179 mvaddstr(2, 8, "Each Safety");
180 mvaddstr(3, 5, "All 4 Safeties");
181 mvaddstr(4, 3, "Each Coup Fourre");
182 mvaddstr(2, 37, "100");
183 mvaddstr(3, 37, "300");
184 mvaddstr(4, 37, "300");
187 else if ((Window
== W_FULL
|| Finished
) ^ was_full
) {
192 else if (Window
!= last_win
)
195 for (i
= 0; i
< SCORE_Y
; i
++)
197 move(SCORE_Y
- 1, 1);
198 for (i
= 0; i
< SCORE_X
; i
++)
200 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
201 pp
->sh_hand_tot
= -1;
204 pp
->sh_safescore
= -1;
207 Player
[PLAYER
].was_finished
= !Finished
;
208 Player
[COMP
].was_finished
= !Finished
;
209 if (Window
== W_FULL
|| Finished
) {
210 if (!was_full
|| new) {
211 mvaddstr(5, 5, "Trip Completed");
212 mvaddstr(6, 10, "Safe Trip");
213 mvaddstr(7, 5, "Delayed Action");
214 mvaddstr(8, 10, "Extension");
215 mvaddstr(9, 11, "Shut-Out");
216 mvaddstr(10, 21, "---- ---- -----");
217 mvaddstr(11, 9, "Hand Total");
218 mvaddstr(12, 20, "----- -----");
219 mvaddstr(13, 6, "Overall Total");
220 mvaddstr(14, 15, "Games");
221 mvaddstr(5, 37, "400");
222 mvaddstr(6, 37, "300");
223 mvaddstr(7, 37, "300");
224 mvaddstr(8, 37, "200");
225 mvaddstr(9, 37, "500");
229 if (was_full
|| new) {
230 mvaddstr(5, 21, "---- ---- -----");
231 mvaddstr(6, 9, "Hand Total");
232 mvaddstr(7, 20, "----- -----");
233 mvaddstr(8, 6, "Overall Total");
234 mvaddstr(9, 15, "Games");
235 mvaddstr(11, 2, "p: pick");
236 mvaddstr(12, 2, "u: use #");
237 mvaddstr(13, 2, "d: discard #");
238 mvaddstr(14, 2, "w: toggle window");
239 mvaddstr(11, 21, "q: quit");
241 mvaddstr(12, 21, "o: order hand");
243 mvaddstr(12, 21, "o: stop ordering");
244 mvaddstr(13, 21, "s: save");
245 mvaddstr(14, 21, "r: reprint");
248 was_full
= (Window
== W_FULL
|| Finished
);