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