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