Home | History | Annotate | Line # | Download | only in monop
monop.h revision 1.4
      1 /*	$NetBSD: monop.h,v 1.4 1995/04/24 12:24:23 cgd 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	reg	register
     43 # define	shrt	char
     44 # define	bool	char
     45 # define	unsgn	unsigned
     46 
     47 # define	TRUE	(1)
     48 # define	FALSE	(0)
     49 
     50 # define	N_MON	8	/* number of monopolies			*/
     51 # define	N_PROP	22	/* number of normal property squares	*/
     52 # define	N_RR	4	/* number of railroads			*/
     53 # define	N_UTIL	2	/* number of utilities			*/
     54 # define	N_SQRS	40	/* number of squares on board		*/
     55 # define	MAX_PL	9	/* maximum number of players		*/
     56 # define	MAX_PRP	(N_PROP+N_RR+N_UTIL) /* max # ownable property	*/
     57 
     58 				/* square type numbers			*/
     59 # define	PRPTY	0	/* normal property			*/
     60 # define	RR	1	/* railroad				*/
     61 # define	UTIL	2	/* water works - electric co		*/
     62 # define	SAFE	3	/* safe spot				*/
     63 # define	CC	4	/* community chest			*/
     64 # define	CHANCE	5	/* chance (surprise!!!)			*/
     65 # define	INC_TAX	6	/* Income tax */
     66 # define	GOTO_J	7	/* Go To Jail! */
     67 # define	LUX_TAX	8	/* Luxury tax */
     68 # define	IN_JAIL	9	/* In jail */
     69 
     70 # define	JAIL	40	/* JAIL square number			*/
     71 
     72 # define	lucky(str)	printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1])
     73 # define	printline()	printf("------------------------------\n")
     74 # define	sqnum(sqp)	(sqp - board)
     75 # define	swap(A1,A2)	if ((A1) != (A2)) { \
     76 					(A1) ^= (A2); \
     77 					(A2) ^= (A1); \
     78 					(A1) ^= (A2); \
     79 				}
     80 
     81 struct sqr_st {			/* structure for square			*/
     82 	char	*name;			/* place name			*/
     83 	shrt	owner;			/* owner number			*/
     84 	shrt	type;			/* place type			*/
     85 	struct prp_st	*desc;		/* description struct		*/
     86 	int	cost;			/* cost				*/
     87 };
     88 
     89 typedef struct sqr_st	SQUARE;
     90 
     91 struct mon_st {			/* monopoly description structure	*/
     92 	char	*name;			/* monop. name (color)		*/
     93 	shrt	owner;			/* owner of monopoly		*/
     94 	shrt	num_in;			/* # in monopoly		*/
     95 	shrt	num_own;		/* # owned (-1: not poss. monop)*/
     96 	shrt	h_cost;			/* price of houses		*/
     97 	char	*not_m;			/* name if not monopoly		*/
     98 	char	*mon_n;			/* name if a monopoly		*/
     99 	char	sqnums[3];		/* Square numbers (used to init)*/
    100 	SQUARE	*sq[3];			/* list of squares in monop	*/
    101 };
    102 
    103 typedef struct mon_st	MON;
    104 
    105 /*
    106  * This struct describes a property.  For railroads and utilities, only
    107  * the "morg" member is used.
    108  */
    109 struct prp_st {			/* property description structure	*/
    110 	bool	morg;			/* set if mortgaged		*/
    111 	bool	monop;			/* set if monopoly		*/
    112 	shrt	square;			/* square description		*/
    113 	shrt	houses;			/* number of houses		*/
    114 	MON	*mon_desc;		/* name of color		*/
    115 	int	rent[6];		/* rents			*/
    116 };
    117 
    118 struct own_st {			/* element in list owned things		*/
    119 	SQUARE	*sqr;			/* pointer to square		*/
    120 	struct own_st	*next;		/* next in list			*/
    121 };
    122 
    123 typedef struct own_st	OWN;
    124 
    125 struct plr_st {			/* player description structure		*/
    126 	char	*name;			/* owner name			*/
    127 	shrt	num_gojf;		/* # of get-out-of-jail-free's	*/
    128 	shrt	num_rr;			/* # of railroads owned		*/
    129 	shrt	num_util;		/* # of water works/elec. co.	*/
    130 	shrt	loc;			/* location on board		*/
    131 	shrt	in_jail;		/* count of turns in jail	*/
    132 	int	money;			/* amount of money		*/
    133 	OWN	*own_list;		/* start of propery list	*/
    134 };
    135 
    136 typedef struct plr_st	PLAY;
    137 typedef struct prp_st	PROP;
    138 typedef struct prp_st	RR_S;
    139 typedef struct prp_st	UTIL_S;
    140 
    141 int	cc(), chance(), lux_tax(), goto_jail(), inc_tax();
    142