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) {
44 if (i == CHEST)k = 14;
46 if (game.prop[i] >= 0)
48 if (game.place[i] == LOC_BUILDING && game.prop[i] == 0)
54 /* Now look at how he finished and how far he got. NDEATHS and
55 * game.numdie tell us how well he survived. game.dflag will tell us
56 * if he ever got suitably deep into the cave. game.closng still
57 * indicates whether he reached the endgame. And if he got as far as
58 * "cave closed" (indicated by "game.closed"), then bonus is zero for
59 * mundane exits or 133, 134, 135 if he blew it (so to speak). */
60 score += (NDEATHS - game.numdie) * 10;
61 mxscor += NDEATHS * 10;
65 if (game.dflag != 0)score += 25;
67 if (game.closng)score += 25;
72 if (game.bonus == SPLATTER_MESSAGE)
74 if (game.bonus == DEFEAT_MESSAGE)
76 if (game.bonus == VICTORY_MESSAGE)
81 /* Did he come to Witt's End as he should? */
82 if (game.place[MAGAZINE] == LOC_WITTSEND)
90 /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
91 for (long i = 0; i < NHINTS; i++) {
93 score = score - hints[i].penalty;
99 score = score - game.trnluz - game.saved;
101 /* Return to score command if that's where we came from. */
102 if (mode == scoregame) {
103 rspeak(GARNERED_POINTS, score, mxscor, game.turns, game.turns);
109 void terminate(enum termination mode)
110 /* End of game. Let's tell him all about it. */
112 long points = score(mode);
114 if (points + game.trnluz + 1 >= mxscor && game.trnluz != 0)
116 if (points + game.saved + 1 >= mxscor && game.saved != 0)
117 rspeak(WITHOUT_SUSPENDS);
118 rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
119 for (long i = 1; i <= (long)NCLASSES; i++) {
120 if (classes[i].threshold >= points) {
121 speak(classes[i].message);
122 i = classes[i].threshold + 1 - points;
123 rspeak(NEXT_HIGHER, i, i);