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. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)init.c 8.1 (Berkeley) 5/31/93
34 * $FreeBSD: src/games/mille/init.c,v 1.5 1999/12/12 06:17:24 billf Exp $
35 * $DragonFly: src/games/mille/init.c,v 1.2 2003/06/17 04:25:24 dillon Exp $
41 * @(#)init.c 1.1 (Berkeley) 4/1/82
51 bzero(Numseen, sizeof Numseen);
54 for (i = 0; i < 2; i++) {
57 for (j = 0; j < NUM_SAFE; j++) {
58 pp->safety[j] = S_UNKNOWN;
61 for (j = 1; j < HAND_SZ; j++) {
62 pp->hand[j] = *--Topcard;
64 account(card = *Topcard);
66 pp->safety[card - S_CONV] = S_IN_HAND;
76 pp->new_speed = FALSE;
77 pp->new_battle = FALSE;
78 for (j = 0; j < NUM_MILES; j++)
82 sort(Player[PLAYER].hand);
94 for (i = 0; i < DECK_SZ; i++) {
95 r = roll(1, DECK_SZ) - 1;
96 if (r < 0 || r > DECK_SZ - 1) {
97 fprintf(stderr, "shuffle: card no. error: %d\n", r);
104 Topcard = &Deck[DECK_SZ];
112 static int first = TRUE;
117 mvaddstr(5, 0, "--HAND--");
125 mvaddstr(13, 0, "--BATTLE--");
126 mvaddstr(15, 0, "--SPEED--");
127 mvaddstr(5, 20, "--DECK--");
128 mvaddstr(7, 20, "--DISCARD--");
129 mvaddstr(13, 20, "--BATTLE--");
130 mvaddstr(15, 20, "--SPEED--");
131 mvwaddstr(Miles, 0, 0, "--MILEAGE--");
132 mvwaddstr(Miles, 0, 41, "--MILEAGE--");
134 for (pp = Player; pp <= &Player[COMP]; pp++) {
135 for (i = 0; i < HAND_SZ; i++)
144 for (i = 0; i < 5; i++) {
150 wmove(Board, MOVE_Y + 1, MOVE_X);
152 wmove(Board, MOVE_Y + 2, MOVE_X);
156 for (pp = Player; pp <= &Player[COMP]; pp++) {
157 for (i = 0; i < NUM_SAFE; i++)
158 pp->sh_safety[i] = FALSE;
159 for (i = 0; i < NUM_MILES; i++)
160 pp->sh_nummiles[i] = 0;
161 pp->sh_safescore = -1;
171 static int was_full = -1;
172 static int last_win = -1;
175 was_full = (Window != W_FULL);
181 mvaddstr(0, 22, "You Comp Value");
182 mvaddstr(1, 2, "Milestones Played");
183 mvaddstr(2, 8, "Each Safety");
184 mvaddstr(3, 5, "All 4 Safeties");
185 mvaddstr(4, 3, "Each Coup Fourre");
186 mvaddstr(2, 37, "100");
187 mvaddstr(3, 37, "300");
188 mvaddstr(4, 37, "300");
191 else if ((Window == W_FULL || Finished) ^ was_full) {
196 else if (Window != last_win)
199 for (i = 0; i < SCORE_Y; i++)
201 move(SCORE_Y - 1, 1);
202 for (i = 0; i < SCORE_X; i++)
204 for (pp = Player; pp <= &Player[COMP]; pp++) {
205 pp->sh_hand_tot = -1;
208 pp->sh_safescore = -1;
211 Player[PLAYER].was_finished = !Finished;
212 Player[COMP].was_finished = !Finished;
213 if (Window == W_FULL || Finished) {
214 if (!was_full || new) {
215 mvaddstr(5, 5, "Trip Completed");
216 mvaddstr(6, 10, "Safe Trip");
217 mvaddstr(7, 5, "Delayed Action");
218 mvaddstr(8, 10, "Extension");
219 mvaddstr(9, 11, "Shut-Out");
220 mvaddstr(10, 21, "---- ---- -----");
221 mvaddstr(11, 9, "Hand Total");
222 mvaddstr(12, 20, "----- -----");
223 mvaddstr(13, 6, "Overall Total");
224 mvaddstr(14, 15, "Games");
225 mvaddstr(5, 37, "400");
226 mvaddstr(6, 37, "300");
227 mvaddstr(7, 37, "300");
228 mvaddstr(8, 37, "200");
229 mvaddstr(9, 37, "500");
233 if (was_full || new) {
234 mvaddstr(5, 21, "---- ---- -----");
235 mvaddstr(6, 9, "Hand Total");
236 mvaddstr(7, 20, "----- -----");
237 mvaddstr(8, 6, "Overall Total");
238 mvaddstr(9, 15, "Games");
239 mvaddstr(11, 2, "p: pick");
240 mvaddstr(12, 2, "u: use #");
241 mvaddstr(13, 2, "d: discard #");
242 mvaddstr(14, 2, "w: toggle window");
243 mvaddstr(11, 21, "q: quit");
245 mvaddstr(12, 21, "o: order hand");
247 mvaddstr(12, 21, "o: stop ordering");
248 mvaddstr(13, 21, "s: save");
249 mvaddstr(14, 21, "r: reprint");
252 was_full = (Window == W_FULL || Finished);