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 (long i = MINTRS; i <= MAXTRS; i++) {
41 if (object_descriptions[i].inventory != 0) {
43 if (i == CHEST)k = 14;
45 if (game.prop[i] >= 0)
47 if (game.place[i] == LOC_BUILDING && game.prop[i] == 0)
53 /* Now look at how he finished and how far he got. maximum_deaths and
54 * game.numdie tell us how well he survived. game.dflag will tell us
55 * if he ever got suitably deep into the cave. game.closng still
56 * indicates whether he reached the endgame. And if he got as far as
57 * "cave closed" (indicated by "game.closed"), then bonus is zero for
58 * mundane exits or 133, 134, 135 if he blew it (so to speak). */
59 score += (maximum_deaths - game.numdie) * 10;
60 mxscor += maximum_deaths * 10;
64 if (game.dflag != 0)score += 25;
66 if (game.closng)score += 25;
71 if (game.bonus == SPLATTER_MESSAGE)
73 if (game.bonus == DEFEAT_MESSAGE)
75 if (game.bonus == VICTORY_MESSAGE)
80 /* Did he come to Witt's End as he should? */
81 if (game.place[MAGAZINE] == LOC_WITTSEND)
89 /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
90 for (long i = 1; i <= HNTMAX; i++) {
92 score = score - HINTS[i][2];
98 score = score - game.trnluz - game.saved;
100 /* Return to score command if that's where we came from. */
101 if (mode == scoregame) {
102 SETPRM(1, score, mxscor);
103 SETPRM(3, game.turns, game.turns);
104 RSPEAK(GARNERED_POINTS);
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 SETPRM(1, points, mxscor);
120 SETPRM(3, game.turns, game.turns);
122 for (long i = 1; i <= (long)CLSSES; i++) {
123 if (CVAL[i] >= points) {
124 speak(class_messages[i]);
125 i = CVAL[i] + 1 - points;