date and time created 90/06/25 12:37:42 by bostic
[unix-history] / usr / src / games / mille / mille.h
CommitLineData
15240bf5
KB
1/*
2 * Copyright (c) 1982 Regents of the University of California.
4a732708
KB
3 * All rights reserved.
4 *
7c5ab767 5 * %sccs.include.redist.c%
4a732708 6 *
7c5ab767 7 * @(#)mille.h 5.5 (Berkeley) %G%
15240bf5
KB
8 */
9
4a732708 10# include <sys/types.h>
15240bf5 11# include <ctype.h>
4a732708 12# include <curses.h>
6ebcb998 13# include <string.h>
15240bf5
KB
14
15/*
16 * @(#)mille.h 1.1 (Berkeley) 4/1/82
17 */
18
19/*
20 * Miscellaneous constants
21 */
22
23# define unsgn unsigned
24# define CARD short
25
15240bf5
KB
26# define HAND_SZ 7 /* number of cards in a hand */
27# define DECK_SZ 101 /* number of cards in decks */
28# define NUM_SAFE 4 /* number of saftey cards */
29# define NUM_MILES 5 /* number of milestones types */
30# define NUM_CARDS 20 /* number of types of cards */
31# define BOARD_Y 17 /* size of board screen */
32# define BOARD_X 40
33# define MILES_Y 7 /* size of mileage screen */
34# define MILES_X 80
35# define SCORE_Y 17 /* size of score screen */
36# define SCORE_X 40
37# define MOVE_Y 10 /* Where to print move prompt */
38# define MOVE_X 20
39# define ERR_Y 15 /* Where to print errors */
40# define ERR_X 5
41# define EXT_Y 4 /* Where to put Extension */
42# define EXT_X 9
43
44# define PLAYER 0
45# define COMP 1
46
47# define W_SMALL 0 /* Small (initial) window */
48# define W_FULL 1 /* Full (final) window */
49
50/*
51 * Move types
52 */
53
54# define M_DISCARD 0
55# define M_DRAW 1
56# define M_PLAY 2
57# define M_ORDER 3
58
59/*
60 * Scores
61 */
62
63# define SC_SAFETY 100
64# define SC_ALL_SAFE 300
65# define SC_COUP 300
66# define SC_TRIP 400
67# define SC_SAFE 300
68# define SC_DELAY 300
69# define SC_EXTENSION 200
70# define SC_SHUT_OUT 500
71
72/*
73 * safety descriptions
74 */
75
76# define S_UNKNOWN 0 /* location of safety unknown */
77# define S_IN_HAND 1 /* safety in player's hand */
78# define S_PLAYED 2 /* safety has been played */
79# define S_GAS_SAFE 0 /* Gas safety card index */
80# define S_SPARE_SAFE 1 /* Tire safety card index */
81# define S_DRIVE_SAFE 2 /* Driveing safety card index */
82# define S_RIGHT_WAY 3 /* Right-of-Way card index */
83# define S_CONV 15 /* conversion from C_ to S_ */
84
85/*
86 * card numbers
87 */
88
89# define C_INIT -1
90# define C_25 0
91# define C_50 1
92# define C_75 2
93# define C_100 3
94# define C_200 4
95# define C_EMPTY 5
96# define C_FLAT 6
97# define C_CRASH 7
98# define C_STOP 8
99# define C_LIMIT 9
100# define C_GAS 10
101# define C_SPARE 11
102# define C_REPAIRS 12
103# define C_GO 13
104# define C_END_LIMIT 14
105# define C_GAS_SAFE 15
106# define C_SPARE_SAFE 16
107# define C_DRIVE_SAFE 17
108# define C_RIGHT_WAY 18
109
110/*
111 * prompt types
112 */
113
114# define MOVEPROMPT 0
115# define REALLYPROMPT 1
116# define ANOTHERHANDPROMPT 2
117# define ANOTHERGAMEPROMPT 3
118# define SAVEGAMEPROMPT 4
119# define SAMEFILEPROMPT 5
120# define FILEPROMPT 6
121# define EXTENSIONPROMPT 7
122# define OVERWRITEFILEPROMPT 8
123
124# ifdef SYSV
125# define srandom(x) srand(x)
126# define random() rand()
127
128# ifndef attron
129# define erasechar() _tty.c_cc[VERASE]
130# define killchar() _tty.c_cc[VKILL]
131# endif
132# else
133# ifndef erasechar
134# define erasechar() _tty.sg_erase
135# define killchar() _tty.sg_kill
136# endif
137# endif SYSV
138
139typedef struct {
140 bool coups[NUM_SAFE];
141 bool can_go;
142 bool new_battle;
143 bool new_speed;
144 short safety[NUM_SAFE];
145 short sh_safety[NUM_SAFE];
146 short nummiles[NUM_MILES];
147 short sh_nummiles[NUM_MILES];
148 CARD hand[HAND_SZ];
149 CARD sh_hand[HAND_SZ];
150 CARD battle;
151 CARD sh_battle;
152 CARD speed;
153 CARD sh_speed;
154 int mileage;
155 int sh_mileage;
156 int hand_tot;
157 int sh_hand_tot;
158 int safescore;
159 int sh_safescore;
160 int coupscore;
161 int total;
162 int sh_total;
163 int games;
164 int sh_games;
165 int was_finished;
166} PLAY;
167
168/*
169 * macros
170 */
171
172# define other(x) (1 - x)
173# define nextplay() (Play = other(Play))
174# define nextwin(x) (1 - x)
175# define opposite(x) (Opposite[x])
176# define issafety(x) (x >= C_GAS_SAFE)
177
178/*
179 * externals
180 */
181
182extern bool Debug, Finished, Next, On_exit, Order, Saved;
183
184extern char *C_fmt, **C_name, *Fromfile, Initstr[];
185
186extern int Card_no, End, Handstart, Movetype, Numcards[], Numgos,
187 Numneed[], Numseen[NUM_CARDS], Play, Value[], Window;
188
189extern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], Sh_discard,
190 *Topcard;
191
192extern FILE *outf;
193
194extern PLAY Player[2];
195
196extern WINDOW *Board, *Miles, *Score;
197
198/*
199 * functions
200 */
201
202CARD getcard();