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
36 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
38 static const char rcsid[] =
39 "$FreeBSD: src/games/mille/init.c,v 1.5 1999/12/12 06:17:24 billf Exp $";
45 * @(#)init.c 1.1 (Berkeley) 4/1/82
55 bzero(Numseen, sizeof Numseen);
58 for (i = 0; i < 2; i++) {
61 for (j = 0; j < NUM_SAFE; j++) {
62 pp->safety[j] = S_UNKNOWN;
65 for (j = 1; j < HAND_SZ; j++) {
66 pp->hand[j] = *--Topcard;
68 account(card = *Topcard);
70 pp->safety[card - S_CONV] = S_IN_HAND;
80 pp->new_speed = FALSE;
81 pp->new_battle = FALSE;
82 for (j = 0; j < NUM_MILES; j++)
86 sort(Player[PLAYER].hand);
98 for (i = 0; i < DECK_SZ; i++) {
99 r = roll(1, DECK_SZ) - 1;
100 if (r < 0 || r > DECK_SZ - 1) {
101 fprintf(stderr, "shuffle: card no. error: %d\n", r);
108 Topcard = &Deck[DECK_SZ];
116 static int first = TRUE;
121 mvaddstr(5, 0, "--HAND--");
129 mvaddstr(13, 0, "--BATTLE--");
130 mvaddstr(15, 0, "--SPEED--");
131 mvaddstr(5, 20, "--DECK--");
132 mvaddstr(7, 20, "--DISCARD--");
133 mvaddstr(13, 20, "--BATTLE--");
134 mvaddstr(15, 20, "--SPEED--");
135 mvwaddstr(Miles, 0, 0, "--MILEAGE--");
136 mvwaddstr(Miles, 0, 41, "--MILEAGE--");
138 for (pp = Player; pp <= &Player[COMP]; pp++) {
139 for (i = 0; i < HAND_SZ; i++)
148 for (i = 0; i < 5; i++) {
154 wmove(Board, MOVE_Y + 1, MOVE_X);
156 wmove(Board, MOVE_Y + 2, MOVE_X);
160 for (pp = Player; pp <= &Player[COMP]; pp++) {
161 for (i = 0; i < NUM_SAFE; i++)
162 pp->sh_safety[i] = FALSE;
163 for (i = 0; i < NUM_MILES; i++)
164 pp->sh_nummiles[i] = 0;
165 pp->sh_safescore = -1;
175 static int was_full = -1;
176 static int last_win = -1;
179 was_full = (Window != W_FULL);
185 mvaddstr(0, 22, "You Comp Value");
186 mvaddstr(1, 2, "Milestones Played");
187 mvaddstr(2, 8, "Each Safety");
188 mvaddstr(3, 5, "All 4 Safeties");
189 mvaddstr(4, 3, "Each Coup Fourre");
190 mvaddstr(2, 37, "100");
191 mvaddstr(3, 37, "300");
192 mvaddstr(4, 37, "300");
195 else if ((Window == W_FULL || Finished) ^ was_full) {
200 else if (Window != last_win)
203 for (i = 0; i < SCORE_Y; i++)
205 move(SCORE_Y - 1, 1);
206 for (i = 0; i < SCORE_X; i++)
208 for (pp = Player; pp <= &Player[COMP]; pp++) {
209 pp->sh_hand_tot = -1;
212 pp->sh_safescore = -1;
215 Player[PLAYER].was_finished = !Finished;
216 Player[COMP].was_finished = !Finished;
217 if (Window == W_FULL || Finished) {
218 if (!was_full || new) {
219 mvaddstr(5, 5, "Trip Completed");
220 mvaddstr(6, 10, "Safe Trip");
221 mvaddstr(7, 5, "Delayed Action");
222 mvaddstr(8, 10, "Extension");
223 mvaddstr(9, 11, "Shut-Out");
224 mvaddstr(10, 21, "---- ---- -----");
225 mvaddstr(11, 9, "Hand Total");
226 mvaddstr(12, 20, "----- -----");
227 mvaddstr(13, 6, "Overall Total");
228 mvaddstr(14, 15, "Games");
229 mvaddstr(5, 37, "400");
230 mvaddstr(6, 37, "300");
231 mvaddstr(7, 37, "300");
232 mvaddstr(8, 37, "200");
233 mvaddstr(9, 37, "500");
237 if (was_full || new) {
238 mvaddstr(5, 21, "---- ---- -----");
239 mvaddstr(6, 9, "Hand Total");
240 mvaddstr(7, 20, "----- -----");
241 mvaddstr(8, 6, "Overall Total");
242 mvaddstr(9, 15, "Games");
243 mvaddstr(11, 2, "p: pick");
244 mvaddstr(12, 2, "u: use #");
245 mvaddstr(13, 2, "d: discard #");
246 mvaddstr(14, 2, "w: toggle window");
247 mvaddstr(11, 21, "q: quit");
249 mvaddstr(12, 21, "o: order hand");
251 mvaddstr(12, 21, "o: stop ordering");
252 mvaddstr(13, 21, "s: save");
253 mvaddstr(14, 21, "r: reprint");
256 was_full = (Window == W_FULL || Finished);