]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/print.c
Merge with v20030416.
[bsdgames-darwin.git] / monop / print.c
1 /* $NetBSD: print.c,v 1.6 1999/09/08 21:17:52 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. 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 #include <sys/cdefs.h>
37 #ifndef lint
38 #if 0
39 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93";
40 #else
41 __RCSID("$NetBSD: print.c,v 1.6 1999/09/08 21:17:52 jsm Exp $");
42 #endif
43 #endif /* not lint */
44
45 #include "monop.ext"
46
47 static const char *header = "Name Own Price Mg # Rent";
48
49 static void printmorg __P((const SQUARE *));
50
51 /*
52 * This routine prints out the current board
53 */
54 void
55 printboard()
56 {
57 int i;
58
59 printf("%s\t%s\n", header, header);
60 for (i = 0; i < N_SQRS/2; i++) {
61 printsq(i, FALSE);
62 putchar('\t');
63 printsq(i+N_SQRS/2, TRUE);
64 }
65 }
66
67 /*
68 * This routine lists where each player is.
69 */
70 void
71 where()
72 {
73 int i;
74
75 printf("%s Player\n", header);
76 for (i = 0; i < num_play; i++) {
77 printsq(play[i].loc, FALSE);
78 printf(" %s (%d)", play[i].name, i+1);
79 if (cur_p == &play[i])
80 printf(" *");
81 putchar('\n');
82 }
83 }
84
85 /*
86 * This routine prints out an individual square
87 */
88 void
89 printsq(sqn, eoln)
90 int sqn;
91 bool eoln;
92 {
93 int rnt;
94 PROP *pp;
95 SQUARE *sqp;
96
97 sqp = &board[sqn];
98 printf("%-10.10s", sqp->name);
99 switch (sqp->type) {
100 case SAFE:
101 case CC:
102 case CHANCE:
103 case INC_TAX:
104 case GOTO_J:
105 case LUX_TAX:
106 case IN_JAIL:
107 if (!eoln)
108 printf(" ");
109 break;
110 case PRPTY:
111 pp = sqp->desc;
112 if (sqp->owner < 0) {
113 printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
114 if (!eoln)
115 printf(" ");
116 break;
117 }
118 printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
119 sqp->cost);
120 printmorg(sqp);
121 if (pp->monop) {
122 if (pp->houses < 5)
123 if (pp->houses > 0)
124 printf("%d %4d", pp->houses,
125 pp->rent[pp->houses]);
126 else
127 printf("0 %4d", pp->rent[0] * 2);
128 else
129 printf("H %4d", pp->rent[5]);
130 }
131 else
132 printf(" %4d", pp->rent[0]);
133 break;
134 case UTIL:
135 if (sqp->owner < 0) {
136 printf(" - 150");
137 if (!eoln)
138 printf(" ");
139 break;
140 }
141 printf(" %d 150", sqp->owner+1);
142 printmorg(sqp);
143 printf("%d", play[sqp->owner].num_util);
144 if (!eoln)
145 printf(" ");
146 break;
147 case RR:
148 if (sqp->owner < 0) {
149 printf(" - Railroad 200");
150 if (!eoln)
151 printf(" ");
152 break;
153 }
154 printf(" %d Railroad 200", sqp->owner+1);
155 printmorg(sqp);
156 rnt = 25;
157 rnt <<= play[sqp->owner].num_rr - 1;
158 printf("%d %4d", play[sqp->owner].num_rr,
159 25 << (play[sqp->owner].num_rr - 1));
160 break;
161 }
162 if (eoln)
163 putchar('\n');
164 }
165
166 /*
167 * This routine prints out the mortgage flag.
168 */
169 static void
170 printmorg(sqp)
171 const SQUARE *sqp;
172 {
173 if (sqp->desc->morg)
174 printf(" * ");
175 else
176 printf(" ");
177 }
178
179 /*
180 * This routine lists the holdings of the player given
181 */
182 void
183 printhold(pl)
184 int pl;
185 {
186 OWN *op;
187 PLAY *pp;
188
189 pp = &play[pl];
190 printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl],
191 pl + 1, pp->money + prop_worth(pp));
192 printf("\t$%d", pp->money);
193 if (pp->num_gojf) {
194 printf(", %d get-out-of-jail-free card", pp->num_gojf);
195 if (pp->num_gojf > 1)
196 putchar('s');
197 }
198 putchar('\n');
199 if (pp->own_list) {
200 printf("\t%s\n", header);
201 for (op = pp->own_list; op; op = op->next) {
202 putchar('\t');
203 printsq(sqnum(op->sqr), TRUE);
204 }
205 }
206 }