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