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