]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/print.c
Two corrections from George Robbins (confirmed by `The lore of the train'
[bsdgames-darwin.git] / monop / print.c
1 /*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #ifndef lint
35 /*static char sccsid[] = "from: @(#)print.c 5.4 (Berkeley) 6/1/90";*/
36 static char rcsid[] = "$Id: print.c,v 1.2 1993/08/01 18:53:33 mycroft Exp $";
37 #endif /* not lint */
38
39 # include "monop.ext"
40
41 static char buf[80], /* output buffer */
42 *header = "Name Own Price Mg # Rent";
43
44 /*
45 * This routine prints out the current board
46 */
47 printboard() {
48
49 reg int i;
50
51 printf("%s\t%s\n", header, header);
52 for (i = 0; i < N_SQRS/2; i++) {
53 printsq(i, FALSE);
54 putchar('\t');
55 printsq(i+N_SQRS/2, TRUE);
56 }
57 }
58 /*
59 * This routine lists where each player is.
60 */
61 where() {
62
63 reg int i;
64 char *bsp;
65
66 printf("%s Player\n", header);
67 for (i = 0; i < num_play; i++) {
68 printsq(play[i].loc, FALSE);
69 printf(" %s (%d)", play[i].name, i+1);
70 if (cur_p == &play[i])
71 printf(" *");
72 putchar('\n');
73 }
74 }
75 /*
76 * This routine prints out an individual square
77 */
78 printsq(sqn, eoln)
79 int sqn;
80 reg bool eoln; {
81
82 reg int rnt;
83 reg PROP *pp;
84 reg SQUARE *sqp;
85 int i;
86
87 sqp = &board[sqn];
88 printf("%-10.10s", sqp->name);
89 switch (sqp->type) {
90 case SAFE:
91 case CC:
92 case CHANCE:
93 case INC_TAX:
94 case GOTO_J:
95 case LUX_TAX:
96 case IN_JAIL:
97 spec:
98 if (!eoln)
99 printf(" ");
100 break;
101 case PRPTY:
102 pp = sqp->desc;
103 if (sqp->owner < 0) {
104 printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
105 if (!eoln)
106 printf(" ");
107 break;
108 }
109 printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
110 sqp->cost);
111 printmorg(sqp);
112 if (pp->monop) {
113 if (pp->houses < 5)
114 if (pp->houses > 0)
115 printf("%d %4d", pp->houses,
116 pp->rent[pp->houses]);
117 else
118 printf("0 %4d", pp->rent[0] * 2);
119 else
120 printf("H %4d", pp->rent[5]);
121 }
122 else
123 printf(" %4d", pp->rent[0]);
124 break;
125 case UTIL:
126 if (sqp->owner < 0) {
127 printf(" - 150");
128 if (!eoln)
129 printf(" ");
130 break;
131 }
132 printf(" %d 150", sqp->owner+1);
133 printmorg(sqp);
134 printf("%d", play[sqp->owner].num_util);
135 if (!eoln)
136 printf(" ");
137 break;
138 case RR:
139 if (sqp->owner < 0) {
140 printf(" - Railroad 200");
141 if (!eoln)
142 printf(" ");
143 break;
144 }
145 printf(" %d Railroad 200", sqp->owner+1);
146 printmorg(sqp);
147 rnt = 25;
148 rnt <<= play[sqp->owner].num_rr - 1;
149 printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
150 break;
151 }
152 if (eoln)
153 putchar('\n');
154 }
155 /*
156 * This routine prints out the mortgage flag.
157 */
158 printmorg(sqp)
159 reg SQUARE *sqp; {
160
161 if (sqp->desc->morg)
162 printf(" * ");
163 else
164 printf(" ");
165 }
166 /*
167 * This routine lists the holdings of the player given
168 */
169 printhold(pl)
170 reg int pl; {
171
172 reg OWN *op;
173 reg PLAY *pp;
174 char *bsp;
175
176 pp = &play[pl];
177 printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
178 pp->money + prop_worth(pp));
179 printf("\t$%d", pp->money);
180 if (pp->num_gojf) {
181 printf(", %d get-out-of-jail-free card", pp->num_gojf);
182 if (pp->num_gojf > 1)
183 putchar('s');
184 }
185 putchar('\n');
186 if (pp->own_list) {
187 printf("\t%s\n", header);
188 for (op = pp->own_list; op; op = op->next) {
189 putchar('\t');
190 printsq(sqnum(op->sqr), TRUE);
191 }
192 }
193 }