Home | History | Annotate | Line # | Download | only in monop
monop.h revision 1.6
      1 /*	$NetBSD: monop.h,v 1.6 1997/10/12 17:45:20 christos 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	<stdio.h>
     39 # include	<stdlib.h>
     40 # include	<string.h>
     41 
     42 # define	bool	char
     43 
     44 # define	TRUE	(1)
     45 # define	FALSE	(0)
     46 
     47 # define	N_MON	8	/* number of monopolies			*/
     48 # define	N_PROP	22	/* number of normal property squares	*/
     49 # define	N_RR	4	/* number of railroads			*/
     50 # define	N_UTIL	2	/* number of utilities			*/
     51 # define	N_SQRS	40	/* number of squares on board		*/
     52 # define	MAX_PL	9	/* maximum number of players		*/
     53 # define	MAX_PRP	(N_PROP+N_RR+N_UTIL) /* max # ownable property	*/
     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 # define	swap(A1,A2)	if ((A1) != (A2)) { \
     73 					(A1) ^= (A2); \
     74 					(A2) ^= (A1); \
     75 					(A1) ^= (A2); \
     76 				}
     77 
     78 struct sqr_st {			/* structure for square			*/
     79 	char	*name;			/* place name			*/
     80 	short	owner;			/* owner number			*/
     81 	short	type;			/* place type			*/
     82 	struct prp_st	*desc;		/* description struct		*/
     83 	int	cost;			/* cost				*/
     84 };
     85 
     86 typedef struct sqr_st	SQUARE;
     87 
     88 struct mon_st {			/* monopoly description structure	*/
     89 	char	*name;			/* monop. name (color)		*/
     90 	short	owner;			/* owner of monopoly		*/
     91 	short	num_in;			/* # in monopoly		*/
     92 	short	num_own;		/* # owned (-1: not poss. monop)*/
     93 	short	h_cost;			/* price of houses		*/
     94 	char	*not_m;			/* name if not monopoly		*/
     95 	char	*mon_n;			/* name if a monopoly		*/
     96 	unsigned char	sqnums[3];	/* Square numbers (used to init)*/
     97 	SQUARE	*sq[3];			/* list of squares in monop	*/
     98 };
     99 
    100 typedef struct mon_st	MON;
    101 
    102 /*
    103  * This struct describes a property.  For railroads and utilities, only
    104  * the "morg" member is used.
    105  */
    106 struct prp_st {			/* property description structure	*/
    107 	bool	morg;			/* set if mortgaged		*/
    108 	bool	monop;			/* set if monopoly		*/
    109 	short	square;			/* square description		*/
    110 	short	houses;			/* number of houses		*/
    111 	MON	*mon_desc;		/* name of color		*/
    112 	int	rent[6];		/* rents			*/
    113 };
    114 
    115 struct own_st {			/* element in list owned things		*/
    116 	SQUARE	*sqr;			/* pointer to square		*/
    117 	struct own_st	*next;		/* next in list			*/
    118 };
    119 
    120 typedef struct own_st	OWN;
    121 
    122 struct plr_st {			/* player description structure		*/
    123 	char	*name;			/* owner name			*/
    124 	short	num_gojf;		/* # of get-out-of-jail-free's	*/
    125 	short	num_rr;			/* # of railroads owned		*/
    126 	short	num_util;		/* # of water works/elec. co.	*/
    127 	short	loc;			/* location on board		*/
    128 	short	in_jail;		/* count of turns in jail	*/
    129 	int	money;			/* amount of money		*/
    130 	OWN	*own_list;		/* start of propery list	*/
    131 };
    132 
    133 typedef struct plr_st	PLAY;
    134 typedef struct prp_st	PROP;
    135 typedef struct prp_st	RR_S;
    136 typedef struct prp_st	UTIL_S;
    137 
    138 
    139 /* cards.c */
    140 void init_decks __P((void));
    141 void get_card __P((DECK *));
    142 
    143 /* execute.c */
    144 void execute __P((int));
    145 void do_move __P((void));
    146 void move __P((int));
    147 void save __P((void));
    148 void restore __P((void));
    149 int rest_f __P((char *));
    150 
    151 /* getinp.c */
    152 int getinp __P((char *, char *[]));
    153 
    154 /* houses.c */
    155 void buy_houses __P((void));
    156 void sell_houses __P((void));
    157 
    158 /* jail.c */
    159 void card __P((void));
    160 void ret_card __P((PLAY *));
    161 void pay __P((void));
    162 int move_jail __P((int, int ));
    163 void printturn __P((void));
    164 
    165 /* misc.c */
    166 int getyn __P((char *));
    167 void notify __P((void));
    168 void next_play __P((void));
    169 int get_int __P((char *));
    170 void set_ownlist __P((int));
    171 void is_monop __P((MON *, int));
    172 void isnot_monop __P((MON *));
    173 void list __P((void));
    174 void list_all __P((void));
    175 void quit __P((void));
    176 
    177 /* morg.c */
    178 void mortgage __P((void));
    179 void unmortgage __P((void));
    180 void force_morg __P((void));
    181 
    182 /* print.c */
    183 void printboard __P((void));
    184 void where __P((void));
    185 void printsq __P((int, bool));
    186 void printhold __P((int));
    187 
    188 /* prop.c */
    189 void buy __P((int, SQUARE *));
    190 void add_list __P((int, OWN **, int));
    191 void del_list __P((int, OWN **, short));
    192 void bid __P((void));
    193 int prop_worth __P((PLAY *));
    194 
    195 /* rent.c */
    196 void rent __P((SQUARE *));
    197 
    198 /* roll.c */
    199 int roll __P((int, int));
    200 
    201 /* spec.c */
    202 void inc_tax __P((void));
    203 void goto_jail __P((void));
    204 void lux_tax __P((void));
    205 void cc __P((void));
    206 void chance __P((void));
    207 
    208 /* trade.c */
    209 void trade __P((void));
    210 void resign __P((void));
    211