133213Sbostic /* 233213Sbostic * Copyright (c) 1987 Regents of the University of California. 333213Sbostic * All rights reserved. 433213Sbostic * 533213Sbostic * Redistribution and use in source and binary forms are permitted 633213Sbostic * provided that this notice is preserved and that due credit is given 733213Sbostic * to the University of California at Berkeley. The name of the University 833213Sbostic * may not be used to endorse or promote products derived from this 933213Sbostic * software without specific prior written permission. This software 1033213Sbostic * is provided ``as is'' without express or implied warranty. 1133213Sbostic */ 1233213Sbostic 1333213Sbostic #ifndef lint 14*33216Sbostic static char sccsid[] = "@(#)print.c 5.2 (Berkeley) 01/02/88"; 1533213Sbostic #endif /* not lint */ 1633213Sbostic 1733213Sbostic # include "monop.ext" 1833213Sbostic 1933213Sbostic static char buf[80], /* output buffer */ 2033213Sbostic *header = "Name Own Price Mg # Rent"; 2133213Sbostic 2233213Sbostic /* 2333213Sbostic * This routine prints out the current board 2433213Sbostic */ 2533213Sbostic printboard() { 2633213Sbostic 2733213Sbostic reg int i; 2833213Sbostic 2933213Sbostic printf("%s\t%s\n", header, header); 3033213Sbostic for (i = 0; i < N_SQRS/2; i++) { 3133213Sbostic printsq(i, FALSE); 3233213Sbostic putchar('\t'); 3333213Sbostic printsq(i+N_SQRS/2, TRUE); 3433213Sbostic } 3533213Sbostic } 3633213Sbostic /* 3733213Sbostic * This routine lists where each player is. 3833213Sbostic */ 3933213Sbostic where() { 4033213Sbostic 4133213Sbostic reg int i; 4233213Sbostic char *bsp; 4333213Sbostic 4433213Sbostic printf("%s Player\n", header); 4533213Sbostic for (i = 0; i < num_play; i++) { 4633213Sbostic printsq(play[i].loc, FALSE); 4733213Sbostic printf(" %s (%d)", play[i].name, i+1); 4833213Sbostic if (cur_p == &play[i]) 4933213Sbostic printf(" *"); 5033213Sbostic putchar('\n'); 5133213Sbostic } 5233213Sbostic } 5333213Sbostic /* 5433213Sbostic * This routine prints out an individual square 5533213Sbostic */ 5633213Sbostic printsq(sqn, eoln) 5733213Sbostic int sqn; 5833213Sbostic reg bool eoln; { 5933213Sbostic 6033213Sbostic reg int rnt; 6133213Sbostic reg PROP *pp; 6233213Sbostic reg SQUARE *sqp; 6333213Sbostic int i; 6433213Sbostic 6533213Sbostic sqp = &board[sqn]; 6633213Sbostic printf("%-10.10s", sqp->name); 6733213Sbostic switch (sqp->type) { 6833213Sbostic case SAFE: 6933213Sbostic case CC: 7033213Sbostic case CHANCE: 71*33216Sbostic case INC_TAX: 72*33216Sbostic case GOTO_J: 73*33216Sbostic case LUX_TAX: 74*33216Sbostic case IN_JAIL: 7533213Sbostic spec: 7633213Sbostic if (!eoln) 7733213Sbostic printf(" "); 7833213Sbostic break; 7933213Sbostic case PRPTY: 8033213Sbostic pp = sqp->desc; 8133213Sbostic if (sqp->owner < 0) { 8233213Sbostic printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost); 8333213Sbostic if (!eoln) 8433213Sbostic printf(" "); 8533213Sbostic break; 8633213Sbostic } 8733213Sbostic printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name, 8833213Sbostic sqp->cost); 8933213Sbostic printmorg(sqp); 9033213Sbostic if (pp->monop) { 9133213Sbostic if (pp->houses < 5) 9233213Sbostic if (pp->houses > 0) 9333213Sbostic printf("%d %4d", pp->houses, 9433213Sbostic pp->rent[pp->houses]); 9533213Sbostic else 9633213Sbostic printf("0 %4d", pp->rent[0] * 2); 9733213Sbostic else 9833213Sbostic printf("H %4d", pp->rent[5]); 9933213Sbostic } 10033213Sbostic else 10133213Sbostic printf(" %4d", pp->rent[0]); 10233213Sbostic break; 10333213Sbostic case UTIL: 10433213Sbostic if (sqp->owner < 0) { 10533213Sbostic printf(" - 150"); 10633213Sbostic if (!eoln) 10733213Sbostic printf(" "); 10833213Sbostic break; 10933213Sbostic } 11033213Sbostic printf(" %d 150", sqp->owner+1); 11133213Sbostic printmorg(sqp); 11233213Sbostic printf("%d", play[sqp->owner].num_util); 11333213Sbostic if (!eoln) 11433213Sbostic printf(" "); 11533213Sbostic break; 11633213Sbostic case RR: 11733213Sbostic if (sqp->owner < 0) { 11833213Sbostic printf(" - Railroad 200"); 11933213Sbostic if (!eoln) 12033213Sbostic printf(" "); 12133213Sbostic break; 12233213Sbostic } 12333213Sbostic printf(" %d Railroad 200", sqp->owner+1); 12433213Sbostic printmorg(sqp); 12533213Sbostic rnt = 25; 12633213Sbostic rnt <<= play[sqp->owner].num_rr - 1; 12733213Sbostic printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1)); 12833213Sbostic break; 12933213Sbostic } 13033213Sbostic if (eoln) 13133213Sbostic putchar('\n'); 13233213Sbostic } 13333213Sbostic /* 13433213Sbostic * This routine prints out the mortgage flag. 13533213Sbostic */ 13633213Sbostic printmorg(sqp) 13733213Sbostic reg SQUARE *sqp; { 13833213Sbostic 13933213Sbostic if (sqp->desc->morg) 14033213Sbostic printf(" * "); 14133213Sbostic else 14233213Sbostic printf(" "); 14333213Sbostic } 14433213Sbostic /* 14533213Sbostic * This routine lists the holdings of the player given 14633213Sbostic */ 14733213Sbostic printhold(pl) 14833213Sbostic reg int pl; { 14933213Sbostic 15033213Sbostic reg OWN *op; 15133213Sbostic reg PLAY *pp; 15233213Sbostic char *bsp; 15333213Sbostic 15433213Sbostic pp = &play[pl]; 15533213Sbostic printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1, 15633213Sbostic pp->money + prop_worth(pp)); 15733213Sbostic printf("\t$%d", pp->money); 15833213Sbostic if (pp->num_gojf) { 15933213Sbostic printf(", %d get-out-of-jail-free card", pp->num_gojf); 16033213Sbostic if (pp->num_gojf > 1) 16133213Sbostic putchar('s'); 16233213Sbostic } 16333213Sbostic putchar('\n'); 16433213Sbostic if (pp->own_list) { 16533213Sbostic printf("\t%s\n", header); 16633213Sbostic for (op = pp->own_list; op; op = op->next) { 16733213Sbostic putchar('\t'); 16833213Sbostic printsq(sqnum(op->sqr), TRUE); 16933213Sbostic } 17033213Sbostic } 17133213Sbostic } 172