monop.h 5.9 KB

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