carp: add carp_group_demote_adj()
[dragonfly.git] / games / mille / mille.h
CommitLineData
6693db17 1/*-
984263bc
MD
2 * Copyright (c) 1982, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
6693db17 13 * 3. Neither the name of the University nor the names of its contributors
984263bc
MD
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)mille.h 8.1 (Berkeley) 5/31/93
30 *
31 * $FreeBSD: src/games/mille/mille.h,v 1.7 1999/12/12 06:17:24 billf Exp $
46c76430 32 * $DragonFly: src/games/mille/mille.h,v 1.6 2006/08/27 17:17:23 pavalos Exp $
984263bc
MD
33 */
34
6693db17
SW
35#include <sys/types.h>
36#include <sys/uio.h>
37#include <ctype.h>
38#include <curses.h>
39#include <stdlib.h>
40#include <string.h>
41#include <unistd.h>
984263bc
MD
42
43/*
44 * @(#)mille.h 1.1 (Berkeley) 4/1/82
45 */
46
47/*
48 * Miscellaneous constants
49 */
50
6693db17
SW
51#define CARD short
52
53#define HAND_SZ 7 /* number of cards in a hand */
54#define DECK_SZ 101 /* number of cards in decks */
55#define NUM_SAFE 4 /* number of saftey cards */
56#define NUM_MILES 5 /* number of milestones types */
57#define NUM_CARDS 20 /* number of types of cards */
58#define BOARD_Y 17 /* size of board screen */
59#define BOARD_X 40
60#define MILES_Y 7 /* size of mileage screen */
61#define MILES_X 80
62#define SCORE_Y 17 /* size of score screen */
63#define SCORE_X 40
64#define MOVE_Y 10 /* Where to print move prompt */
65#define MOVE_X 20
66#define ERR_Y 15 /* Where to print errors */
67#define ERR_X 5
68#define EXT_Y 4 /* Where to put Extension */
69#define EXT_X 9
70
71#define PLAYER 0
72#define COMP 1
73
74#define W_SMALL 0 /* Small (initial) window */
75#define W_FULL 1 /* Full (final) window */
984263bc
MD
76
77/*
78 * Move types
79 */
80
6693db17
SW
81#define M_DISCARD 0
82#define M_DRAW 1
83#define M_PLAY 2
84#define M_ORDER 3
984263bc
MD
85
86/*
87 * Scores
88 */
89
6693db17
SW
90#define SC_SAFETY 100
91#define SC_ALL_SAFE 300
92#define SC_COUP 300
93#define SC_TRIP 400
94#define SC_SAFE 300
95#define SC_DELAY 300
96#define SC_EXTENSION 200
97#define SC_SHUT_OUT 500
984263bc
MD
98
99/*
100 * safety descriptions
101 */
102
6693db17
SW
103#define S_UNKNOWN 0 /* location of safety unknown */
104#define S_IN_HAND 1 /* safety in player's hand */
105#define S_PLAYED 2 /* safety has been played */
106#define S_GAS_SAFE 0 /* Gas safety card index */
107#define S_SPARE_SAFE 1 /* Tire safety card index */
108#define S_DRIVE_SAFE 2 /* Driveing safety card index */
109#define S_RIGHT_WAY 3 /* Right-of-Way card index */
110#define S_CONV 15 /* conversion from C_ to S_ */
984263bc
MD
111
112/*
113 * card numbers
114 */
115
6693db17
SW
116#define C_INIT -1
117#define C_25 0
118#define C_50 1
119#define C_75 2
120#define C_100 3
121#define C_200 4
122#define C_EMPTY 5
123#define C_FLAT 6
124#define C_CRASH 7
125#define C_STOP 8
126#define C_LIMIT 9
127#define C_GAS 10
128#define C_SPARE 11
129#define C_REPAIRS 12
130#define C_GO 13
131#define C_END_LIMIT 14
132#define C_GAS_SAFE 15
133#define C_SPARE_SAFE 16
134#define C_DRIVE_SAFE 17
135#define C_RIGHT_WAY 18
984263bc
MD
136
137/*
138 * prompt types
139 */
140
6693db17
SW
141#define MOVEPROMPT 0
142#define REALLYPROMPT 1
143#define ANOTHERHANDPROMPT 2
144#define ANOTHERGAMEPROMPT 3
145#define SAVEGAMEPROMPT 4
146#define SAMEFILEPROMPT 5
147#define FILEPROMPT 6
148#define EXTENSIONPROMPT 7
149#define OVERWRITEFILEPROMPT 8
984263bc 150
6693db17
SW
151#define erasechar() cur_term->Nttyb.c_cc[VERASE]
152#define killchar() cur_term->Nttyb.c_cc[VKILL]
984263bc
MD
153
154typedef struct {
155 bool coups[NUM_SAFE];
156 bool can_go;
157 bool new_battle;
158 bool new_speed;
159 short safety[NUM_SAFE];
160 short sh_safety[NUM_SAFE];
161 short nummiles[NUM_MILES];
162 short sh_nummiles[NUM_MILES];
163 CARD hand[HAND_SZ];
164 CARD sh_hand[HAND_SZ];
165 CARD battle;
166 CARD sh_battle;
167 CARD speed;
168 CARD sh_speed;
169 int mileage;
170 int sh_mileage;
171 int hand_tot;
172 int sh_hand_tot;
173 int safescore;
174 int sh_safescore;
175 int coupscore;
176 int total;
177 int sh_total;
178 int games;
179 int sh_games;
180 int was_finished;
181} PLAY;
182
183/*
184 * macros
185 */
186
6693db17
SW
187#define other(x) (1 - x)
188#define nextplay() (Play = other(Play))
189#define nextwin(x) (1 - x)
190#define opposite(x) (Opposite[x])
191#define issafety(x) (x >= C_GAS_SAFE)
984263bc
MD
192
193/*
194 * externals
195 */
196
197extern bool Debug, Finished, Next, On_exit, Order, Saved;
198
46c76430
PA
199extern char *Fromfile, Initstr[];
200extern const char *C_fmt, **C_name;
984263bc
MD
201
202extern int Card_no, End, Handstart, Movetype, Numcards[], Numgos,
203 Numneed[], Numseen[NUM_CARDS], Play, Value[], Window;
204
205extern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], Sh_discard,
206 *Topcard;
207
208extern FILE *outf;
209
210extern PLAY Player[2];
211
212extern WINDOW *Board, *Miles, *Score;
213
214/*
215 * functions
216 */
217
6693db17
SW
218void account(CARD);
219void calcmove(void);
220bool canplay(PLAY *, PLAY *, CARD);
221bool check_ext(bool);
222void check_more(void);
223void die(int);
224void domove(void);
225bool error(const char *, ...);
984263bc 226#ifdef EXTRAP
6693db17 227void extrapolate(PLAY *);
984263bc 228#endif
6693db17
SW
229void finalscore(PLAY *);
230CARD getcard(void);
231bool getyn(int);
232void init(void);
233int isrepair(CARD);
234void newboard(void);
235void newscore(void);
236bool onecard(PLAY *);
237void prboard(void);
238void prompt(int);
239void prscore(bool);
240char readch(void);
241bool rest_f(char *);
242int roll(int, int);
243void rub(int);
244CARD safety(CARD);
245bool save(void);
246void shuffle(void);
247void sort(CARD *);
248bool varpush(int, ssize_t (*)(int, const struct iovec *, int));
984263bc 249#ifdef EXTRAP
6693db17 250void undoex(void);
984263bc 251#endif