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