1 | /**
|
---|
2 | SCORE
|
---|
3 |
|
---|
4 | Calculate what the player's score would be if he quit now.
|
---|
5 | This may be the end of the game, or he may just be wondering
|
---|
6 | how he is doing.
|
---|
7 |
|
---|
8 | The present scoring algorithm is as follows:
|
---|
9 | (treasure points are explained in a following comment)
|
---|
10 | objective: points: present total possible:
|
---|
11 | getting well into cave 25 25
|
---|
12 | total possible for treasures (+mag) 426
|
---|
13 | reaching "closing" 20 20
|
---|
14 | "closed": quit/killed 10
|
---|
15 | klutzed 20
|
---|
16 | wrong way 25
|
---|
17 | success 30 30
|
---|
18 | total: 501
|
---|
19 | (points can also be deducted for using hints or deaths.)
|
---|
20 |
|
---|
21 | */
|
---|
22 |
|
---|
23 | #include <stdio.h>
|
---|
24 | #include "advent.h"
|
---|
25 | #include "advdec.h"
|
---|
26 |
|
---|
27 | void score(scorng)
|
---|
28 | boolean scorng;
|
---|
29 | {
|
---|
30 | int cur_score, max_score, qk[3];
|
---|
31 | int obj, num_treas, k, i;
|
---|
32 | long t;
|
---|
33 | char *kk2c;
|
---|
34 |
|
---|
35 | cur_score = 0;
|
---|
36 | max_score = 0;
|
---|
37 | num_treas = 0;
|
---|
38 |
|
---|
39 | /** First tally up the treasures. Must be in building and not broken.
|
---|
40 | give the poor guy partial score just for finding each treasure.
|
---|
41 | Gets full score, qk[3], for obj if:
|
---|
42 | obj is at loc qk[1], and
|
---|
43 | obj has prop value of qk[2]
|
---|
44 |
|
---|
45 | weight total possible
|
---|
46 | magazine 1 (absolute) 1
|
---|
47 |
|
---|
48 | all the following are multiplied by 5 (range 5-25):
|
---|
49 | book 2
|
---|
50 | cask 3 (with wine only)
|
---|
51 | chain 4 (must enter via styx)
|
---|
52 | chest 5
|
---|
53 | cloak 3
|
---|
54 | clover 1
|
---|
55 | coins 5
|
---|
56 | crown 2
|
---|
57 | crystal-ball 2
|
---|
58 | diamonds 2
|
---|
59 | eggs 3
|
---|
60 | emerald 3
|
---|
61 | grail 2
|
---|
62 | horn 2
|
---|
63 | jewels 1
|
---|
64 | lyre 1
|
---|
65 | nugget 2
|
---|
66 | pearl 4
|
---|
67 | pyramid 4
|
---|
68 | radium 4
|
---|
69 | ring 4
|
---|
70 | rug 3
|
---|
71 | sapphire 1
|
---|
72 | shoes 3
|
---|
73 | spices 1
|
---|
74 | sword 4
|
---|
75 | trident 2
|
---|
76 | vase 2
|
---|
77 | droplet 5
|
---|
78 | tree 5
|
---|
79 | total: 85 * 5 = 425 + 1 ==> 426
|
---|
80 | */
|
---|
81 |
|
---|
82 | for (obj = 1; obj < MAXOBJ; obj++) {
|
---|
83 | if (g.points[obj] == 0)
|
---|
84 | continue;
|
---|
85 | t = g.points[obj];
|
---|
86 | qk[0] = (int) (t < 0L ? -((t = -t) % 1000) : (t % 1000));
|
---|
87 | t /= 1000;
|
---|
88 | qk[1] = (int) (t % 1000);
|
---|
89 | qk[2] = (int) (t / 1000);
|
---|
90 | k = 0;
|
---|
91 | if (treasr(obj)) {
|
---|
92 | num_treas++;
|
---|
93 | k = qk[2] * 2;
|
---|
94 | if (g.prop[obj] >= 0)
|
---|
95 | cur_score += k;
|
---|
96 | qk[2] *= 5;
|
---|
97 | }
|
---|
98 | if ((g.place[obj] == qk[0]) && (g.prop[obj] == qk[1])
|
---|
99 | && ((g.place[obj] != -CHEST) || (g.place[CHEST] == 3))
|
---|
100 | && ((g.place[obj] != -SHIELD) || (g.place[SHIELD] == -SAFE))
|
---|
101 | )
|
---|
102 | cur_score += qk[2] - k;
|
---|
103 | max_score += qk[2];
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | /**
|
---|
108 | Now look at how he finished and how far he got. Maxdie and numdie tell us
|
---|
109 | how well he survived. Gaveup says whether he exited via quit. Dflag will
|
---|
110 | tell us if he ever got suitably deep into the cave. Closing still indicates
|
---|
111 | whether he reached the endgame. And if he got as far as "cave closed"
|
---|
112 | (indicated by "closed"), then bonus is zero for mundane exits or 133, 134,
|
---|
113 | 135 if he blew it (so to speak).
|
---|
114 | */
|
---|
115 |
|
---|
116 | if (g.dflag)
|
---|
117 | cur_score += 25;
|
---|
118 | max_score += 25;
|
---|
119 | if (g.closing)
|
---|
120 | cur_score += 20;
|
---|
121 | max_score += 20;
|
---|
122 | if (g.closed) {
|
---|
123 | if (g.bonus == 0)
|
---|
124 | cur_score += 10;
|
---|
125 | else if (g.bonus == 135)
|
---|
126 | cur_score += 20;
|
---|
127 | else if (g.bonus == 134)
|
---|
128 | cur_score += 25;
|
---|
129 | else if (g.bonus == 133)
|
---|
130 | cur_score += 30;
|
---|
131 | }
|
---|
132 | max_score += 30;
|
---|
133 |
|
---|
134 | /* Deduct points for hints, deaths and quiting.
|
---|
135 | hints < hntmin are special; see database description
|
---|
136 | */
|
---|
137 | for (i = 1; i <= HNTMAX; i++)
|
---|
138 | if (g.hinted[i])
|
---|
139 | cur_score -= g.hints[i][2];
|
---|
140 | cur_score -= g.numdie * 10;
|
---|
141 | if (gaveup)
|
---|
142 | cur_score -= 4;
|
---|
143 |
|
---|
144 | fprintf(stdout, "You have found %3d out of %3d Treasures,",
|
---|
145 | num_treas - g.tally, num_treas);
|
---|
146 | fprintf(stdout, " using %4d turns\n", g.turns);
|
---|
147 | fprintf(stdout, "For a score of: %4d", cur_score);
|
---|
148 | fprintf(stdout, " out of a possible %4d\n", max_score);
|
---|
149 |
|
---|
150 | if (cur_score < 110) {
|
---|
151 | fprintf(stdout, "You are obviously a rank amateur.");
|
---|
152 | if (!scorng)
|
---|
153 | fprintf(stdout, " Better luck next time.");
|
---|
154 | fputc('\n', stdout);
|
---|
155 | k = 110 - cur_score;
|
---|
156 | } else if (cur_score < 152) {
|
---|
157 | fprintf(stdout,
|
---|
158 | "Your score qualifies you as a Novice Class Adventurer.\n");
|
---|
159 | k = 152 - cur_score;
|
---|
160 | } else if (cur_score < 200) {
|
---|
161 | fprintf(stdout,
|
---|
162 | "You have achieved the rating: \"Experienced Adventurer\".\n");
|
---|
163 | k = 200 - cur_score;
|
---|
164 | } else if (cur_score < 277) {
|
---|
165 | fprintf(stdout,
|
---|
166 | "You may now consider yourself a \"Seasoned Adventurer\".\n");
|
---|
167 | k = 277 - cur_score;
|
---|
168 | } else if (cur_score < 345) {
|
---|
169 | fprintf(stdout,
|
---|
170 | "You have reached \"Junior Master\" status.\n");
|
---|
171 | k = 345 - cur_score;
|
---|
172 | } else if (cur_score < 451) {
|
---|
173 | fprintf(stdout,
|
---|
174 | "Your score puts you in Master Adventurer Class C.\n");
|
---|
175 | k = 451 - cur_score;
|
---|
176 | } else if (cur_score < 471) {
|
---|
177 | fprintf(stdout,
|
---|
178 | "Your score puts you in Master Adventurer Class B.\n");
|
---|
179 | k = 471 - cur_score;
|
---|
180 | } else if (cur_score < 501) {
|
---|
181 | fprintf(stdout,
|
---|
182 | "Your score puts you in Master Adventurer Class A.\n");
|
---|
183 | k = 501 - cur_score;
|
---|
184 | } else {
|
---|
185 | fprintf(stdout,
|
---|
186 | "All of Adventuredom gives tribute to you, Adventurer Grandmaster!\n");
|
---|
187 | k = 0;
|
---|
188 | }
|
---|
189 |
|
---|
190 | if (!scorng) {
|
---|
191 | kk2c = (k == 1) ? "." : "s.";
|
---|
192 | printf("\nTo acheive the next higher rating,");
|
---|
193 | if (cur_score == 501)
|
---|
194 | printf(" would be a neat trick!\n\n CONGRATULATIONS!!\n");
|
---|
195 | else
|
---|
196 | printf(" you need %3d more point%s\n", k, kk2c);
|
---|
197 | }
|
---|
198 | return;
|
---|
199 | }
|
---|