Home | History | Annotate | Line # | Download | only in mille
print.c revision 1.1
      1  1.1  cgd /*
      2  1.1  cgd  * Copyright (c) 1982 Regents of the University of California.
      3  1.1  cgd  * All rights reserved.
      4  1.1  cgd  *
      5  1.1  cgd  * Redistribution and use in source and binary forms, with or without
      6  1.1  cgd  * modification, are permitted provided that the following conditions
      7  1.1  cgd  * are met:
      8  1.1  cgd  * 1. Redistributions of source code must retain the above copyright
      9  1.1  cgd  *    notice, this list of conditions and the following disclaimer.
     10  1.1  cgd  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  cgd  *    notice, this list of conditions and the following disclaimer in the
     12  1.1  cgd  *    documentation and/or other materials provided with the distribution.
     13  1.1  cgd  * 3. All advertising materials mentioning features or use of this software
     14  1.1  cgd  *    must display the following acknowledgement:
     15  1.1  cgd  *	This product includes software developed by the University of
     16  1.1  cgd  *	California, Berkeley and its contributors.
     17  1.1  cgd  * 4. Neither the name of the University nor the names of its contributors
     18  1.1  cgd  *    may be used to endorse or promote products derived from this software
     19  1.1  cgd  *    without specific prior written permission.
     20  1.1  cgd  *
     21  1.1  cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  1.1  cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.1  cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.1  cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  1.1  cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  1.1  cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  1.1  cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  1.1  cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  1.1  cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  1.1  cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  1.1  cgd  * SUCH DAMAGE.
     32  1.1  cgd  */
     33  1.1  cgd 
     34  1.1  cgd #ifndef lint
     35  1.1  cgd static char sccsid[] = "@(#)print.c	5.4 (Berkeley) 6/1/90";
     36  1.1  cgd #endif /* not lint */
     37  1.1  cgd 
     38  1.1  cgd # include	"mille.h"
     39  1.1  cgd 
     40  1.1  cgd /*
     41  1.1  cgd  * @(#)print.c	1.1 (Berkeley) 4/1/82
     42  1.1  cgd  */
     43  1.1  cgd 
     44  1.1  cgd # define	COMP_STRT	20
     45  1.1  cgd # define	CARD_STRT	2
     46  1.1  cgd 
     47  1.1  cgd prboard() {
     48  1.1  cgd 
     49  1.1  cgd 	reg PLAY	*pp;
     50  1.1  cgd 	reg int		i, j, k, temp;
     51  1.1  cgd 
     52  1.1  cgd 	for (k = 0; k < 2; k++) {
     53  1.1  cgd 		pp = &Player[k];
     54  1.1  cgd 		temp = k * COMP_STRT + CARD_STRT;
     55  1.1  cgd 		for (i = 0; i < NUM_SAFE; i++)
     56  1.1  cgd 			if (pp->safety[i] == S_PLAYED && !pp->sh_safety[i]) {
     57  1.1  cgd 				mvaddstr(i, temp, C_name[i + S_CONV]);
     58  1.1  cgd 				if (pp->coups[i])
     59  1.1  cgd 					mvaddch(i, temp - CARD_STRT, '*');
     60  1.1  cgd 				pp->sh_safety[i] = TRUE;
     61  1.1  cgd 			}
     62  1.1  cgd 		show_card(14, temp, pp->battle, &pp->sh_battle);
     63  1.1  cgd 		show_card(16, temp, pp->speed, &pp->sh_speed);
     64  1.1  cgd 		for (i = C_25; i <= C_200; i++) {
     65  1.1  cgd 			reg char	*name;
     66  1.1  cgd 			reg int		end;
     67  1.1  cgd 
     68  1.1  cgd 			if (pp->nummiles[i] == pp->sh_nummiles[i])
     69  1.1  cgd 				continue;
     70  1.1  cgd 
     71  1.1  cgd 			name = C_name[i];
     72  1.1  cgd 			temp = k * 40;
     73  1.1  cgd 			end = pp->nummiles[i];
     74  1.1  cgd 			for (j = pp->sh_nummiles[i]; j < end; j++)
     75  1.1  cgd 				mvwaddstr(Miles, i + 1, (j << 2) + temp, name);
     76  1.1  cgd 			pp->sh_nummiles[i] = end;
     77  1.1  cgd 		}
     78  1.1  cgd 	}
     79  1.1  cgd 	prscore(TRUE);
     80  1.1  cgd 	temp = CARD_STRT;
     81  1.1  cgd 	pp = &Player[PLAYER];
     82  1.1  cgd 	for (i = 0; i < HAND_SZ; i++)
     83  1.1  cgd 		show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]);
     84  1.1  cgd 	mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck);
     85  1.1  cgd 	show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard);
     86  1.1  cgd 	if (End == 1000) {
     87  1.1  cgd 		move(EXT_Y, EXT_X);
     88  1.1  cgd 		standout();
     89  1.1  cgd 		addstr("Extension");
     90  1.1  cgd 		standend();
     91  1.1  cgd 	}
     92  1.1  cgd 	wrefresh(Board);
     93  1.1  cgd 	wrefresh(Miles);
     94  1.1  cgd 	wrefresh(Score);
     95  1.1  cgd }
     96  1.1  cgd 
     97  1.1  cgd /*
     98  1.1  cgd  * show_card:
     99  1.1  cgd  *	Show the given card if it is different from the last one shown
    100  1.1  cgd  */
    101  1.1  cgd show_card(y, x, c, lc)
    102  1.1  cgd int		y, x;
    103  1.1  cgd register CARD	c, *lc;
    104  1.1  cgd {
    105  1.1  cgd 	if (c == *lc)
    106  1.1  cgd 		return;
    107  1.1  cgd 
    108  1.1  cgd 	mvprintw(y, x, C_fmt, C_name[c]);
    109  1.1  cgd 	*lc = c;
    110  1.1  cgd }
    111  1.1  cgd 
    112  1.1  cgd static char	Score_fmt[] = "%4d";
    113  1.1  cgd 
    114  1.1  cgd prscore(for_real)
    115  1.1  cgd reg bool	for_real; {
    116  1.1  cgd 
    117  1.1  cgd 	reg PLAY	*pp;
    118  1.1  cgd 	reg int		x;
    119  1.1  cgd 
    120  1.1  cgd 	stdscr = Score;
    121  1.1  cgd 	for (pp = Player; pp < &Player[2]; pp++) {
    122  1.1  cgd 		x = (pp - Player) * 6 + 21;
    123  1.1  cgd 		show_score(1, x, pp->mileage, &pp->sh_mileage);
    124  1.1  cgd 		if (pp->safescore != pp->sh_safescore) {
    125  1.1  cgd 			mvprintw(2, x, Score_fmt, pp->safescore);
    126  1.1  cgd 			if (pp->safescore == 400)
    127  1.1  cgd 				mvaddstr(3, x + 1, "300");
    128  1.1  cgd 			else
    129  1.1  cgd 				mvaddstr(3, x + 1, "  0");
    130  1.1  cgd 			mvprintw(4, x, Score_fmt, pp->coupscore);
    131  1.1  cgd 			pp->sh_safescore = pp->safescore;
    132  1.1  cgd 		}
    133  1.1  cgd 		if (Window == W_FULL || Finished) {
    134  1.1  cgd #ifdef EXTRAP
    135  1.1  cgd 			if (for_real)
    136  1.1  cgd 				finalscore(pp);
    137  1.1  cgd 			else
    138  1.1  cgd 				extrapolate(pp);
    139  1.1  cgd #else
    140  1.1  cgd 			finalscore(pp);
    141  1.1  cgd #endif
    142  1.1  cgd 			show_score(11, x, pp->hand_tot, &pp->sh_hand_tot);
    143  1.1  cgd 			show_score(13, x, pp->total, &pp->sh_total);
    144  1.1  cgd 			show_score(14, x, pp->games, &pp->sh_games);
    145  1.1  cgd 		}
    146  1.1  cgd 		else {
    147  1.1  cgd 			show_score(6, x, pp->hand_tot, &pp->sh_hand_tot);
    148  1.1  cgd 			show_score(8, x, pp->total, &pp->sh_total);
    149  1.1  cgd 			show_score(9, x, pp->games, &pp->sh_games);
    150  1.1  cgd 		}
    151  1.1  cgd 	}
    152  1.1  cgd 	stdscr = Board;
    153  1.1  cgd }
    154  1.1  cgd 
    155  1.1  cgd /*
    156  1.1  cgd  * show_score:
    157  1.1  cgd  *	Show a score value if it is different from the last time we
    158  1.1  cgd  *	showed it.
    159  1.1  cgd  */
    160  1.1  cgd show_score(y, x, s, ls)
    161  1.1  cgd int		y, x;
    162  1.1  cgd register int	s, *ls;
    163  1.1  cgd {
    164  1.1  cgd 	if (s == *ls)
    165  1.1  cgd 		return;
    166  1.1  cgd 
    167  1.1  cgd 	mvprintw(y, x, Score_fmt, s);
    168  1.1  cgd 	*ls = s;
    169  1.1  cgd }
    170