]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/print.c
A few more whitespace/KNF. I keep hoping I've found them all...
[bsdgames-darwin.git] / monop / print.c
1 /* $NetBSD: print.c,v 1.10 2008/02/20 05:08:46 dholland 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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 #ifndef lint
34 #if 0
35 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93";
36 #else
37 __RCSID("$NetBSD: print.c,v 1.10 2008/02/20 05:08:46 dholland Exp $");
38 #endif
39 #endif /* not lint */
40
41 #include "monop.ext"
42
43 static const char *header = "Name Own Price Mg # Rent";
44
45 static void printmorg(const SQUARE *);
46
47 /*
48 * This routine prints out the current board
49 */
50 void
51 printboard()
52 {
53 int i;
54
55 printf("%s\t%s\n", header, header);
56 for (i = 0; i < N_SQRS/2; i++) {
57 printsq(i, FALSE);
58 putchar('\t');
59 printsq(i+N_SQRS/2, TRUE);
60 }
61 }
62
63 /*
64 * This routine lists where each player is.
65 */
66 void
67 where()
68 {
69 int i;
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 /*
82 * This routine prints out an individual square
83 */
84 void
85 printsq(sqn, eoln)
86 int sqn;
87 bool eoln;
88 {
89 int rnt;
90 PROP *pp;
91 SQUARE *sqp;
92
93 sqp = &board[sqn];
94 printf("%-10.10s", sqp->name);
95 switch (sqp->type) {
96 case SAFE:
97 case CC:
98 case CHANCE:
99 case INC_TAX:
100 case GOTO_J:
101 case LUX_TAX:
102 case IN_JAIL:
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 } else
127 printf(" %4d", pp->rent[0]);
128 break;
129 case UTIL:
130 if (sqp->owner < 0) {
131 printf(" - 150");
132 if (!eoln)
133 printf(" ");
134 break;
135 }
136 printf(" %d 150", sqp->owner+1);
137 printmorg(sqp);
138 printf("%d", play[sqp->owner].num_util);
139 if (!eoln)
140 printf(" ");
141 break;
142 case RR:
143 if (sqp->owner < 0) {
144 printf(" - Railroad 200");
145 if (!eoln)
146 printf(" ");
147 break;
148 }
149 printf(" %d Railroad 200", sqp->owner+1);
150 printmorg(sqp);
151 rnt = 25;
152 rnt <<= play[sqp->owner].num_rr - 1;
153 printf("%d %4d", play[sqp->owner].num_rr,
154 25 << (play[sqp->owner].num_rr - 1));
155 break;
156 }
157 if (eoln)
158 putchar('\n');
159 }
160
161 /*
162 * This routine prints out the mortgage flag.
163 */
164 static void
165 printmorg(sqp)
166 const SQUARE *sqp;
167 {
168 if (sqp->desc->morg)
169 printf(" * ");
170 else
171 printf(" ");
172 }
173
174 /*
175 * This routine lists the holdings of the player given
176 */
177 void
178 printhold(pl)
179 int pl;
180 {
181 OWN *op;
182 PLAY *pp;
183
184 pp = &play[pl];
185 printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl],
186 pl + 1, pp->money + prop_worth(pp));
187 printf("\t$%d", pp->money);
188 if (pp->num_gojf) {
189 printf(", %d get-out-of-jail-free card", pp->num_gojf);
190 if (pp->num_gojf > 1)
191 putchar('s');
192 }
193 putchar('\n');
194 if (pp->own_list) {
195 printf("\t%s\n", header);
196 for (op = pp->own_list; op; op = op->next) {
197 putchar('\t');
198 printsq(sqnum(op->sqr), TRUE);
199 }
200 }
201 }