1 /* $OpenBSD: print.c,v 1.5 2003/06/03 03:01:40 millert Exp $ */ 2 /* $NetBSD: print.c,v 1.3 1995/03/23 08:35:05 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1980, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 #ifndef lint 34 #if 0 35 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; 36 #else 37 static const char rcsid[] = "$OpenBSD: print.c,v 1.5 2003/06/03 03:01:40 millert Exp $"; 38 #endif 39 #endif /* not lint */ 40 41 #include "monop.ext" 42 43 static const char *header = "Name Own Price Mg # Rent"; 44 45 static void printmorg(SQUARE *); 46 47 /* 48 * This routine prints out the current board 49 */ 50 void 51 printboard() 52 { 53 int i; 54 55 printf("%s\t%s\n", header, header); 56 for (i = 0; i < N_SQRS/2; i++) { 57 printsq(i, FALSE); 58 putchar('\t'); 59 printsq(i+N_SQRS/2, TRUE); 60 } 61 } 62 /* 63 * This routine lists where each player is. 64 */ 65 void 66 where() 67 { 68 int i; 69 70 printf("%s Player\n", header); 71 for (i = 0; i < num_play; i++) { 72 printsq(play[i].loc, FALSE); 73 printf(" %s (%d)", play[i].name, i+1); 74 if (cur_p == &play[i]) 75 printf(" *"); 76 putchar('\n'); 77 } 78 } 79 /* 80 * This routine prints out an individual square 81 */ 82 void 83 printsq(sqn, eoln) 84 int sqn; 85 bool eoln; 86 { 87 int rnt; 88 PROP *pp; 89 SQUARE *sqp; 90 91 sqp = &board[sqn]; 92 printf("%-10.10s", sqp->name); 93 switch (sqp->type) { 94 case SAFE: 95 case CC: 96 case CHANCE: 97 case INC_TAX: 98 case GOTO_J: 99 case LUX_TAX: 100 case IN_JAIL: 101 if (!eoln) 102 printf(" "); 103 break; 104 case PRPTY: 105 pp = sqp->desc; 106 if (sqp->owner < 0) { 107 printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost); 108 if (!eoln) 109 printf(" "); 110 break; 111 } 112 printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name, 113 sqp->cost); 114 printmorg(sqp); 115 if (pp->monop) { 116 if (pp->houses < 5) { 117 if (pp->houses > 0) 118 printf("%d %4d", pp->houses, 119 pp->rent[(int)pp->houses]); 120 else 121 printf("0 %4d", pp->rent[0] * 2); 122 } else 123 printf("H %4d", pp->rent[5]); 124 } else 125 printf(" %4d", pp->rent[0]); 126 break; 127 case UTIL: 128 if (sqp->owner < 0) { 129 printf(" - 150"); 130 if (!eoln) 131 printf(" "); 132 break; 133 } 134 printf(" %d 150", sqp->owner+1); 135 printmorg(sqp); 136 printf("%d", play[(int)sqp->owner].num_util); 137 if (!eoln) 138 printf(" "); 139 break; 140 case RR: 141 if (sqp->owner < 0) { 142 printf(" - Railroad 200"); 143 if (!eoln) 144 printf(" "); 145 break; 146 } 147 printf(" %d Railroad 200", sqp->owner+1); 148 printmorg(sqp); 149 rnt = 25; 150 rnt <<= play[(int)sqp->owner].num_rr - 1; 151 printf("%d %4d", play[(int)sqp->owner].num_rr, 152 25 << (play[(int)sqp->owner].num_rr - 1)); 153 break; 154 default: 155 printf("Warning: printsq() switch %d\n", sqp->type); 156 break; 157 } 158 if (eoln) 159 putchar('\n'); 160 } 161 /* 162 * This routine prints out the mortgage flag. 163 */ 164 static void 165 printmorg(sqp) 166 SQUARE *sqp; 167 { 168 if (sqp->desc->morg) 169 printf(" * "); 170 else 171 printf(" "); 172 } 173 /* 174 * This routine lists the holdings of the player given 175 */ 176 void 177 printhold(pl) 178 int pl; 179 { 180 OWN *op; 181 PLAY *pp; 182 183 pp = &play[pl]; 184 printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1, 185 pp->money + prop_worth(pp)); 186 printf("\t$%d", pp->money); 187 if (pp->num_gojf) { 188 printf(", %d get-out-of-jail-free card", pp->num_gojf); 189 if (pp->num_gojf > 1) 190 putchar('s'); 191 } 192 putchar('\n'); 193 if (pp->own_list) { 194 printf("\t%s\n", header); 195 for (op = pp->own_list; op; op = op->next) { 196 putchar('\t'); 197 printsq(sqnum(op->sqr), TRUE); 198 } 199 } 200 } 201