Commit | Line | Data |
---|---|---|
c542bac9 KB |
1 | /* |
2 | * Copyright (c) 1982 Regents of the University of California. | |
4dfa8914 KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
65c7d3b6 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
c542bac9 KB |
16 | */ |
17 | ||
18 | #ifndef lint | |
65c7d3b6 | 19 | static char sccsid[] = "@(#)end.c 5.3 (Berkeley) %G%"; |
4dfa8914 | 20 | #endif /* not lint */ |
c542bac9 KB |
21 | |
22 | # include "mille.h" | |
23 | ||
24 | /* | |
25 | * @(#)end.c 1.1 (Berkeley) 4/1/82 | |
26 | */ | |
27 | ||
28 | /* | |
29 | * print out the score as if it was final, and add the totals for | |
30 | * the end-of-games points to the user who deserves it (if any). | |
31 | */ | |
32 | finalscore(pp) | |
33 | reg PLAY *pp; { | |
34 | ||
35 | reg int temp, tot, num; | |
36 | ||
37 | if (pp->was_finished == Finished) | |
38 | return; | |
39 | ||
40 | pp->was_finished = Finished; | |
41 | num = pp - Player; | |
42 | temp = num * 6 + 21 + 1; | |
43 | for (tot = 5; tot <= 9; tot++) | |
44 | mvaddstr(tot, temp, " 0"); | |
45 | if (pp->mileage == End) { | |
46 | mvaddstr(5, temp, "40"); | |
47 | tot = SC_TRIP; | |
48 | if (pp->nummiles[C_200] == 0) { | |
49 | mvaddstr(6, temp, "30"); | |
50 | tot = SC_TRIP + SC_SAFE; | |
51 | } | |
52 | if (Topcard <= Deck) { | |
53 | mvaddstr(7, temp, "30"); | |
54 | tot += SC_DELAY; | |
55 | } | |
56 | if (End == 1000) { | |
57 | mvaddstr(8, temp, "20"); | |
58 | tot += SC_EXTENSION; | |
59 | } | |
60 | if (Player[other(num)].mileage == 0) { | |
61 | mvaddstr(9, temp, "50"); | |
62 | tot += SC_SHUT_OUT; | |
63 | } | |
64 | pp->total += tot; | |
65 | pp->hand_tot += tot; | |
66 | } | |
67 | } | |
68 | ||
69 | # ifdef EXTRAP | |
70 | static int Last_tot[2]; /* last tot used for extrapolate */ | |
71 | ||
72 | /* | |
73 | * print out the score as if it was final, and add the totals for | |
74 | * the end-of-games points to the user who deserves it (if any). | |
75 | */ | |
76 | extrapolate(pp) | |
77 | reg PLAY *pp; { | |
78 | ||
79 | reg int x, num, tot, count; | |
80 | ||
81 | num = pp - Player; | |
82 | tot += SC_TRIP + SC_DELAY + SC_EXT; | |
83 | x = num * 6 + 21 + 3; | |
84 | for (tot = 5; tot <= 9; tot++) | |
85 | mvaddch(tot, x, '0'); | |
86 | x -= 2; | |
87 | pp = &Player[other(num)]; | |
88 | for (count = 0, tot = 0; tot < NUM_SAFE; tot++) | |
89 | if (pp->safety[tot] != S_PLAYED) | |
90 | count += SC_SAFE; | |
91 | mvprintw(3, x, "%3d", count); | |
92 | tot += count; | |
93 | if (count == 400) { | |
94 | mvaddstr(4, x, "30"); | |
95 | tot += SC_ALL_SAFE; | |
96 | } | |
97 | pp = &Player[num]; | |
98 | for (count = 0, tot = 0; tot < NUM_SAFE; tot++) | |
99 | if (pp->safety[tot] != S_PLAYED) | |
100 | count += SC_COUP / 10; | |
101 | mvprintw(4, x - 1, "%3d", count); | |
102 | tot += count; | |
103 | tot += 1000 - pp->mileage; | |
104 | mvaddstr(5, x, "40"); | |
105 | mvaddstr(7, x, "30"); | |
106 | mvaddstr(8, x, "20"); | |
107 | if (pp->nummiles[C_200] == 0) { | |
108 | mvaddstr(6, x, "30"); | |
109 | tot = SC_TRIP + SC_SAFE; | |
110 | } | |
111 | if (Player[other(num)].mileage == 0) { | |
112 | mvaddstr(9, x, "50"); | |
113 | tot += SC_SHUT_OUT; | |
114 | } | |
115 | pp->total += tot; | |
116 | pp->hand_tot += tot; | |
117 | Last_tot[num] = tot; | |
118 | } | |
119 | ||
120 | undoex() { | |
121 | ||
122 | reg PLAY *pp; | |
123 | reg int i; | |
124 | ||
125 | i = 0; | |
126 | for (pp = Player; pp < &Player[2]; pp++) { | |
127 | pp->total -= Last_tot[i]; | |
128 | pp->hand_tot -= Last_tot[i++]; | |
129 | } | |
130 | } | |
131 | # endif | |
132 |