xref: /csrg-svn/games/monop/print.c (revision 34788)
133213Sbostic /*
2*34788Sbostic  * Copyright (c) 1980 Regents of the University of California.
333213Sbostic  * All rights reserved.
433213Sbostic  *
533213Sbostic  * Redistribution and use in source and binary forms are permitted
6*34788Sbostic  * provided that the above copyright notice and this paragraph are
7*34788Sbostic  * duplicated in all such forms and that any documentation,
8*34788Sbostic  * advertising materials, and other materials related to such
9*34788Sbostic  * distribution and use acknowledge that the software was developed
10*34788Sbostic  * by the University of California, Berkeley.  The name of the
11*34788Sbostic  * University may not be used to endorse or promote products derived
12*34788Sbostic  * from this software without specific prior written permission.
13*34788Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34788Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34788Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633213Sbostic  */
1733213Sbostic 
1833213Sbostic #ifndef lint
19*34788Sbostic static char sccsid[] = "@(#)print.c	5.3 (Berkeley) 06/18/88";
2033213Sbostic #endif /* not lint */
2133213Sbostic 
2233213Sbostic # include	"monop.ext"
2333213Sbostic 
2433213Sbostic static char	buf[80],		/* output buffer		*/
2533213Sbostic 		*header	= "Name      Own      Price Mg # Rent";
2633213Sbostic 
2733213Sbostic /*
2833213Sbostic  *	This routine prints out the current board
2933213Sbostic  */
3033213Sbostic printboard() {
3133213Sbostic 
3233213Sbostic 	reg int	i;
3333213Sbostic 
3433213Sbostic 	printf("%s\t%s\n", header, header);
3533213Sbostic 	for (i = 0; i < N_SQRS/2; i++) {
3633213Sbostic 		printsq(i, FALSE);
3733213Sbostic 		putchar('\t');
3833213Sbostic 		printsq(i+N_SQRS/2, TRUE);
3933213Sbostic 	}
4033213Sbostic }
4133213Sbostic /*
4233213Sbostic  *	This routine lists where each player is.
4333213Sbostic  */
4433213Sbostic where() {
4533213Sbostic 
4633213Sbostic 	reg int	i;
4733213Sbostic 	char	*bsp;
4833213Sbostic 
4933213Sbostic 	printf("%s Player\n", header);
5033213Sbostic 	for (i = 0; i < num_play; i++) {
5133213Sbostic 		printsq(play[i].loc, FALSE);
5233213Sbostic 		printf(" %s (%d)", play[i].name, i+1);
5333213Sbostic 		if (cur_p == &play[i])
5433213Sbostic 			printf(" *");
5533213Sbostic 		putchar('\n');
5633213Sbostic 	}
5733213Sbostic }
5833213Sbostic /*
5933213Sbostic  *	This routine prints out an individual square
6033213Sbostic  */
6133213Sbostic printsq(sqn, eoln)
6233213Sbostic int		sqn;
6333213Sbostic reg bool	eoln; {
6433213Sbostic 
6533213Sbostic 	reg int		rnt;
6633213Sbostic 	reg PROP	*pp;
6733213Sbostic 	reg SQUARE	*sqp;
6833213Sbostic 	int		i;
6933213Sbostic 
7033213Sbostic 	sqp = &board[sqn];
7133213Sbostic 	printf("%-10.10s", sqp->name);
7233213Sbostic 	switch (sqp->type) {
7333213Sbostic 	  case SAFE:
7433213Sbostic 	  case CC:
7533213Sbostic 	  case CHANCE:
7633216Sbostic 	  case INC_TAX:
7733216Sbostic 	  case GOTO_J:
7833216Sbostic 	  case LUX_TAX:
7933216Sbostic 	  case IN_JAIL:
8033213Sbostic spec:
8133213Sbostic 		if (!eoln)
8233213Sbostic 			printf("                        ");
8333213Sbostic 		break;
8433213Sbostic 	  case PRPTY:
8533213Sbostic 		pp = sqp->desc;
8633213Sbostic 		if (sqp->owner < 0) {
8733213Sbostic 			printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
8833213Sbostic 			if (!eoln)
8933213Sbostic 				printf("         ");
9033213Sbostic 			break;
9133213Sbostic 		}
9233213Sbostic 		printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
9333213Sbostic 			sqp->cost);
9433213Sbostic 		printmorg(sqp);
9533213Sbostic 		if (pp->monop) {
9633213Sbostic 			if (pp->houses < 5)
9733213Sbostic 				if (pp->houses > 0)
9833213Sbostic 					printf("%d %4d", pp->houses,
9933213Sbostic 						pp->rent[pp->houses]);
10033213Sbostic 				else
10133213Sbostic 					printf("0 %4d", pp->rent[0] * 2);
10233213Sbostic 			else
10333213Sbostic 				printf("H %4d", pp->rent[5]);
10433213Sbostic 		}
10533213Sbostic 		else
10633213Sbostic 			printf("  %4d", pp->rent[0]);
10733213Sbostic 		break;
10833213Sbostic 	  case UTIL:
10933213Sbostic 		if (sqp->owner < 0) {
11033213Sbostic 			printf(" -          150");
11133213Sbostic 			if (!eoln)
11233213Sbostic 				printf("         ");
11333213Sbostic 			break;
11433213Sbostic 		}
11533213Sbostic 		printf(" %d          150", sqp->owner+1);
11633213Sbostic 		printmorg(sqp);
11733213Sbostic 		printf("%d", play[sqp->owner].num_util);
11833213Sbostic 		if (!eoln)
11933213Sbostic 			printf("    ");
12033213Sbostic 		break;
12133213Sbostic 	  case RR:
12233213Sbostic 		if (sqp->owner < 0) {
12333213Sbostic 			printf(" - Railroad 200");
12433213Sbostic 			if (!eoln)
12533213Sbostic 				printf("         ");
12633213Sbostic 			break;
12733213Sbostic 		}
12833213Sbostic 		printf(" %d Railroad 200", sqp->owner+1);
12933213Sbostic 		printmorg(sqp);
13033213Sbostic 		rnt = 25;
13133213Sbostic 		rnt <<= play[sqp->owner].num_rr - 1;
13233213Sbostic 		printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
13333213Sbostic 		break;
13433213Sbostic 	}
13533213Sbostic 	if (eoln)
13633213Sbostic 		putchar('\n');
13733213Sbostic }
13833213Sbostic /*
13933213Sbostic  *	This routine prints out the mortgage flag.
14033213Sbostic  */
14133213Sbostic printmorg(sqp)
14233213Sbostic reg SQUARE	*sqp; {
14333213Sbostic 
14433213Sbostic 	if (sqp->desc->morg)
14533213Sbostic 		printf(" * ");
14633213Sbostic 	else
14733213Sbostic 		printf("   ");
14833213Sbostic }
14933213Sbostic /*
15033213Sbostic  *	This routine lists the holdings of the player given
15133213Sbostic  */
15233213Sbostic printhold(pl)
15333213Sbostic reg int	pl; {
15433213Sbostic 
15533213Sbostic 	reg OWN		*op;
15633213Sbostic 	reg PLAY	*pp;
15733213Sbostic 	char		*bsp;
15833213Sbostic 
15933213Sbostic 	pp = &play[pl];
16033213Sbostic 	printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
16133213Sbostic 		pp->money + prop_worth(pp));
16233213Sbostic 	printf("\t$%d", pp->money);
16333213Sbostic 	if (pp->num_gojf) {
16433213Sbostic 		printf(", %d get-out-of-jail-free card", pp->num_gojf);
16533213Sbostic 		if (pp->num_gojf > 1)
16633213Sbostic 			putchar('s');
16733213Sbostic 	}
16833213Sbostic 	putchar('\n');
16933213Sbostic 	if (pp->own_list) {
17033213Sbostic 		printf("\t%s\n", header);
17133213Sbostic 		for (op = pp->own_list; op; op = op->next) {
17233213Sbostic 			putchar('\t');
17333213Sbostic 			printsq(sqnum(op->sqr), TRUE);
17433213Sbostic 		}
17533213Sbostic 	}
17633213Sbostic }
177