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