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