xref: /original-bsd/games/mille/end.c (revision 9f9a0d6d)
1 /*
2  * Copyright (c) 1982 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)end.c	5.4 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"mille.h"
13 
14 /*
15  * @(#)end.c	1.1 (Berkeley) 4/1/82
16  */
17 
18 /*
19  *	print out the score as if it was final, and add the totals for
20  * the end-of-games points to the user who deserves it (if any).
21  */
22 finalscore(pp)
23 reg PLAY	*pp; {
24 
25 	reg int		temp, tot, num;
26 
27 	if (pp->was_finished == Finished)
28 		return;
29 
30 	pp->was_finished = Finished;
31 	num = pp - Player;
32 	temp = num * 6 + 21 + 1;
33 	for (tot = 5; tot <= 9; tot++)
34 		mvaddstr(tot, temp, "  0");
35 	if (pp->mileage == End) {
36 		mvaddstr(5, temp, "40");
37 		tot = SC_TRIP;
38 		if (pp->nummiles[C_200] == 0) {
39 			mvaddstr(6, temp, "30");
40 			tot = SC_TRIP + SC_SAFE;
41 		}
42 		if (Topcard <= Deck) {
43 			mvaddstr(7, temp, "30");
44 			tot += SC_DELAY;
45 		}
46 		if (End == 1000) {
47 			mvaddstr(8, temp, "20");
48 			tot += SC_EXTENSION;
49 		}
50 		if (Player[other(num)].mileage == 0) {
51 			mvaddstr(9, temp, "50");
52 			tot += SC_SHUT_OUT;
53 		}
54 		pp->total += tot;
55 		pp->hand_tot += tot;
56 	}
57 }
58 
59 # ifdef EXTRAP
60 static int	Last_tot[2];	/* last tot used for extrapolate	*/
61 
62 /*
63  *	print out the score as if it was final, and add the totals for
64  * the end-of-games points to the user who deserves it (if any).
65  */
66 extrapolate(pp)
67 reg PLAY	*pp; {
68 
69 	reg int		x, num, tot, count;
70 
71 	num = pp - Player;
72 	tot += SC_TRIP + SC_DELAY + SC_EXT;
73 	x = num * 6 + 21 + 3;
74 	for (tot = 5; tot <= 9; tot++)
75 		mvaddch(tot, x, '0');
76 	x -= 2;
77 	pp = &Player[other(num)];
78 	for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
79 		if (pp->safety[tot] != S_PLAYED)
80 			count += SC_SAFE;
81 	mvprintw(3, x, "%3d", count);
82 	tot += count;
83 	if (count == 400) {
84 		mvaddstr(4, x, "30");
85 		tot += SC_ALL_SAFE;
86 	}
87 	pp = &Player[num];
88 	for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
89 		if (pp->safety[tot] != S_PLAYED)
90 			count += SC_COUP / 10;
91 	mvprintw(4, x - 1, "%3d", count);
92 	tot += count;
93 	tot += 1000 - pp->mileage;
94 	mvaddstr(5, x, "40");
95 	mvaddstr(7, x, "30");
96 	mvaddstr(8, x, "20");
97 	if (pp->nummiles[C_200] == 0) {
98 		mvaddstr(6, x, "30");
99 		tot = SC_TRIP + SC_SAFE;
100 	}
101 	if (Player[other(num)].mileage == 0) {
102 		mvaddstr(9, x, "50");
103 		tot += SC_SHUT_OUT;
104 	}
105 	pp->total += tot;
106 	pp->hand_tot += tot;
107 	Last_tot[num] = tot;
108 }
109 
110 undoex() {
111 
112 	reg PLAY	*pp;
113 	reg int		i;
114 
115 	i = 0;
116 	for (pp = Player; pp < &Player[2]; pp++) {
117 		pp->total -= Last_tot[i];
118 		pp->hand_tot -= Last_tot[i++];
119 	}
120 }
121 # endif
122 
123