4 * SPDX-FileCopyrightText: (C) 1977, 2005 by Will Crowther and Don Woods
5 * SPDX-License-Identifier: BSD-2-Clause
11 static int mxscor; /* ugh..the price for having score() not exit. */
13 int score(enum termination mode) {
14 /* 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 (!objects[i].is_treasure) {
44 if (objects[i].inventory != 0) {
52 if (!PROP_IS_STASHED(i) && !PROP_IS_NOTFOUND(i)) {
55 if (game.objects[i].place == LOC_BUILDING && PROP_IS_FOUND(i)) {
62 /* Now look at how he finished and how far he got. NDEATHS and
63 * game.numdie tell us how well he survived. game.dflag will tell us
64 * if he ever got suitably deep into the cave. game.closng still
65 * indicates whether he reached the endgame. And if he got as far as
66 * "cave closed" (indicated by "game.closed"), then bonus is zero for
67 * mundane exits or 133, 134, 135 if he blew it (so to speak). */
68 score += (NDEATHS - game.numdie) * 10;
69 mxscor += NDEATHS * 10;
70 if (mode == endgame) {
74 if (game.dflag != 0) {
83 if (game.bonus == none) {
86 if (game.bonus == splatter) {
89 if (game.bonus == defeat) {
92 if (game.bonus == victory) {
98 /* Did he come to Witt's End as he should? */
99 if (game.objects[MAGAZINE].place == LOC_WITTSEND) {
108 /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
109 for (int i = 0; i < NHINTS; i++) {
110 if (game.hints[i].used) {
111 score = score - hints[i].penalty;
120 score = score - game.trnluz - game.saved;
122 /* Return to score command if that's where we came from. */
123 if (mode == scoregame) {
124 rspeak(GARNERED_POINTS, score, mxscor, game.turns, game.turns);
130 void terminate(enum termination mode) {
131 /* End of game. Let's tell him all about it. */
132 int points = score(mode);
133 #if defined ADVENT_AUTOSAVE
137 if (points + game.trnluz + 1 >= mxscor && game.trnluz != 0) {
140 if (points + game.saved + 1 >= mxscor && game.saved != 0) {
141 rspeak(WITHOUT_SUSPENDS);
143 rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
144 for (int i = 1; i <= (int)NCLASSES; i++) {
145 if (classes[i].threshold >= points) {
146 speak(classes[i].message);
147 if (i < (int)NCLASSES) {
148 int nxt = classes[i].threshold + 1 - points;
149 rspeak(NEXT_HIGHER, nxt, nxt);