Fix capitalization glitches.
[open-adventure.git] / score.c
1 #include <stdlib.h>
2 #include "misc.h"
3 #include "main.h"
4 #include "share.h"
5
6 /*
7  * scoring and wrap-up
8  */
9
10 void score(long MODE) {
11         /* <0 if scoring, >0 if quitting, =0 if died or won */
12
13 /*  The present scoring algorithm is as follows:
14  *     Objective:          Points:        Present total possible:
15  *  Getting well into cave   25                    25
16  *  Each treasure < chest    12                    60
17  *  Treasure chest itself    14                    14
18  *  Each treasure > chest    16                   224
19  *  Surviving             (MAX-NUM)*10             30
20  *  Not quitting              4                     4
21  *  Reaching "CLOSNG"        25                    25
22  *  "Closed": Quit/Killed    10
23  *            Klutzed        25
24  *            Wrong way      30
25  *            Success        45                    45
26  *  Came to Witt's End        1                     1
27  *  Round out the total       2                     2
28  *                                       TOTAL:   430
29  *  Points can also be deducted for using hints or too many turns, or for
30  *  saving intermediate positions. */
31
32         SCORE=0;
33         MXSCOR=0;
34
35 /*  First tally up the treasures.  Must be in building and not broken.
36  *  Give the poor guy 2 points just for finding each treasure. */
37
38         /* 20010 */ for (I=50; I<=MAXTRS; I++) {
39         if(PTEXT[I] == 0) goto L20010;
40         K=12;
41         if(I == CHEST)K=14;
42         if(I > CHEST)K=16;
43         if(PROP[I] >= 0)SCORE=SCORE+2;
44         if(PLACE[I] == 3 && PROP[I] == 0)SCORE=SCORE+K-2;
45         MXSCOR=MXSCOR+K;
46 L20010: /*etc*/ ;
47         } /* end loop */
48
49 /*  Now look at how he finished and how far he got.  MAXDIE and NUMDIE tell us
50  *  how well he survived.  DFLAG will
51  *  tell us if he ever got suitably deep into the cave.  CLOSNG still indicates
52  *  whether he reached the endgame.  And if he got as far as "cave closed"
53  *  (indicated by "CLOSED"), then bonus is zero for mundane exits or 133, 134,
54  *  135 if he blew it (so to speak). */
55
56         SCORE=SCORE+(MAXDIE-NUMDIE)*10;
57         MXSCOR=MXSCOR+MAXDIE*10;
58         if(MODE == 0)SCORE=SCORE+4;
59         MXSCOR=MXSCOR+4;
60         if(DFLAG != 0)SCORE=SCORE+25;
61         MXSCOR=MXSCOR+25;
62         if(CLOSNG)SCORE=SCORE+25;
63         MXSCOR=MXSCOR+25;
64         if(!CLOSED) goto L20020;
65         if(BONUS == 0)SCORE=SCORE+10;
66         if(BONUS == 135)SCORE=SCORE+25;
67         if(BONUS == 134)SCORE=SCORE+30;
68         if(BONUS == 133)SCORE=SCORE+45;
69 L20020: MXSCOR=MXSCOR+45;
70
71 /*  Did he come to Witt's End as he should? */
72
73         if(PLACE[MAGZIN] == 108)SCORE=SCORE+1;
74         MXSCOR=MXSCOR+1;
75
76 /*  Round it off. */
77
78         SCORE=SCORE+2;
79         MXSCOR=MXSCOR+2;
80
81 /*  Deduct for hints/turns/saves.  Hints < 4 are special; see database desc. */
82
83         for (I=1; I<=HNTMAX; I++) {
84         if(HINTED[I])SCORE=SCORE-HINTS[I][2];
85         } /* end loop */
86         if(NOVICE)SCORE=SCORE-5;
87         if(CLSHNT)SCORE=SCORE-10;
88         SCORE=SCORE-TRNLUZ-SAVED;
89
90 /*  Return to score command if that's where we came from. */
91
92         if(MODE < 0) return;
93
94 /*  that should be good enough.  Let's tell him all about it. */
95
96         if(SCORE+TRNLUZ+1 >= MXSCOR && TRNLUZ != 0)RSPEAK(242);
97         if(SCORE+SAVED+1 >= MXSCOR && SAVED != 0)RSPEAK(143);
98         SETPRM(1,SCORE,MXSCOR);
99         SETPRM(3,TURNS,TURNS);
100         RSPEAK(262);
101         for (I=1; I<=CLSSES; I++) {
102         if(CVAL[I] >= SCORE) goto L20210;
103         /*etc*/ ;
104         } /* end loop */
105         SPK=265;
106          goto L25000;
107
108 L20210: SPEAK(CTEXT[I]);
109         SPK=264;
110         if(I >= CLSSES) goto L25000;
111         I=CVAL[I]+1-SCORE;
112         SETPRM(1,I,I);
113         SPK=263;
114 L25000: RSPEAK(SPK);
115         exit(0);
116
117 }