xref: /csrg-svn/games/monop/print.c (revision 60815)
133213Sbostic /*
2*60815Sbostic  * Copyright (c) 1980, 1993
3*60815Sbostic  *	The Regents of the University of California.  All rights reserved.
433213Sbostic  *
542583Sbostic  * %sccs.include.redist.c%
633213Sbostic  */
733213Sbostic 
833213Sbostic #ifndef lint
9*60815Sbostic static char sccsid[] = "@(#)print.c	8.1 (Berkeley) 05/31/93";
1033213Sbostic #endif /* not lint */
1133213Sbostic 
1233213Sbostic # include	"monop.ext"
1333213Sbostic 
1433213Sbostic static char	buf[80],		/* output buffer		*/
1533213Sbostic 		*header	= "Name      Own      Price Mg # Rent";
1633213Sbostic 
1733213Sbostic /*
1833213Sbostic  *	This routine prints out the current board
1933213Sbostic  */
printboard()2033213Sbostic printboard() {
2133213Sbostic 
2233213Sbostic 	reg int	i;
2333213Sbostic 
2433213Sbostic 	printf("%s\t%s\n", header, header);
2533213Sbostic 	for (i = 0; i < N_SQRS/2; i++) {
2633213Sbostic 		printsq(i, FALSE);
2733213Sbostic 		putchar('\t');
2833213Sbostic 		printsq(i+N_SQRS/2, TRUE);
2933213Sbostic 	}
3033213Sbostic }
3133213Sbostic /*
3233213Sbostic  *	This routine lists where each player is.
3333213Sbostic  */
where()3433213Sbostic where() {
3533213Sbostic 
3633213Sbostic 	reg int	i;
3733213Sbostic 	char	*bsp;
3833213Sbostic 
3933213Sbostic 	printf("%s Player\n", header);
4033213Sbostic 	for (i = 0; i < num_play; i++) {
4133213Sbostic 		printsq(play[i].loc, FALSE);
4233213Sbostic 		printf(" %s (%d)", play[i].name, i+1);
4333213Sbostic 		if (cur_p == &play[i])
4433213Sbostic 			printf(" *");
4533213Sbostic 		putchar('\n');
4633213Sbostic 	}
4733213Sbostic }
4833213Sbostic /*
4933213Sbostic  *	This routine prints out an individual square
5033213Sbostic  */
printsq(sqn,eoln)5133213Sbostic printsq(sqn, eoln)
5233213Sbostic int		sqn;
5333213Sbostic reg bool	eoln; {
5433213Sbostic 
5533213Sbostic 	reg int		rnt;
5633213Sbostic 	reg PROP	*pp;
5733213Sbostic 	reg SQUARE	*sqp;
5833213Sbostic 	int		i;
5933213Sbostic 
6033213Sbostic 	sqp = &board[sqn];
6133213Sbostic 	printf("%-10.10s", sqp->name);
6233213Sbostic 	switch (sqp->type) {
6333213Sbostic 	  case SAFE:
6433213Sbostic 	  case CC:
6533213Sbostic 	  case CHANCE:
6633216Sbostic 	  case INC_TAX:
6733216Sbostic 	  case GOTO_J:
6833216Sbostic 	  case LUX_TAX:
6933216Sbostic 	  case IN_JAIL:
7033213Sbostic spec:
7133213Sbostic 		if (!eoln)
7233213Sbostic 			printf("                        ");
7333213Sbostic 		break;
7433213Sbostic 	  case PRPTY:
7533213Sbostic 		pp = sqp->desc;
7633213Sbostic 		if (sqp->owner < 0) {
7733213Sbostic 			printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost);
7833213Sbostic 			if (!eoln)
7933213Sbostic 				printf("         ");
8033213Sbostic 			break;
8133213Sbostic 		}
8233213Sbostic 		printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name,
8333213Sbostic 			sqp->cost);
8433213Sbostic 		printmorg(sqp);
8533213Sbostic 		if (pp->monop) {
8633213Sbostic 			if (pp->houses < 5)
8733213Sbostic 				if (pp->houses > 0)
8833213Sbostic 					printf("%d %4d", pp->houses,
8933213Sbostic 						pp->rent[pp->houses]);
9033213Sbostic 				else
9133213Sbostic 					printf("0 %4d", pp->rent[0] * 2);
9233213Sbostic 			else
9333213Sbostic 				printf("H %4d", pp->rent[5]);
9433213Sbostic 		}
9533213Sbostic 		else
9633213Sbostic 			printf("  %4d", pp->rent[0]);
9733213Sbostic 		break;
9833213Sbostic 	  case UTIL:
9933213Sbostic 		if (sqp->owner < 0) {
10033213Sbostic 			printf(" -          150");
10133213Sbostic 			if (!eoln)
10233213Sbostic 				printf("         ");
10333213Sbostic 			break;
10433213Sbostic 		}
10533213Sbostic 		printf(" %d          150", sqp->owner+1);
10633213Sbostic 		printmorg(sqp);
10733213Sbostic 		printf("%d", play[sqp->owner].num_util);
10833213Sbostic 		if (!eoln)
10933213Sbostic 			printf("    ");
11033213Sbostic 		break;
11133213Sbostic 	  case RR:
11233213Sbostic 		if (sqp->owner < 0) {
11333213Sbostic 			printf(" - Railroad 200");
11433213Sbostic 			if (!eoln)
11533213Sbostic 				printf("         ");
11633213Sbostic 			break;
11733213Sbostic 		}
11833213Sbostic 		printf(" %d Railroad 200", sqp->owner+1);
11933213Sbostic 		printmorg(sqp);
12033213Sbostic 		rnt = 25;
12133213Sbostic 		rnt <<= play[sqp->owner].num_rr - 1;
12233213Sbostic 		printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
12333213Sbostic 		break;
12433213Sbostic 	}
12533213Sbostic 	if (eoln)
12633213Sbostic 		putchar('\n');
12733213Sbostic }
12833213Sbostic /*
12933213Sbostic  *	This routine prints out the mortgage flag.
13033213Sbostic  */
printmorg(sqp)13133213Sbostic printmorg(sqp)
13233213Sbostic reg SQUARE	*sqp; {
13333213Sbostic 
13433213Sbostic 	if (sqp->desc->morg)
13533213Sbostic 		printf(" * ");
13633213Sbostic 	else
13733213Sbostic 		printf("   ");
13833213Sbostic }
13933213Sbostic /*
14033213Sbostic  *	This routine lists the holdings of the player given
14133213Sbostic  */
printhold(pl)14233213Sbostic printhold(pl)
14333213Sbostic reg int	pl; {
14433213Sbostic 
14533213Sbostic 	reg OWN		*op;
14633213Sbostic 	reg PLAY	*pp;
14733213Sbostic 	char		*bsp;
14833213Sbostic 
14933213Sbostic 	pp = &play[pl];
15033213Sbostic 	printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
15133213Sbostic 		pp->money + prop_worth(pp));
15233213Sbostic 	printf("\t$%d", pp->money);
15333213Sbostic 	if (pp->num_gojf) {
15433213Sbostic 		printf(", %d get-out-of-jail-free card", pp->num_gojf);
15533213Sbostic 		if (pp->num_gojf > 1)
15633213Sbostic 			putchar('s');
15733213Sbostic 	}
15833213Sbostic 	putchar('\n');
15933213Sbostic 	if (pp->own_list) {
16033213Sbostic 		printf("\t%s\n", header);
16133213Sbostic 		for (op = pp->own_list; op; op = op->next) {
16233213Sbostic 			putchar('\t');
16333213Sbostic 			printsq(sqnum(op->sqr), TRUE);
16433213Sbostic 		}
16533213Sbostic 	}
16633213Sbostic }
167