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