X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=score.c;h=8f91e44716ad0b6b95efeb6681fa0648d7399631;hp=c0f28faa2c8d1f075f2a3250daabf61f18a719bf;hb=67ed99b29cfe5c32b3db72091de3fb174195e032;hpb=b3057f038bc990e216c1763f7de1f485892296d2 diff --git a/score.c b/score.c index c0f28fa..8f91e44 100644 --- a/score.c +++ b/score.c @@ -7,11 +7,13 @@ * scoring and wrap-up */ -void score(enum termination mode) +static long mxscor; /* ugh..the price for having score() not exit. */ + +long score(enum termination mode) /* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if died * or won */ { - long score = 0, mxscor = 0; + long score = 0; /* The present scoring algorithm is as follows: * Objective: Points: Present total possible: @@ -34,6 +36,7 @@ void score(enum termination mode) /* First tally up the treasures. Must be in building and not broken. * Give the poor guy 2 points just for finding each treasure. */ + mxscor = 0; for (long i = MINTRS; i <= MAXTRS; i++) { if (object_descriptions[i].inventory != 0) { long k = 12; @@ -47,14 +50,14 @@ void score(enum termination mode) } } - /* Now look at how he finished and how far he got. MAXDIE and + /* Now look at how he finished and how far he got. maximum_deaths and * game.numdie tell us how well he survived. game.dflag will tell us * if he ever got suitably deep into the cave. game.closng still * indicates whether he reached the endgame. And if he got as far as * "cave closed" (indicated by "game.closed"), then bonus is zero for * mundane exits or 133, 134, 135 if he blew it (so to speak). */ - score += (MAXDIE - game.numdie) * 10; - mxscor += MAXDIE * 10; + score += (maximum_deaths - game.numdie) * 10; + mxscor += maximum_deaths * 10; if (mode == endgame) score += 4; mxscor += 4; @@ -75,7 +78,7 @@ void score(enum termination mode) mxscor += 45; /* Did he come to Witt's End as he should? */ - if (game.place[MAGZIN] == LOC_WITTSEND) + if (game.place[MAGAZINE] == LOC_WITTSEND) score += 1; mxscor += 1; @@ -86,7 +89,7 @@ void score(enum termination mode) /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */ for (long i = 1; i <= HNTMAX; i++) { if (game.hinted[i]) - score = score - HINTS[i][2]; + score = score - hints[i-1].penalty; } if (game.novice) score -= 5; @@ -99,21 +102,27 @@ void score(enum termination mode) SETPRM(1, score, mxscor); SETPRM(3, game.turns, game.turns); RSPEAK(GARNERED_POINTS); - return; } - /* that should be good enough. Let's tell him all about it. */ - if (score + game.trnluz + 1 >= mxscor && game.trnluz != 0) + return score; +} + +void terminate(enum termination mode) +/* End of game. Let's tell him all about it. */ +{ + long points = score(mode); + + if (points + game.trnluz + 1 >= mxscor && game.trnluz != 0) RSPEAK(TOOK_LONG); - if (score + game.saved + 1 >= mxscor && game.saved != 0) + if (points + game.saved + 1 >= mxscor && game.saved != 0) RSPEAK(WITHOUT_SUSPENDS); - SETPRM(1, score, mxscor); + SETPRM(1, points, mxscor); SETPRM(3, game.turns, game.turns); RSPEAK(TOTAL_SCORE); for (long i = 1; i <= (long)CLSSES; i++) { - if (CVAL[i] >= score) { - newspeak(class_messages[i]); - i = CVAL[i] + 1 - score; + if (classes[i].threshold >= points) { + speak(classes[i].message); + i = classes[i].threshold + 1 - points; SETPRM(1, i, i); RSPEAK(NEXT_HIGHER); exit(0); @@ -122,5 +131,6 @@ void score(enum termination mode) RSPEAK(OFF_SCALE); RSPEAK(NO_HIGHER); exit(0); - } + +/* end */