File: mille.h

package info (click to toggle)
kgames 1.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 2,820 kB
  • sloc: ansic: 26,802; yacc: 1,067; lex: 216; makefile: 6
file content (401 lines) | stat: -rw-r--r-- 5,836 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# include	<ctype.h>
# include	<stdio.h>
# include	<stdarg.h>
# include	<string.h>
# include	<unistd.h>
# include	<stdbool.h>
# include	<stdlib.h>

# define reg register
# define TRUE	1
# define FALSE	0

/*
 * @(#)mille.h	1.1 (Berkeley) 4/1/82
 */

/*
 * Miscellaneous constants
 */

# define	unsgn		unsigned
# define	CARD		short

# ifdef  vax
#	define	ARNOLD		78	/* my uid			*/
# else
#	define	ARNOLD		24601	/* my uid			*/
# endif

# define	GURP		28672	/* bad uid			*/
# define	MAXUSERS	35	/* max # of users for startup	*/
# define	HAND_SZ		7	/* number of cards in a hand	*/
# define	DECK_SZ		101	/* number of cards in decks	*/
# define	NUM_SAFE	4	/* number of saftey cards	*/
# define	NUM_MILES	5	/* number of milestones types	*/
# define	NUM_CARDS	20	/* number of types of cards	*/

# define	PLAYER		0
# define	COMP		1

# define	W_SMALL		0	/* Small (initial) window	*/
# define	W_FULL		1	/* Full (final) window		*/

/*
 * Move types
 */

# define	M_DISCARD	0
# define	M_DRAW		1
# define	M_PLAY		2
# define	M_ORDER		3
# define	M_REASONABLE	4

/*
 * Scores
 */

# define	SC_SAFETY	100
# define	SC_ALL_SAFE	300
# define	SC_COUP		300
# define	SC_TRIP		400
# define	SC_SAFE		300
# define	SC_DELAY	300
# define	SC_EXTENSION	200
# define	SC_SHUT_OUT	500

/*
 * safety descriptions
 */

# define	S_UNKNOWN	0	/* location of safety unknown	*/
# define	S_IN_HAND	1	/* safety in player's hand	*/
# define	S_PLAYED	2	/* safety has been played	*/
# define	S_GAS_SAFE	0	/* Gas safety card index	*/
# define	S_SPARE_SAFE	1	/* Tire safety card index	*/
# define	S_DRIVE_SAFE	2	/* Driveing safety card index	*/
# define	S_RIGHT_WAY	3	/* Right-of-Way card index	*/
# define	S_CONV		15	/* conversion from C_ to S_	*/

/*
 * card numbers
 */

# define	C_INIT		-1
# define	C_25		0
# define	C_50		1
# define	C_75		2
# define	C_100		3
# define	C_200		4
# define	C_EMPTY		5
# define	C_FLAT		6	
# define	C_CRASH		7
# define	C_STOP		8
# define	C_LIMIT		9
# define	C_GAS		10
# define	C_SPARE		11
# define	C_REPAIRS	12
# define	C_GO		13
# define	C_END_LIMIT	14
# define	C_GAS_SAFE	15
# define	C_SPARE_SAFE	16
# define	C_DRIVE_SAFE	17
# define	C_RIGHT_WAY	18

typedef struct {
	bool	coups[NUM_SAFE];
	bool	can_go;
	bool	new_battle;
	bool	new_speed;
	short	safety[NUM_SAFE];
	short	nummiles[NUM_MILES];
	CARD	hand[HAND_SZ];
	CARD	battle;
	CARD	speed;
	int	mileage;
	int	hand_tot;
	int	safescore;
	int	coupscore;
	int	total;
	int	games;
} PLAY;

/*
 * animation constants
 */

# define ANIMATE
# define ANIMATE_HAND		0
# define ANIMATE_DECK		1
# define ANIMATE_DISC		2
# define ANIMATE_MILES		3
# define ANIMATE_BATTLE		4
# define ANIMATE_SPEED		5
# define ANIMATE_OBATTLE	6
# define ANIMATE_OSPEED		7
# define ANIMATE_SAFETY		8

/*
 * macros
 */

# define	other(x)	(1 - x)
# define	nextplay()	(Play = other(Play))
# define	nextwin(x)	(1 - x)
# define	opposite(x)	(Opposite[x])
# define	issafety(x)	(x >= C_GAS_SAFE)
# define	is_safety(x)	(x >= C_GAS_SAFE)

# define	is_repair(x)	isrepair(x)

/*
 * externals
 */

extern bool	Debug, Finished, Next, On_exit, Order, Saved;

extern const char	*C_fmt, *Fromfile;
extern const char *const *C_name;
extern char	Initstr[];

extern const int Value[], Numcards[];
extern const CARD	Opposite[NUM_CARDS];

extern int	Card_no, End, Handstart, Movetype, Numgos,
		Numneed[], Numseen[NUM_CARDS], Play, WIndow;

extern CARD	Deck[DECK_SZ], Discard, *Topcard;

extern FILE	*outf;

extern PLAY	Player[2];

/*
 * functions
 */

CARD	getcard();

void
VError(const char *string, va_list ap);

void
Error (const char *string, ...);

void
Prompt (char *string);

void
debug (int pos, char *string, int a0, int a1, int a2);

bool
error (const char *string, ...);

char *
GetpromptedInput (char *string);

void
Message (char *string);

void
stand(int y, int x, char *str);

void
InScore (int line, int player, char *text);

void
prscore(bool for_real);

/* animate.c */
void
animate_move (int player, int orig_type, int orig_arg, int dest_type, int dest_arg);

/* comp.c */
void
calcmove(void);

int
onecard(const PLAY *pp);

int
canplay(const PLAY *pp, const PLAY *op, CARD card);

/* drawcard.c */

/* end.c */
void
finalscore(PLAY *pp);

void
extrapolate(PLAY *pp);

void
undoex(void);

/* init.c */
void
init(void);

void
shuffle(void);

/* mille.c */
void
rub(int sig);

void
die(void);

/* misc.c */
bool
error(const char *str, ...);

bool
check_ext(bool forcomp);

void
check_more(void);

/* move.c */
void
domove(void);

void
check_go(void);

char *
sprint (char * string, ...);

int
haspicked(const PLAY *pp);

char *
playcard(PLAY *pp);

void
account(CARD card);

void
sort(CARD *hand);

/* print.c */

/* roll.c */
int
roll(int ndie, int nsides);

/* save.c */
bool
save(void);

bool
rest_f(const char *file);

bool
rest(void);

/* types.c */
bool
isrepair(CARD card);

int
safety(CARD card);

/* uiXt.c */
void
prboard(void);

void
do_save (void);

void
do_quit (void);

void
getmove(void);

void
ComputerCard (int type);

void
ComputerStatus (char *string);

void
ComputerDistance (int distance);

void
ComputerSpeed (int type);

void
ComputerBattle (int type);

void
ComputerMiles (int type, int ind, int count);

void
EraseComputer (void);

void
ComputerSafety (int type, int ind);

void
DisplayDiscard (int type);

void
DisplayDeck (int numberLeft);

void
HumanDistance (int distance);

void
HumanSpeed (int type);

void
HumanBattle (int type);

void
HumanMiles (int type, int ind, int count);

void
EraseHuman (void);

void
HumanSafety (int type, int ind);

void
HumanHand (int type, int ind);

void
newboard(void);

void
newscore(void);

void
draw_board (void);

void
redraw_board (void);

void
init_ui (int *argc, char **argv);

void
finish_ui (void);

void
update_ui (void);

void
Beep (void);

int
getyn(char *prompt);

void
FlushInput (void);

/* varpush.c */
int
varpush(int file, int (*func)(int, void *, size_t));