1 /* $OpenBSD: monop.h,v 1.7 2003/06/03 03:01:40 millert 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 #include <stdio.h> 36 #include <stdlib.h> 37 #include <string.h> 38 39 #ifdef __CHAR_UNSIGNED__ 40 #define shrt short 41 #else 42 #define shrt char 43 #endif 44 #define bool int8_t 45 46 #define TRUE (1) 47 #define FALSE (0) 48 49 #define N_MON 8 /* number of monopolies */ 50 #define N_PROP 22 /* number of normal property squares */ 51 #define N_RR 4 /* number of railroads */ 52 #define N_UTIL 2 /* number of utilities */ 53 #define N_SQRS 40 /* number of squares on board */ 54 #define MAX_PL 9 /* maximum number of players */ 55 #define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */ 56 #define N_HOUSE 32 /* total number of houses available */ 57 #define N_HOTEL 12 /* total number of hotels available */ 58 59 /* square type numbers */ 60 #define PRPTY 0 /* normal property */ 61 #define RR 1 /* railroad */ 62 #define UTIL 2 /* water works - electric co */ 63 #define SAFE 3 /* safe spot */ 64 #define CC 4 /* community chest */ 65 #define CHANCE 5 /* chance (surprise!!!) */ 66 #define INC_TAX 6 /* Income tax */ 67 #define GOTO_J 7 /* Go To Jail! */ 68 #define LUX_TAX 8 /* Luxury tax */ 69 #define IN_JAIL 9 /* In jail */ 70 71 #define JAIL 40 /* JAIL square number */ 72 73 #define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1]) 74 #define printline() printf("------------------------------\n") 75 #define sqnum(sqp) (sqp - board) 76 77 struct sqr_st { /* structure for square */ 78 char *name; /* place name */ 79 shrt owner; /* owner number */ 80 shrt type; /* place type */ 81 struct prp_st *desc; /* description struct */ 82 int cost; /* cost */ 83 }; 84 85 typedef struct sqr_st SQUARE; 86 87 struct mon_st { /* monopoly description structure */ 88 char *name; /* monop. name (color) */ 89 shrt owner; /* owner of monopoly */ 90 shrt num_in; /* # in monopoly */ 91 shrt num_own; /* # owned (-1: not poss. monop)*/ 92 shrt h_cost; /* price of houses */ 93 char *not_m; /* name if not monopoly */ 94 char *mon_n; /* name if a monopoly */ 95 char sqnums[3]; /* Square numbers (used to init)*/ 96 SQUARE *sq[3]; /* list of squares in monop */ 97 }; 98 99 typedef struct mon_st MON; 100 101 /* 102 * This struct describes a property. For railroads and utilities, only 103 * the "morg" member is used. 104 */ 105 struct prp_st { /* property description structure */ 106 bool morg; /* set if mortgaged */ 107 bool monop; /* set if monopoly */ 108 shrt square; /* square description */ 109 shrt houses; /* number of houses */ 110 MON *mon_desc; /* name of color */ 111 int rent[6]; /* rents */ 112 }; 113 114 struct own_st { /* element in list owned things */ 115 SQUARE *sqr; /* pointer to square */ 116 struct own_st *next; /* next in list */ 117 }; 118 119 typedef struct own_st OWN; 120 121 struct plr_st { /* player description structure */ 122 char *name; /* owner name */ 123 shrt num_gojf; /* # of get-out-of-jail-free's */ 124 shrt num_rr; /* # of railroads owned */ 125 shrt num_util; /* # of water works/elec. co. */ 126 shrt loc; /* location on board */ 127 shrt in_jail; /* count of turns in jail */ 128 int money; /* amount of money */ 129 OWN *own_list; /* start of property list */ 130 }; 131 132 typedef struct plr_st PLAY; 133 typedef struct prp_st PROP; 134 typedef struct prp_st RR_S; 135 typedef struct prp_st UTIL_S; 136 137 /* cards.c */ 138 void init_decks(void); 139 void get_card(DECK *); 140 void ret_card(PLAY *); 141 142 /* execute.c */ 143 void execute(int); 144 void do_move(void); 145 void move(int); 146 void save(void); 147 void restore(void); 148 void game_restore(void); 149 int rest_f(char *); 150 151 /* getinp.c */ 152 int getinp(char *, char *[]); 153 154 /* houses.c */ 155 void buy_houses(void); 156 void sell_houses(void); 157 158 /* jail.c */ 159 void card(void); 160 void pay(void); 161 int move_jail(int, int ); 162 void printturn(void); 163 164 /* misc.c */ 165 int getyn(char *); 166 void notify(void); 167 void next_play(void); 168 int get_int(char *); 169 void set_ownlist(int); 170 void is_monop(MON *, int); 171 void isnot_monop(MON *); 172 void list(void); 173 void list_all(void); 174 void quit(void); 175 176 /* morg.c */ 177 void mortgage(void); 178 void unmortgage(void); 179 void force_morg(void); 180 181 /* print.c */ 182 void printboard(void); 183 void where(void); 184 void printsq(int, bool); 185 void printhold(int); 186 187 /* prop.c */ 188 void buy(int, SQUARE *); 189 void add_list(int, OWN **, int); 190 void del_list(int, OWN **, shrt); 191 void bid(void); 192 int prop_worth(PLAY *); 193 194 /* rent.c */ 195 void rent(SQUARE *); 196 197 /* roll.c */ 198 int roll(int, int); 199 200 /* spec.c */ 201 void inc_tax(void); 202 void goto_jail(void); 203 void lux_tax(void); 204 void cc(void); 205 void chance(void); 206 207 /* trade.c */ 208 void trade(void); 209 void resign(void); 210