]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/print.c
Remove uses of __P.
[bsdgames-darwin.git] / monop / print.c
1 /* $NetBSD: print.c,v 1.8 2004/01/27 20:30:30 jsm 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.8 2004/01/27 20:30:30 jsm 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 }
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,
155 25 << (play[sqp->owner].num_rr - 1));
156 break;
157 }
158 if (eoln)
159 putchar('\n');
160 }
161
162 /*
163 * This routine prints out the mortgage flag.
164 */
165 static void
166 printmorg(sqp)
167 const SQUARE *sqp;
168 {
169 if (sqp->desc->morg)
170 printf(" * ");
171 else
172 printf(" ");
173 }
174
175 /*
176 * This routine lists the holdings of the player given
177 */
178 void
179 printhold(pl)
180 int pl;
181 {
182 OWN *op;
183 PLAY *pp;
184
185 pp = &play[pl];
186 printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl],
187 pl + 1, pp->money + prop_worth(pp));
188 printf("\t$%d", pp->money);
189 if (pp->num_gojf) {
190 printf(", %d get-out-of-jail-free card", pp->num_gojf);
191 if (pp->num_gojf > 1)
192 putchar('s');
193 }
194 putchar('\n');
195 if (pp->own_list) {
196 printf("\t%s\n", header);
197 for (op = pp->own_list; op; op = op->next) {
198 putchar('\t');
199 printsq(sqnum(op->sqr), TRUE);
200 }
201 }
202 }