Commit | Line | Data |
---|---|---|
90753f46 | 1 | /* |
de010735 KB |
2 | * Copyright (c) 1982, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
82278f7a | 4 | * |
7c5ab767 | 5 | * %sccs.include.redist.c% |
90753f46 KB |
6 | */ |
7 | ||
8 | #ifndef lint | |
de010735 | 9 | static char sccsid[] = "@(#)print.c 8.1 (Berkeley) %G%"; |
82278f7a KB |
10 | #endif /* not lint */ |
11 | ||
90753f46 KB |
12 | # include "mille.h" |
13 | ||
14 | /* | |
15 | * @(#)print.c 1.1 (Berkeley) 4/1/82 | |
16 | */ | |
17 | ||
18 | # define COMP_STRT 20 | |
19 | # define CARD_STRT 2 | |
20 | ||
21 | prboard() { | |
22 | ||
23 | reg PLAY *pp; | |
24 | reg int i, j, k, temp; | |
25 | ||
26 | for (k = 0; k < 2; k++) { | |
27 | pp = &Player[k]; | |
28 | temp = k * COMP_STRT + CARD_STRT; | |
29 | for (i = 0; i < NUM_SAFE; i++) | |
30 | if (pp->safety[i] == S_PLAYED && !pp->sh_safety[i]) { | |
31 | mvaddstr(i, temp, C_name[i + S_CONV]); | |
32 | if (pp->coups[i]) | |
33 | mvaddch(i, temp - CARD_STRT, '*'); | |
34 | pp->sh_safety[i] = TRUE; | |
35 | } | |
36 | show_card(14, temp, pp->battle, &pp->sh_battle); | |
37 | show_card(16, temp, pp->speed, &pp->sh_speed); | |
38 | for (i = C_25; i <= C_200; i++) { | |
39 | reg char *name; | |
40 | reg int end; | |
41 | ||
42 | if (pp->nummiles[i] == pp->sh_nummiles[i]) | |
43 | continue; | |
44 | ||
45 | name = C_name[i]; | |
46 | temp = k * 40; | |
47 | end = pp->nummiles[i]; | |
48 | for (j = pp->sh_nummiles[i]; j < end; j++) | |
49 | mvwaddstr(Miles, i + 1, (j << 2) + temp, name); | |
50 | pp->sh_nummiles[i] = end; | |
51 | } | |
52 | } | |
53 | prscore(TRUE); | |
54 | temp = CARD_STRT; | |
55 | pp = &Player[PLAYER]; | |
56 | for (i = 0; i < HAND_SZ; i++) | |
57 | show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]); | |
58 | mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck); | |
59 | show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard); | |
60 | if (End == 1000) { | |
61 | move(EXT_Y, EXT_X); | |
62 | standout(); | |
63 | addstr("Extension"); | |
64 | standend(); | |
65 | } | |
66 | wrefresh(Board); | |
67 | wrefresh(Miles); | |
68 | wrefresh(Score); | |
69 | } | |
70 | ||
71 | /* | |
72 | * show_card: | |
73 | * Show the given card if it is different from the last one shown | |
74 | */ | |
75 | show_card(y, x, c, lc) | |
76 | int y, x; | |
77 | register CARD c, *lc; | |
78 | { | |
79 | if (c == *lc) | |
80 | return; | |
81 | ||
82 | mvprintw(y, x, C_fmt, C_name[c]); | |
83 | *lc = c; | |
84 | } | |
85 | ||
86 | static char Score_fmt[] = "%4d"; | |
87 | ||
88 | prscore(for_real) | |
89 | reg bool for_real; { | |
90 | ||
91 | reg PLAY *pp; | |
92 | reg int x; | |
93 | ||
94 | stdscr = Score; | |
95 | for (pp = Player; pp < &Player[2]; pp++) { | |
96 | x = (pp - Player) * 6 + 21; | |
97 | show_score(1, x, pp->mileage, &pp->sh_mileage); | |
98 | if (pp->safescore != pp->sh_safescore) { | |
99 | mvprintw(2, x, Score_fmt, pp->safescore); | |
100 | if (pp->safescore == 400) | |
101 | mvaddstr(3, x + 1, "300"); | |
102 | else | |
103 | mvaddstr(3, x + 1, " 0"); | |
104 | mvprintw(4, x, Score_fmt, pp->coupscore); | |
105 | pp->sh_safescore = pp->safescore; | |
106 | } | |
107 | if (Window == W_FULL || Finished) { | |
108 | #ifdef EXTRAP | |
109 | if (for_real) | |
110 | finalscore(pp); | |
111 | else | |
112 | extrapolate(pp); | |
113 | #else | |
114 | finalscore(pp); | |
115 | #endif | |
116 | show_score(11, x, pp->hand_tot, &pp->sh_hand_tot); | |
117 | show_score(13, x, pp->total, &pp->sh_total); | |
118 | show_score(14, x, pp->games, &pp->sh_games); | |
119 | } | |
120 | else { | |
121 | show_score(6, x, pp->hand_tot, &pp->sh_hand_tot); | |
122 | show_score(8, x, pp->total, &pp->sh_total); | |
123 | show_score(9, x, pp->games, &pp->sh_games); | |
124 | } | |
125 | } | |
126 | stdscr = Board; | |
127 | } | |
128 | ||
129 | /* | |
130 | * show_score: | |
131 | * Show a score value if it is different from the last time we | |
132 | * showed it. | |
133 | */ | |
134 | show_score(y, x, s, ls) | |
135 | int y, x; | |
136 | register int s, *ls; | |
137 | { | |
138 | if (s == *ls) | |
139 | return; | |
140 | ||
141 | mvprintw(y, x, Score_fmt, s); | |
142 | *ls = s; | |
143 | } |