10 static long mxscor; /* ugh..the price for having score() not exit. */
12 long score(enum termination mode)
13 /* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if died
18 /* The present scoring algorithm is as follows:
19 * Objective: Points: Present total possible:
20 * Getting well into cave 25 25
21 * Each treasure < chest 12 60
22 * Treasure chest itself 14 14
23 * Each treasure > chest 16 224
24 * Surviving (MAX-NUM)*10 30
26 * Reaching "game.closng" 25 25
27 * "Closed": Quit/Killed 10
31 * Came to Witt's End 1 1
32 * Round out the total 2 2
34 * Points can also be deducted for using hints or too many turns, or for
35 * saving intermediate positions. */
37 /* First tally up the treasures. Must be in building and not broken.
38 * Give the poor guy 2 points just for finding each treasure. */
40 for (int i = 1; i <= NOBJECTS; i++) {
41 if (!object_descriptions[i].is_treasure)
43 if (object_descriptions[i].inventory != 0) {
45 if (i == CHEST)k = 14;
47 if (game.prop[i] >= 0)
49 if (game.place[i] == LOC_BUILDING && game.prop[i] == 0)
55 /* Now look at how he finished and how far he got. NDEATHS and
56 * game.numdie tell us how well he survived. game.dflag will tell us
57 * if he ever got suitably deep into the cave. game.closng still
58 * indicates whether he reached the endgame. And if he got as far as
59 * "cave closed" (indicated by "game.closed"), then bonus is zero for
60 * mundane exits or 133, 134, 135 if he blew it (so to speak). */
61 score += (NDEATHS - game.numdie) * 10;
62 mxscor += NDEATHS * 10;
66 if (game.dflag != 0)score += 25;
68 if (game.closng)score += 25;
73 if (game.bonus == SPLATTER_MESSAGE)
75 if (game.bonus == DEFEAT_MESSAGE)
77 if (game.bonus == VICTORY_MESSAGE)
82 /* Did he come to Witt's End as he should? */
83 if (game.place[MAGAZINE] == LOC_WITTSEND)
91 /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
92 for (long i = 0; i < NHINTS; i++) {
94 score = score - hints[i].penalty;
100 score = score - game.trnluz - game.saved;
102 /* Return to score command if that's where we came from. */
103 if (mode == scoregame) {
104 rspeak(GARNERED_POINTS, score, mxscor, game.turns, game.turns);
110 void terminate(enum termination mode)
111 /* End of game. Let's tell him all about it. */
113 long points = score(mode);
115 if (points + game.trnluz + 1 >= mxscor && game.trnluz != 0)
117 if (points + game.saved + 1 >= mxscor && game.saved != 0)
118 rspeak(WITHOUT_SUSPENDS);
119 rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
120 for (long i = 1; i <= (long)NCLASSES; i++) {
121 if (classes[i].threshold >= points) {
122 speak(classes[i].message);
123 i = classes[i].threshold + 1 - points;
124 rspeak(NEXT_HIGHER, i, i);