1 /* 2 * Copyright (c) 1982 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 the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)print.c 5.3 (Berkeley) 06/18/88"; 20 #endif /* not lint */ 21 22 # include "mille.h" 23 24 /* 25 * @(#)print.c 1.1 (Berkeley) 4/1/82 26 */ 27 28 # define COMP_STRT 20 29 # define CARD_STRT 2 30 31 prboard() { 32 33 reg PLAY *pp; 34 reg int i, j, k, temp; 35 36 for (k = 0; k < 2; k++) { 37 pp = &Player[k]; 38 temp = k * COMP_STRT + CARD_STRT; 39 for (i = 0; i < NUM_SAFE; i++) 40 if (pp->safety[i] == S_PLAYED && !pp->sh_safety[i]) { 41 mvaddstr(i, temp, C_name[i + S_CONV]); 42 if (pp->coups[i]) 43 mvaddch(i, temp - CARD_STRT, '*'); 44 pp->sh_safety[i] = TRUE; 45 } 46 show_card(14, temp, pp->battle, &pp->sh_battle); 47 show_card(16, temp, pp->speed, &pp->sh_speed); 48 for (i = C_25; i <= C_200; i++) { 49 reg char *name; 50 reg int end; 51 52 if (pp->nummiles[i] == pp->sh_nummiles[i]) 53 continue; 54 55 name = C_name[i]; 56 temp = k * 40; 57 end = pp->nummiles[i]; 58 for (j = pp->sh_nummiles[i]; j < end; j++) 59 mvwaddstr(Miles, i + 1, (j << 2) + temp, name); 60 pp->sh_nummiles[i] = end; 61 } 62 } 63 prscore(TRUE); 64 temp = CARD_STRT; 65 pp = &Player[PLAYER]; 66 for (i = 0; i < HAND_SZ; i++) 67 show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]); 68 mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck); 69 show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard); 70 if (End == 1000) { 71 move(EXT_Y, EXT_X); 72 standout(); 73 addstr("Extension"); 74 standend(); 75 } 76 wrefresh(Board); 77 wrefresh(Miles); 78 wrefresh(Score); 79 } 80 81 /* 82 * show_card: 83 * Show the given card if it is different from the last one shown 84 */ 85 show_card(y, x, c, lc) 86 int y, x; 87 register CARD c, *lc; 88 { 89 if (c == *lc) 90 return; 91 92 mvprintw(y, x, C_fmt, C_name[c]); 93 *lc = c; 94 } 95 96 static char Score_fmt[] = "%4d"; 97 98 prscore(for_real) 99 reg bool for_real; { 100 101 reg PLAY *pp; 102 reg int x; 103 104 stdscr = Score; 105 for (pp = Player; pp < &Player[2]; pp++) { 106 x = (pp - Player) * 6 + 21; 107 show_score(1, x, pp->mileage, &pp->sh_mileage); 108 if (pp->safescore != pp->sh_safescore) { 109 mvprintw(2, x, Score_fmt, pp->safescore); 110 if (pp->safescore == 400) 111 mvaddstr(3, x + 1, "300"); 112 else 113 mvaddstr(3, x + 1, " 0"); 114 mvprintw(4, x, Score_fmt, pp->coupscore); 115 pp->sh_safescore = pp->safescore; 116 } 117 if (Window == W_FULL || Finished) { 118 #ifdef EXTRAP 119 if (for_real) 120 finalscore(pp); 121 else 122 extrapolate(pp); 123 #else 124 finalscore(pp); 125 #endif 126 show_score(11, x, pp->hand_tot, &pp->sh_hand_tot); 127 show_score(13, x, pp->total, &pp->sh_total); 128 show_score(14, x, pp->games, &pp->sh_games); 129 } 130 else { 131 show_score(6, x, pp->hand_tot, &pp->sh_hand_tot); 132 show_score(8, x, pp->total, &pp->sh_total); 133 show_score(9, x, pp->games, &pp->sh_games); 134 } 135 } 136 stdscr = Board; 137 } 138 139 /* 140 * show_score: 141 * Show a score value if it is different from the last time we 142 * showed it. 143 */ 144 show_score(y, x, s, ls) 145 int y, x; 146 register int s, *ls; 147 { 148 if (s == *ls) 149 return; 150 151 mvprintw(y, x, Score_fmt, s); 152 *ls = s; 153 } 154