xref: /csrg-svn/games/monop/print.c (revision 33213)
1*33213Sbostic /*
2*33213Sbostic  * Copyright (c) 1987 Regents of the University of California.
3*33213Sbostic  * All rights reserved.
4*33213Sbostic  *
5*33213Sbostic  * Redistribution and use in source and binary forms are permitted
6*33213Sbostic  * provided that this notice is preserved and that due credit is given
7*33213Sbostic  * to the University of California at Berkeley. The name of the University
8*33213Sbostic  * may not be used to endorse or promote products derived from this
9*33213Sbostic  * software without specific prior written permission. This software
10*33213Sbostic  * is provided ``as is'' without express or implied warranty.
11*33213Sbostic  */
12*33213Sbostic 
13*33213Sbostic #ifndef lint
14*33213Sbostic static char sccsid[] = "@(#)print.c	5.1 (Berkeley) 01/02/88";
15*33213Sbostic #endif /* not lint */
16*33213Sbostic 
17*33213Sbostic # include	"monop.ext"
18*33213Sbostic 
19*33213Sbostic static char	buf[80],		/* output buffer		*/
20*33213Sbostic 		*header	= "Name      Own      Price Mg # Rent";
21*33213Sbostic 
22*33213Sbostic /*
23*33213Sbostic  *	This routine prints out the current board
24*33213Sbostic  */
25*33213Sbostic printboard() {
26*33213Sbostic 
27*33213Sbostic 	reg int	i;
28*33213Sbostic 
29*33213Sbostic 	printf("%s\t%s\n", header, header);
30*33213Sbostic 	for (i = 0; i < N_SQRS/2; i++) {
31*33213Sbostic 		printsq(i, FALSE);
32*33213Sbostic 		putchar('\t');
33*33213Sbostic 		printsq(i+N_SQRS/2, TRUE);
34*33213Sbostic 	}
35*33213Sbostic }
36*33213Sbostic /*
37*33213Sbostic  *	This routine lists where each player is.
38*33213Sbostic  */
39*33213Sbostic where() {
40*33213Sbostic 
41*33213Sbostic 	reg int	i;
42*33213Sbostic 	char	*bsp;
43*33213Sbostic 
44*33213Sbostic 	printf("%s Player\n", header);
45*33213Sbostic 	for (i = 0; i < num_play; i++) {
46*33213Sbostic 		printsq(play[i].loc, FALSE);
47*33213Sbostic 		printf(" %s (%d)", play[i].name, i+1);
48*33213Sbostic 		if (cur_p == &play[i])
49*33213Sbostic 			printf(" *");
50*33213Sbostic 		putchar('\n');
51*33213Sbostic 	}
52*33213Sbostic }
53*33213Sbostic /*
54*33213Sbostic  *	This routine prints out an individual square
55*33213Sbostic  */
56*33213Sbostic printsq(sqn, eoln)
57*33213Sbostic int		sqn;
58*33213Sbostic reg bool	eoln; {
59*33213Sbostic 
60*33213Sbostic 	reg int		rnt;
61*33213Sbostic 	reg PROP	*pp;
62*33213Sbostic 	reg SQUARE	*sqp;
63*33213Sbostic 	int		i;
64*33213Sbostic 
65*33213Sbostic 	sqp = &board[sqn];
66*33213Sbostic 	printf("%-10.10s", sqp->name);
67*33213Sbostic 	if (sqn == JAIL)
68*33213Sbostic 		goto spec;
69*33213Sbostic 	switch (sqp->type) {
70*33213Sbostic 	  case SAFE:
71*33213Sbostic 	  case CC:
72*33213Sbostic 	  case CHANCE:
73*33213Sbostic 	  case SPEC:
74*33213Sbostic spec:
75*33213Sbostic 		if (!eoln)
76*33213Sbostic 			printf("                        ");
77*33213Sbostic 		break;
78*33213Sbostic 	  case PRPTY:
79*33213Sbostic 		pp = sqp->desc;
80*33213Sbostic 		if (sqp->owner < 0) {
81*33213Sbostic 			printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
82*33213Sbostic 			if (!eoln)
83*33213Sbostic 				printf("         ");
84*33213Sbostic 			break;
85*33213Sbostic 		}
86*33213Sbostic 		printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
87*33213Sbostic 			sqp->cost);
88*33213Sbostic 		printmorg(sqp);
89*33213Sbostic 		if (pp->monop) {
90*33213Sbostic 			if (pp->houses < 5)
91*33213Sbostic 				if (pp->houses > 0)
92*33213Sbostic 					printf("%d %4d", pp->houses,
93*33213Sbostic 						pp->rent[pp->houses]);
94*33213Sbostic 				else
95*33213Sbostic 					printf("0 %4d", pp->rent[0] * 2);
96*33213Sbostic 			else
97*33213Sbostic 				printf("H %4d", pp->rent[5]);
98*33213Sbostic 		}
99*33213Sbostic 		else
100*33213Sbostic 			printf("  %4d", pp->rent[0]);
101*33213Sbostic 		break;
102*33213Sbostic 	  case UTIL:
103*33213Sbostic 		if (sqp->owner < 0) {
104*33213Sbostic 			printf(" -          150");
105*33213Sbostic 			if (!eoln)
106*33213Sbostic 				printf("         ");
107*33213Sbostic 			break;
108*33213Sbostic 		}
109*33213Sbostic 		printf(" %d          150", sqp->owner+1);
110*33213Sbostic 		printmorg(sqp);
111*33213Sbostic 		printf("%d", play[sqp->owner].num_util);
112*33213Sbostic 		if (!eoln)
113*33213Sbostic 			printf("    ");
114*33213Sbostic 		break;
115*33213Sbostic 	  case RR:
116*33213Sbostic 		if (sqp->owner < 0) {
117*33213Sbostic 			printf(" - Railroad 200");
118*33213Sbostic 			if (!eoln)
119*33213Sbostic 				printf("         ");
120*33213Sbostic 			break;
121*33213Sbostic 		}
122*33213Sbostic 		printf(" %d Railroad 200", sqp->owner+1);
123*33213Sbostic 		printmorg(sqp);
124*33213Sbostic 		rnt = 25;
125*33213Sbostic 		rnt <<= play[sqp->owner].num_rr - 1;
126*33213Sbostic 		printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
127*33213Sbostic 		break;
128*33213Sbostic 	}
129*33213Sbostic 	if (eoln)
130*33213Sbostic 		putchar('\n');
131*33213Sbostic }
132*33213Sbostic /*
133*33213Sbostic  *	This routine prints out the mortgage flag.
134*33213Sbostic  */
135*33213Sbostic printmorg(sqp)
136*33213Sbostic reg SQUARE	*sqp; {
137*33213Sbostic 
138*33213Sbostic 	if (sqp->desc->morg)
139*33213Sbostic 		printf(" * ");
140*33213Sbostic 	else
141*33213Sbostic 		printf("   ");
142*33213Sbostic }
143*33213Sbostic /*
144*33213Sbostic  *	This routine lists the holdings of the player given
145*33213Sbostic  */
146*33213Sbostic printhold(pl)
147*33213Sbostic reg int	pl; {
148*33213Sbostic 
149*33213Sbostic 	reg OWN		*op;
150*33213Sbostic 	reg PLAY	*pp;
151*33213Sbostic 	char		*bsp;
152*33213Sbostic 
153*33213Sbostic 	pp = &play[pl];
154*33213Sbostic 	printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
155*33213Sbostic 		pp->money + prop_worth(pp));
156*33213Sbostic 	printf("\t$%d", pp->money);
157*33213Sbostic 	if (pp->num_gojf) {
158*33213Sbostic 		printf(", %d get-out-of-jail-free card", pp->num_gojf);
159*33213Sbostic 		if (pp->num_gojf > 1)
160*33213Sbostic 			putchar('s');
161*33213Sbostic 	}
162*33213Sbostic 	putchar('\n');
163*33213Sbostic 	if (pp->own_list) {
164*33213Sbostic 		printf("\t%s\n", header);
165*33213Sbostic 		for (op = pp->own_list; op; op = op->next) {
166*33213Sbostic 			putchar('\t');
167*33213Sbostic 			printsq(sqnum(op->sqr), TRUE);
168*33213Sbostic 		}
169*33213Sbostic 	}
170*33213Sbostic }
171