Commit | Line | Data |
---|---|---|
d2ef7839 | 1 | /* |
d99e6414 | 2 | * Copyright (c) 1980 Regents of the University of California. |
d2ef7839 KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
d99e6414 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
d2ef7839 KB |
16 | */ |
17 | ||
18 | #ifndef lint | |
d99e6414 | 19 | static char sccsid[] = "@(#)print.c 5.3 (Berkeley) %G%"; |
d2ef7839 KB |
20 | #endif /* not lint */ |
21 | ||
22 | # include "monop.ext" | |
23 | ||
24 | static char buf[80], /* output buffer */ | |
25 | *header = "Name Own Price Mg # Rent"; | |
26 | ||
27 | /* | |
28 | * This routine prints out the current board | |
29 | */ | |
30 | printboard() { | |
31 | ||
32 | reg int i; | |
33 | ||
34 | printf("%s\t%s\n", header, header); | |
35 | for (i = 0; i < N_SQRS/2; i++) { | |
36 | printsq(i, FALSE); | |
37 | putchar('\t'); | |
38 | printsq(i+N_SQRS/2, TRUE); | |
39 | } | |
40 | } | |
41 | /* | |
42 | * This routine lists where each player is. | |
43 | */ | |
44 | where() { | |
45 | ||
46 | reg int i; | |
47 | char *bsp; | |
48 | ||
49 | printf("%s Player\n", header); | |
50 | for (i = 0; i < num_play; i++) { | |
51 | printsq(play[i].loc, FALSE); | |
52 | printf(" %s (%d)", play[i].name, i+1); | |
53 | if (cur_p == &play[i]) | |
54 | printf(" *"); | |
55 | putchar('\n'); | |
56 | } | |
57 | } | |
58 | /* | |
59 | * This routine prints out an individual square | |
60 | */ | |
61 | printsq(sqn, eoln) | |
62 | int sqn; | |
63 | reg bool eoln; { | |
64 | ||
65 | reg int rnt; | |
66 | reg PROP *pp; | |
67 | reg SQUARE *sqp; | |
68 | int i; | |
69 | ||
70 | sqp = &board[sqn]; | |
71 | printf("%-10.10s", sqp->name); | |
d2ef7839 KB |
72 | switch (sqp->type) { |
73 | case SAFE: | |
74 | case CC: | |
75 | case CHANCE: | |
2497392a KB |
76 | case INC_TAX: |
77 | case GOTO_J: | |
78 | case LUX_TAX: | |
79 | case IN_JAIL: | |
d2ef7839 KB |
80 | spec: |
81 | if (!eoln) | |
82 | printf(" "); | |
83 | break; | |
84 | case PRPTY: | |
85 | pp = sqp->desc; | |
86 | if (sqp->owner < 0) { | |
87 | printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost); | |
88 | if (!eoln) | |
89 | printf(" "); | |
90 | break; | |
91 | } | |
92 | printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name, | |
93 | sqp->cost); | |
94 | printmorg(sqp); | |
95 | if (pp->monop) { | |
96 | if (pp->houses < 5) | |
97 | if (pp->houses > 0) | |
98 | printf("%d %4d", pp->houses, | |
99 | pp->rent[pp->houses]); | |
100 | else | |
101 | printf("0 %4d", pp->rent[0] * 2); | |
102 | else | |
103 | printf("H %4d", pp->rent[5]); | |
104 | } | |
105 | else | |
106 | printf(" %4d", pp->rent[0]); | |
107 | break; | |
108 | case UTIL: | |
109 | if (sqp->owner < 0) { | |
110 | printf(" - 150"); | |
111 | if (!eoln) | |
112 | printf(" "); | |
113 | break; | |
114 | } | |
115 | printf(" %d 150", sqp->owner+1); | |
116 | printmorg(sqp); | |
117 | printf("%d", play[sqp->owner].num_util); | |
118 | if (!eoln) | |
119 | printf(" "); | |
120 | break; | |
121 | case RR: | |
122 | if (sqp->owner < 0) { | |
123 | printf(" - Railroad 200"); | |
124 | if (!eoln) | |
125 | printf(" "); | |
126 | break; | |
127 | } | |
128 | printf(" %d Railroad 200", sqp->owner+1); | |
129 | printmorg(sqp); | |
130 | rnt = 25; | |
131 | rnt <<= play[sqp->owner].num_rr - 1; | |
132 | printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1)); | |
133 | break; | |
134 | } | |
135 | if (eoln) | |
136 | putchar('\n'); | |
137 | } | |
138 | /* | |
139 | * This routine prints out the mortgage flag. | |
140 | */ | |
141 | printmorg(sqp) | |
142 | reg SQUARE *sqp; { | |
143 | ||
144 | if (sqp->desc->morg) | |
145 | printf(" * "); | |
146 | else | |
147 | printf(" "); | |
148 | } | |
149 | /* | |
150 | * This routine lists the holdings of the player given | |
151 | */ | |
152 | printhold(pl) | |
153 | reg int pl; { | |
154 | ||
155 | reg OWN *op; | |
156 | reg PLAY *pp; | |
157 | char *bsp; | |
158 | ||
159 | pp = &play[pl]; | |
160 | printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1, | |
161 | pp->money + prop_worth(pp)); | |
162 | printf("\t$%d", pp->money); | |
163 | if (pp->num_gojf) { | |
164 | printf(", %d get-out-of-jail-free card", pp->num_gojf); | |
165 | if (pp->num_gojf > 1) | |
166 | putchar('s'); | |
167 | } | |
168 | putchar('\n'); | |
169 | if (pp->own_list) { | |
170 | printf("\t%s\n", header); | |
171 | for (op = pp->own_list; op; op = op->next) { | |
172 | putchar('\t'); | |
173 | printsq(sqnum(op->sqr), TRUE); | |
174 | } | |
175 | } | |
176 | } |