xref: /csrg-svn/games/mille/print.c (revision 60812)
130205Sbostic /*
2*60812Sbostic  * Copyright (c) 1982, 1993
3*60812Sbostic  *	The Regents of the University of California.  All rights reserved.
433177Sbostic  *
542579Sbostic  * %sccs.include.redist.c%
630205Sbostic  */
730205Sbostic 
830205Sbostic #ifndef lint
9*60812Sbostic static char sccsid[] = "@(#)print.c	8.1 (Berkeley) 05/31/93";
1033177Sbostic #endif /* not lint */
1130205Sbostic 
1230205Sbostic # include	"mille.h"
1330205Sbostic 
1430205Sbostic /*
1530205Sbostic  * @(#)print.c	1.1 (Berkeley) 4/1/82
1630205Sbostic  */
1730205Sbostic 
1830205Sbostic # define	COMP_STRT	20
1930205Sbostic # define	CARD_STRT	2
2030205Sbostic 
prboard()2130205Sbostic prboard() {
2230205Sbostic 
2330205Sbostic 	reg PLAY	*pp;
2430205Sbostic 	reg int		i, j, k, temp;
2530205Sbostic 
2630205Sbostic 	for (k = 0; k < 2; k++) {
2730205Sbostic 		pp = &Player[k];
2830205Sbostic 		temp = k * COMP_STRT + CARD_STRT;
2930205Sbostic 		for (i = 0; i < NUM_SAFE; i++)
3030205Sbostic 			if (pp->safety[i] == S_PLAYED && !pp->sh_safety[i]) {
3130205Sbostic 				mvaddstr(i, temp, C_name[i + S_CONV]);
3230205Sbostic 				if (pp->coups[i])
3330205Sbostic 					mvaddch(i, temp - CARD_STRT, '*');
3430205Sbostic 				pp->sh_safety[i] = TRUE;
3530205Sbostic 			}
3630205Sbostic 		show_card(14, temp, pp->battle, &pp->sh_battle);
3730205Sbostic 		show_card(16, temp, pp->speed, &pp->sh_speed);
3830205Sbostic 		for (i = C_25; i <= C_200; i++) {
3930205Sbostic 			reg char	*name;
4030205Sbostic 			reg int		end;
4130205Sbostic 
4230205Sbostic 			if (pp->nummiles[i] == pp->sh_nummiles[i])
4330205Sbostic 				continue;
4430205Sbostic 
4530205Sbostic 			name = C_name[i];
4630205Sbostic 			temp = k * 40;
4730205Sbostic 			end = pp->nummiles[i];
4830205Sbostic 			for (j = pp->sh_nummiles[i]; j < end; j++)
4930205Sbostic 				mvwaddstr(Miles, i + 1, (j << 2) + temp, name);
5030205Sbostic 			pp->sh_nummiles[i] = end;
5130205Sbostic 		}
5230205Sbostic 	}
5330205Sbostic 	prscore(TRUE);
5430205Sbostic 	temp = CARD_STRT;
5530205Sbostic 	pp = &Player[PLAYER];
5630205Sbostic 	for (i = 0; i < HAND_SZ; i++)
5730205Sbostic 		show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]);
5830205Sbostic 	mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck);
5930205Sbostic 	show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard);
6030205Sbostic 	if (End == 1000) {
6130205Sbostic 		move(EXT_Y, EXT_X);
6230205Sbostic 		standout();
6330205Sbostic 		addstr("Extension");
6430205Sbostic 		standend();
6530205Sbostic 	}
6630205Sbostic 	wrefresh(Board);
6730205Sbostic 	wrefresh(Miles);
6830205Sbostic 	wrefresh(Score);
6930205Sbostic }
7030205Sbostic 
7130205Sbostic /*
7230205Sbostic  * show_card:
7330205Sbostic  *	Show the given card if it is different from the last one shown
7430205Sbostic  */
show_card(y,x,c,lc)7530205Sbostic show_card(y, x, c, lc)
7630205Sbostic int		y, x;
7730205Sbostic register CARD	c, *lc;
7830205Sbostic {
7930205Sbostic 	if (c == *lc)
8030205Sbostic 		return;
8130205Sbostic 
8230205Sbostic 	mvprintw(y, x, C_fmt, C_name[c]);
8330205Sbostic 	*lc = c;
8430205Sbostic }
8530205Sbostic 
8630205Sbostic static char	Score_fmt[] = "%4d";
8730205Sbostic 
prscore(for_real)8830205Sbostic prscore(for_real)
8930205Sbostic reg bool	for_real; {
9030205Sbostic 
9130205Sbostic 	reg PLAY	*pp;
9230205Sbostic 	reg int		x;
9330205Sbostic 
9430205Sbostic 	stdscr = Score;
9530205Sbostic 	for (pp = Player; pp < &Player[2]; pp++) {
9630205Sbostic 		x = (pp - Player) * 6 + 21;
9730205Sbostic 		show_score(1, x, pp->mileage, &pp->sh_mileage);
9830205Sbostic 		if (pp->safescore != pp->sh_safescore) {
9930205Sbostic 			mvprintw(2, x, Score_fmt, pp->safescore);
10030205Sbostic 			if (pp->safescore == 400)
10130205Sbostic 				mvaddstr(3, x + 1, "300");
10230205Sbostic 			else
10330205Sbostic 				mvaddstr(3, x + 1, "  0");
10430205Sbostic 			mvprintw(4, x, Score_fmt, pp->coupscore);
10530205Sbostic 			pp->sh_safescore = pp->safescore;
10630205Sbostic 		}
10730205Sbostic 		if (Window == W_FULL || Finished) {
10830205Sbostic #ifdef EXTRAP
10930205Sbostic 			if (for_real)
11030205Sbostic 				finalscore(pp);
11130205Sbostic 			else
11230205Sbostic 				extrapolate(pp);
11330205Sbostic #else
11430205Sbostic 			finalscore(pp);
11530205Sbostic #endif
11630205Sbostic 			show_score(11, x, pp->hand_tot, &pp->sh_hand_tot);
11730205Sbostic 			show_score(13, x, pp->total, &pp->sh_total);
11830205Sbostic 			show_score(14, x, pp->games, &pp->sh_games);
11930205Sbostic 		}
12030205Sbostic 		else {
12130205Sbostic 			show_score(6, x, pp->hand_tot, &pp->sh_hand_tot);
12230205Sbostic 			show_score(8, x, pp->total, &pp->sh_total);
12330205Sbostic 			show_score(9, x, pp->games, &pp->sh_games);
12430205Sbostic 		}
12530205Sbostic 	}
12630205Sbostic 	stdscr = Board;
12730205Sbostic }
12830205Sbostic 
12930205Sbostic /*
13030205Sbostic  * show_score:
13130205Sbostic  *	Show a score value if it is different from the last time we
13230205Sbostic  *	showed it.
13330205Sbostic  */
show_score(y,x,s,ls)13430205Sbostic show_score(y, x, s, ls)
13530205Sbostic int		y, x;
13630205Sbostic register int	s, *ls;
13730205Sbostic {
13830205Sbostic 	if (s == *ls)
13930205Sbostic 		return;
14030205Sbostic 
14130205Sbostic 	mvprintw(y, x, Score_fmt, s);
14230205Sbostic 	*ls = s;
14330205Sbostic }
144