]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - mille/init.c
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
35 /*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 5/31/93";*/
36 static char rcsid
[] = "$Id: init.c,v 1.4 1994/05/12 17:39:31 jtc Exp $";
42 * @(#)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
);
93 for (i
= 0; i
< DECK_SZ
; i
++) {
94 r
= roll(1, DECK_SZ
) - 1;
95 if (r
< 0 || r
> DECK_SZ
- 1) {
96 fprintf(stderr
, "shuffle: card no. error: %d\n", r
);
103 Topcard
= &Deck
[DECK_SZ
];
110 static int first
= TRUE
;
115 mvaddstr(5, 0, "--HAND--");
123 mvaddstr(13, 0, "--BATTLE--");
124 mvaddstr(15, 0, "--SPEED--");
125 mvaddstr(5, 20, "--DECK--");
126 mvaddstr(7, 20, "--DISCARD--");
127 mvaddstr(13, 20, "--BATTLE--");
128 mvaddstr(15, 20, "--SPEED--");
129 mvwaddstr(Miles
, 0, 0, "--MILEAGE--");
130 mvwaddstr(Miles
, 0, 41, "--MILEAGE--");
132 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
133 for (i
= 0; i
< HAND_SZ
; i
++)
142 for (i
= 0; i
< 5; i
++) {
148 wmove(Board
, MOVE_Y
+ 1, MOVE_X
);
150 wmove(Board
, MOVE_Y
+ 2, MOVE_X
);
154 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
155 for (i
= 0; i
< NUM_SAFE
; i
++)
156 pp
->sh_safety
[i
] = FALSE
;
157 for (i
= 0; i
< NUM_MILES
; i
++)
158 pp
->sh_nummiles
[i
] = 0;
159 pp
->sh_safescore
= -1;
168 static int was_full
= -1;
169 static int last_win
= -1;
172 was_full
= (Window
!= W_FULL
);
178 mvaddstr(0, 22, "You Comp Value");
179 mvaddstr(1, 2, "Milestones Played");
180 mvaddstr(2, 8, "Each Safety");
181 mvaddstr(3, 5, "All 4 Safeties");
182 mvaddstr(4, 3, "Each Coup Fourre");
183 mvaddstr(2, 37, "100");
184 mvaddstr(3, 37, "300");
185 mvaddstr(4, 37, "300");
188 else if ((Window
== W_FULL
|| Finished
) ^ was_full
) {
193 else if (Window
!= last_win
)
196 for (i
= 0; i
< SCORE_Y
; i
++)
198 move(SCORE_Y
- 1, 1);
199 for (i
= 0; i
< SCORE_X
; i
++)
201 for (pp
= Player
; pp
<= &Player
[COMP
]; pp
++) {
202 pp
->sh_hand_tot
= -1;
205 pp
->sh_safescore
= -1;
208 Player
[PLAYER
].was_finished
= !Finished
;
209 Player
[COMP
].was_finished
= !Finished
;
210 if (Window
== W_FULL
|| Finished
) {
211 if (!was_full
|| new) {
212 mvaddstr(5, 5, "Trip Completed");
213 mvaddstr(6, 10, "Safe Trip");
214 mvaddstr(7, 5, "Delayed Action");
215 mvaddstr(8, 10, "Extension");
216 mvaddstr(9, 11, "Shut-Out");
217 mvaddstr(10, 21, "---- ---- -----");
218 mvaddstr(11, 9, "Hand Total");
219 mvaddstr(12, 20, "----- -----");
220 mvaddstr(13, 6, "Overall Total");
221 mvaddstr(14, 15, "Games");
222 mvaddstr(5, 37, "400");
223 mvaddstr(6, 37, "300");
224 mvaddstr(7, 37, "300");
225 mvaddstr(8, 37, "200");
226 mvaddstr(9, 37, "500");
230 if (was_full
|| new) {
231 mvaddstr(5, 21, "---- ---- -----");
232 mvaddstr(6, 9, "Hand Total");
233 mvaddstr(7, 20, "----- -----");
234 mvaddstr(8, 6, "Overall Total");
235 mvaddstr(9, 15, "Games");
236 mvaddstr(11, 2, "p: pick");
237 mvaddstr(12, 2, "u: use #");
238 mvaddstr(13, 2, "d: discard #");
239 mvaddstr(14, 2, "w: toggle window");
240 mvaddstr(11, 21, "q: quit");
242 mvaddstr(12, 21, "o: order hand");
244 mvaddstr(12, 21, "o: stop ordering");
245 mvaddstr(13, 21, "s: save");
246 mvaddstr(14, 21, "r: reprint");
249 was_full
= (Window
== W_FULL
|| Finished
);