|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)print.c 5.4 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: # include "monop.ext" ! 25: ! 26: static char buf[80], /* output buffer */ ! 27: *header = "Name Own Price Mg # Rent"; ! 28: ! 29: /* ! 30: * This routine prints out the current board ! 31: */ ! 32: printboard() { ! 33: ! 34: reg int i; ! 35: ! 36: printf("%s\t%s\n", header, header); ! 37: for (i = 0; i < N_SQRS/2; i++) { ! 38: printsq(i, FALSE); ! 39: putchar('\t'); ! 40: printsq(i+N_SQRS/2, TRUE); ! 41: } ! 42: } ! 43: /* ! 44: * This routine lists where each player is. ! 45: */ ! 46: where() { ! 47: ! 48: reg int i; ! 49: char *bsp; ! 50: ! 51: printf("%s Player\n", header); ! 52: for (i = 0; i < num_play; i++) { ! 53: printsq(play[i].loc, FALSE); ! 54: printf(" %s (%d)", play[i].name, i+1); ! 55: if (cur_p == &play[i]) ! 56: printf(" *"); ! 57: putchar('\n'); ! 58: } ! 59: } ! 60: /* ! 61: * This routine prints out an individual square ! 62: */ ! 63: printsq(sqn, eoln) ! 64: int sqn; ! 65: reg bool eoln; { ! 66: ! 67: reg int rnt; ! 68: reg PROP *pp; ! 69: reg SQUARE *sqp; ! 70: int i; ! 71: ! 72: sqp = &board[sqn]; ! 73: printf("%-10.10s", sqp->name); ! 74: switch (sqp->type) { ! 75: case SAFE: ! 76: case CC: ! 77: case CHANCE: ! 78: case INC_TAX: ! 79: case GOTO_J: ! 80: case LUX_TAX: ! 81: case IN_JAIL: ! 82: spec: ! 83: if (!eoln) ! 84: printf(" "); ! 85: break; ! 86: case PRPTY: ! 87: pp = sqp->desc; ! 88: if (sqp->owner < 0) { ! 89: printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost); ! 90: if (!eoln) ! 91: printf(" "); ! 92: break; ! 93: } ! 94: printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name, ! 95: sqp->cost); ! 96: printmorg(sqp); ! 97: if (pp->monop) { ! 98: if (pp->houses < 5) ! 99: if (pp->houses > 0) ! 100: printf("%d %4d", pp->houses, ! 101: pp->rent[pp->houses]); ! 102: else ! 103: printf("0 %4d", pp->rent[0] * 2); ! 104: else ! 105: printf("H %4d", pp->rent[5]); ! 106: } ! 107: else ! 108: printf(" %4d", pp->rent[0]); ! 109: break; ! 110: case UTIL: ! 111: if (sqp->owner < 0) { ! 112: printf(" - 150"); ! 113: if (!eoln) ! 114: printf(" "); ! 115: break; ! 116: } ! 117: printf(" %d 150", sqp->owner+1); ! 118: printmorg(sqp); ! 119: printf("%d", play[sqp->owner].num_util); ! 120: if (!eoln) ! 121: printf(" "); ! 122: break; ! 123: case RR: ! 124: if (sqp->owner < 0) { ! 125: printf(" - Railroad 200"); ! 126: if (!eoln) ! 127: printf(" "); ! 128: break; ! 129: } ! 130: printf(" %d Railroad 200", sqp->owner+1); ! 131: printmorg(sqp); ! 132: rnt = 25; ! 133: rnt <<= play[sqp->owner].num_rr - 1; ! 134: printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1)); ! 135: break; ! 136: } ! 137: if (eoln) ! 138: putchar('\n'); ! 139: } ! 140: /* ! 141: * This routine prints out the mortgage flag. ! 142: */ ! 143: printmorg(sqp) ! 144: reg SQUARE *sqp; { ! 145: ! 146: if (sqp->desc->morg) ! 147: printf(" * "); ! 148: else ! 149: printf(" "); ! 150: } ! 151: /* ! 152: * This routine lists the holdings of the player given ! 153: */ ! 154: printhold(pl) ! 155: reg int pl; { ! 156: ! 157: reg OWN *op; ! 158: reg PLAY *pp; ! 159: char *bsp; ! 160: ! 161: pp = &play[pl]; ! 162: printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1, ! 163: pp->money + prop_worth(pp)); ! 164: printf("\t$%d", pp->money); ! 165: if (pp->num_gojf) { ! 166: printf(", %d get-out-of-jail-free card", pp->num_gojf); ! 167: if (pp->num_gojf > 1) ! 168: putchar('s'); ! 169: } ! 170: putchar('\n'); ! 171: if (pp->own_list) { ! 172: printf("\t%s\n", header); ! 173: for (op = pp->own_list; op; op = op->next) { ! 174: putchar('\t'); ! 175: printsq(sqnum(op->sqr), TRUE); ! 176: } ! 177: } ! 178: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.