xref: /netbsd-src/games/monop/monop.h (revision 81e0d2b0af8485d94ed5da487d4253841a2e6e45)
1 /*	$NetBSD: monop.h,v 1.12 2004/01/27 20:30:30 jsm Exp $	*/
2 
3 /*
4  * Copyright (c) 1980, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *	@(#)monop.h	8.1 (Berkeley) 5/31/93
32  */
33 
34 #include <err.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38 
39 #define	bool	char
40 
41 #define	TRUE	(1)
42 #define	FALSE	(0)
43 
44 #define	N_MON	8	/* number of monopolies			*/
45 #define	N_PROP	22	/* number of normal property squares	*/
46 #define	N_RR	4	/* number of railroads			*/
47 #define	N_UTIL	2	/* number of utilities			*/
48 #define	N_SQRS	40	/* number of squares on board		*/
49 #define	MAX_PL	9	/* maximum number of players		*/
50 #define	MAX_PRP	(N_PROP+N_RR+N_UTIL) /* max # ownable property	*/
51 
52 				/* square type numbers			*/
53 #define	PRPTY	0	/* normal property			*/
54 #define	RR	1	/* railroad				*/
55 #define	UTIL	2	/* water works - electric co		*/
56 #define	SAFE	3	/* safe spot				*/
57 #define	CC	4	/* community chest			*/
58 #define	CHANCE	5	/* chance (surprise!!!)			*/
59 #define	INC_TAX	6	/* Income tax */
60 #define	GOTO_J	7	/* Go To Jail! */
61 #define	LUX_TAX	8	/* Luxury tax */
62 #define	IN_JAIL	9	/* In jail */
63 
64 #define	JAIL	40	/* JAIL square number			*/
65 
66 #define	lucky(str)	printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1])
67 #define	printline()	printf("------------------------------\n")
68 #define	sqnum(sqp)	(sqp - board)
69 #define	swap(A1,A2)	if ((A1) != (A2)) { \
70 					(A1) ^= (A2); \
71 					(A2) ^= (A1); \
72 					(A1) ^= (A2); \
73 				}
74 
75 struct sqr_st {			/* structure for square			*/
76 	const char	*name;		/* place name			*/
77 	short	owner;			/* owner number			*/
78 	short	type;			/* place type			*/
79 	struct prp_st	*desc;		/* description struct		*/
80 	int	cost;			/* cost				*/
81 };
82 
83 typedef struct sqr_st	SQUARE;
84 
85 struct mon_st {			/* monopoly description structure	*/
86 	const char	*name;		/* monop. name (color)		*/
87 	short	owner;			/* owner of monopoly		*/
88 	short	num_in;			/* # in monopoly		*/
89 	short	num_own;		/* # owned (-1: not poss. monop)*/
90 	short	h_cost;			/* price of houses		*/
91 	const char	*not_m;		/* name if not monopoly		*/
92 	const char	*mon_n;		/* name if a monopoly		*/
93 	unsigned char	sqnums[3];	/* Square numbers (used to init)*/
94 	SQUARE	*sq[3];			/* list of squares in monop	*/
95 };
96 
97 typedef struct mon_st	MON;
98 
99 /*
100  * This struct describes a property.  For railroads and utilities, only
101  * the "morg" member is used.
102  */
103 struct prp_st {			/* property description structure	*/
104 	bool	morg;			/* set if mortgaged		*/
105 	bool	monop;			/* set if monopoly		*/
106 	short	square;			/* square description		*/
107 	short	houses;			/* number of houses		*/
108 	MON	*mon_desc;		/* name of color		*/
109 	int	rent[6];		/* rents			*/
110 };
111 
112 struct own_st {			/* element in list owned things		*/
113 	SQUARE	*sqr;			/* pointer to square		*/
114 	struct own_st	*next;		/* next in list			*/
115 };
116 
117 typedef struct own_st	OWN;
118 
119 struct plr_st {			/* player description structure		*/
120 	char	*name;			/* owner name			*/
121 	short	num_gojf;		/* # of get-out-of-jail-free's	*/
122 	short	num_rr;			/* # of railroads owned		*/
123 	short	num_util;		/* # of water works/elec. co.	*/
124 	short	loc;			/* location on board		*/
125 	short	in_jail;		/* count of turns in jail	*/
126 	int	money;			/* amount of money		*/
127 	OWN	*own_list;		/* start of propery list	*/
128 };
129 
130 typedef struct plr_st	PLAY;
131 typedef struct prp_st	PROP;
132 typedef struct prp_st	RR_S;
133 typedef struct prp_st	UTIL_S;
134 
135 
136 /* cards.c */
137 void init_decks(void);
138 void get_card(DECK *);
139 
140 /* execute.c */
141 void execute(int);
142 void do_move(void);
143 void move(int);
144 void save(void);
145 void restore(void);
146 int rest_f(const char *);
147 
148 /* getinp.c */
149 int getinp(const char *, const char *const []);
150 
151 /* houses.c */
152 void buy_houses(void);
153 void sell_houses(void);
154 
155 /* jail.c */
156 void card(void);
157 void ret_card(PLAY *);
158 void pay(void);
159 int move_jail(int, int );
160 void printturn(void);
161 
162 /* misc.c */
163 int getyn(const char *);
164 void notify(void);
165 void next_play(void);
166 int get_int(const char *);
167 void set_ownlist(int);
168 void is_monop(MON *, int);
169 void is_not_monop(MON *);
170 void list(void);
171 void list_all(void);
172 void quit(void);
173 
174 /* morg.c */
175 void mortgage(void);
176 void unmortgage(void);
177 void force_morg(void);
178 
179 /* print.c */
180 void printboard(void);
181 void where(void);
182 void printsq(int, bool);
183 void printhold(int);
184 
185 /* prop.c */
186 void buy(int, SQUARE *);
187 void add_list(int, OWN **, int);
188 void del_list(int, OWN **, short);
189 void bid(void);
190 int prop_worth(PLAY *);
191 
192 /* rent.c */
193 void rent(SQUARE *);
194 
195 /* roll.c */
196 int roll(int, int);
197 
198 /* spec.c */
199 void inc_tax(void);
200 void goto_jail(void);
201 void lux_tax(void);
202 void cc(void);
203 void chance(void);
204 
205 /* trade.c */
206 void trade(void);
207 void resign(void);
208