print.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* $NetBSD: print.c,v 1.8 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. #include <sys/cdefs.h>
  31. #ifndef lint
  32. #if 0
  33. static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: print.c,v 1.8 2004/01/27 20:30:30 jsm Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include "monop.ext"
  39. static const char *header = "Name Own Price Mg # Rent";
  40. static void printmorg(const SQUARE *);
  41. /*
  42. * This routine prints out the current board
  43. */
  44. void
  45. printboard()
  46. {
  47. int i;
  48. printf("%s\t%s\n", header, header);
  49. for (i = 0; i < N_SQRS/2; i++) {
  50. printsq(i, FALSE);
  51. putchar('\t');
  52. printsq(i+N_SQRS/2, TRUE);
  53. }
  54. }
  55. /*
  56. * This routine lists where each player is.
  57. */
  58. void
  59. where()
  60. {
  61. int i;
  62. printf("%s Player\n", header);
  63. for (i = 0; i < num_play; i++) {
  64. printsq(play[i].loc, FALSE);
  65. printf(" %s (%d)", play[i].name, i+1);
  66. if (cur_p == &play[i])
  67. printf(" *");
  68. putchar('\n');
  69. }
  70. }
  71. /*
  72. * This routine prints out an individual square
  73. */
  74. void
  75. printsq(sqn, eoln)
  76. int sqn;
  77. bool eoln;
  78. {
  79. int rnt;
  80. PROP *pp;
  81. SQUARE *sqp;
  82. sqp = &board[sqn];
  83. printf("%-10.10s", sqp->name);
  84. switch (sqp->type) {
  85. case SAFE:
  86. case CC:
  87. case CHANCE:
  88. case INC_TAX:
  89. case GOTO_J:
  90. case LUX_TAX:
  91. case IN_JAIL:
  92. if (!eoln)
  93. printf(" ");
  94. break;
  95. case PRPTY:
  96. pp = sqp->desc;
  97. if (sqp->owner < 0) {
  98. printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
  99. if (!eoln)
  100. printf(" ");
  101. break;
  102. }
  103. printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
  104. sqp->cost);
  105. printmorg(sqp);
  106. if (pp->monop) {
  107. if (pp->houses < 5)
  108. if (pp->houses > 0)
  109. printf("%d %4d", pp->houses,
  110. pp->rent[pp->houses]);
  111. else
  112. printf("0 %4d", pp->rent[0] * 2);
  113. else
  114. printf("H %4d", pp->rent[5]);
  115. }
  116. else
  117. printf(" %4d", pp->rent[0]);
  118. break;
  119. case UTIL:
  120. if (sqp->owner < 0) {
  121. printf(" - 150");
  122. if (!eoln)
  123. printf(" ");
  124. break;
  125. }
  126. printf(" %d 150", sqp->owner+1);
  127. printmorg(sqp);
  128. printf("%d", play[sqp->owner].num_util);
  129. if (!eoln)
  130. printf(" ");
  131. break;
  132. case RR:
  133. if (sqp->owner < 0) {
  134. printf(" - Railroad 200");
  135. if (!eoln)
  136. printf(" ");
  137. break;
  138. }
  139. printf(" %d Railroad 200", sqp->owner+1);
  140. printmorg(sqp);
  141. rnt = 25;
  142. rnt <<= play[sqp->owner].num_rr - 1;
  143. printf("%d %4d", play[sqp->owner].num_rr,
  144. 25 << (play[sqp->owner].num_rr - 1));
  145. break;
  146. }
  147. if (eoln)
  148. putchar('\n');
  149. }
  150. /*
  151. * This routine prints out the mortgage flag.
  152. */
  153. static void
  154. printmorg(sqp)
  155. const SQUARE *sqp;
  156. {
  157. if (sqp->desc->morg)
  158. printf(" * ");
  159. else
  160. printf(" ");
  161. }
  162. /*
  163. * This routine lists the holdings of the player given
  164. */
  165. void
  166. printhold(pl)
  167. int pl;
  168. {
  169. OWN *op;
  170. PLAY *pp;
  171. pp = &play[pl];
  172. printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl],
  173. pl + 1, pp->money + prop_worth(pp));
  174. printf("\t$%d", pp->money);
  175. if (pp->num_gojf) {
  176. printf(", %d get-out-of-jail-free card", pp->num_gojf);
  177. if (pp->num_gojf > 1)
  178. putchar('s');
  179. }
  180. putchar('\n');
  181. if (pp->own_list) {
  182. printf("\t%s\n", header);
  183. for (op = pp->own_list; op; op = op->next) {
  184. putchar('\t');
  185. printsq(sqnum(op->sqr), TRUE);
  186. }
  187. }
  188. }