9 static long mxscor; /* ugh..the price for having score() not exit. */
11 long score(enum termination mode)
12 /* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if died
17 /* The present scoring algorithm is as follows:
18 * Objective: Points: Present total possible:
19 * Getting well into cave 25 25
20 * Each treasure < chest 12 60
21 * Treasure chest itself 14 14
22 * Each treasure > chest 16 224
23 * Surviving (MAX-NUM)*10 30
25 * Reaching "game.closng" 25 25
26 * "Closed": Quit/Killed 10
30 * Came to Witt's End 1 1
31 * Round out the total 2 2
33 * Points can also be deducted for using hints or too many turns, or for
34 * saving intermediate positions. */
36 /* First tally up the treasures. Must be in building and not broken.
37 * Give the poor guy 2 points just for finding each treasure. */
39 for (int i = 1; i <= NOBJECTS; i++) {
40 if (!objects[i].is_treasure)
42 if (objects[i].inventory != 0) {
48 if (game.prop[i] > STATE_NOTFOUND)
50 if (game.place[i] == LOC_BUILDING && game.prop[i] == STATE_FOUND)
56 /* Now look at how he finished and how far he got. NDEATHS and
57 * game.numdie tell us how well he survived. game.dflag will tell us
58 * if he ever got suitably deep into the cave. game.closng still
59 * indicates whether he reached the endgame. And if he got as far as
60 * "cave closed" (indicated by "game.closed"), then bonus is zero for
61 * mundane exits or 133, 134, 135 if he blew it (so to speak). */
62 score += (NDEATHS - game.numdie) * 10;
63 mxscor += NDEATHS * 10;
74 if (game.bonus == none)
76 if (game.bonus == splatter)
78 if (game.bonus == defeat)
80 if (game.bonus == victory)
85 /* Did he come to Witt's End as he should? */
86 if (game.place[MAGAZINE] == LOC_WITTSEND)
94 /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
95 for (long i = 0; i < NHINTS; i++) {
97 score = score - hints[i].penalty;
103 score = score - game.trnluz - game.saved;
105 /* Return to score command if that's where we came from. */
106 if (mode == scoregame) {
107 rspeak(GARNERED_POINTS, score, mxscor, game.turns, game.turns);
113 void terminate(enum termination mode)
114 /* End of game. Let's tell him all about it. */
116 long points = score(mode);
118 if (points + game.trnluz + 1 >= mxscor && game.trnluz != 0)
120 if (points + game.saved + 1 >= mxscor && game.saved != 0)
121 rspeak(WITHOUT_SUSPENDS);
122 rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
123 for (long i = 1; i <= (long)NCLASSES; i++) {
124 if (classes[i].threshold >= points) {
125 speak(classes[i].message);
126 i = classes[i].threshold + 1 - points;
127 rspeak(NEXT_HIGHER, i, i);