score.c

Go to the documentation of this file.
00001 
00023 #include        <stdio.h>
00024 #include        "advent.h"
00025 #include        "advdec.h"
00026 
00027 void score(scorng)
00028 boolean scorng;
00029 {
00030     int cur_score, max_score, qk[3];
00031     int obj, num_treas, k, i;
00032     long t;
00033     char *kk2c;
00034 
00035     cur_score = 0;
00036     max_score = 0;
00037     num_treas = 0;
00038 
00082     for (obj = 1; obj < MAXOBJ; obj++) {
00083         if (g.points[obj] == 0)
00084             continue;
00085         t = g.points[obj];
00086         qk[0] = (int) (t < 0L ? -((t = -t) % 1000) : (t % 1000));
00087         t /= 1000;
00088         qk[1] = (int) (t % 1000);
00089         qk[2] = (int) (t / 1000);
00090         k = 0;
00091         if (treasr(obj)) {
00092             num_treas++;
00093             k = qk[2] * 2;
00094             if (g.prop[obj] >= 0)
00095                 cur_score += k;
00096             qk[2] *= 5;
00097         }
00098         if ((g.place[obj] == qk[0]) && (g.prop[obj] == qk[1])
00099             && ((g.place[obj] != -CHEST) || (g.place[CHEST] == 3))
00100           && ((g.place[obj] != -SHIELD) || (g.place[SHIELD] == -SAFE))
00101             )
00102             cur_score += qk[2] - k;
00103         max_score += qk[2];
00104     }
00105 
00106 
00116     if (g.dflag)
00117         cur_score += 25;
00118     max_score += 25;
00119     if (g.closing)
00120         cur_score += 20;
00121     max_score += 20;
00122     if (g.closed) {
00123         if (g.bonus == 0)
00124             cur_score += 10;
00125         else if (g.bonus == 135)
00126             cur_score += 20;
00127         else if (g.bonus == 134)
00128             cur_score += 25;
00129         else if (g.bonus == 133)
00130             cur_score += 30;
00131     }
00132     max_score += 30;
00133 
00134 /*  Deduct points for hints, deaths and quiting.
00135     hints < hntmin are special; see database description
00136 */
00137     for (i = 1; i <= HNTMAX; i++)
00138         if (g.hinted[i])
00139             cur_score -= g.hints[i][2];
00140     cur_score -= g.numdie * 10;
00141     if (gaveup)
00142         cur_score -= 4;
00143 
00144     fprintf(stdout, "You have found   %3d out of %3d Treasures,",
00145             num_treas - g.tally, num_treas);
00146     fprintf(stdout, " using %4d turns\n", g.turns);
00147     fprintf(stdout, "For a score of: %4d", cur_score);
00148     fprintf(stdout, " out of a possible %4d\n", max_score);
00149 
00150     if (cur_score < 110) {
00151         fprintf(stdout, "You are obviously a rank amateur.");
00152         if (!scorng)
00153             fprintf(stdout, "  Better luck next time.");
00154         fputc('\n', stdout);
00155         k = 110 - cur_score;
00156     } else if (cur_score < 152) {
00157         fprintf(stdout,
00158           "Your score qualifies you as a Novice Class Adventurer.\n");
00159         k = 152 - cur_score;
00160     } else if (cur_score < 200) {
00161         fprintf(stdout,
00162         "You have achieved the rating: \"Experienced Adventurer\".\n");
00163         k = 200 - cur_score;
00164     } else if (cur_score < 277) {
00165         fprintf(stdout,
00166         "You may now consider yourself a \"Seasoned Adventurer\".\n");
00167         k = 277 - cur_score;
00168     } else if (cur_score < 345) {
00169         fprintf(stdout,
00170                 "You have reached \"Junior Master\" status.\n");
00171         k = 345 - cur_score;
00172     } else if (cur_score < 451) {
00173         fprintf(stdout,
00174                 "Your score puts you in Master Adventurer Class C.\n");
00175         k = 451 - cur_score;
00176     } else if (cur_score < 471) {
00177         fprintf(stdout,
00178                 "Your score puts you in Master Adventurer Class B.\n");
00179         k = 471 - cur_score;
00180     } else if (cur_score < 501) {
00181         fprintf(stdout,
00182                 "Your score puts you in Master Adventurer Class A.\n");
00183         k = 501 - cur_score;
00184     } else {
00185         fprintf(stdout,
00186                 "All of Adventuredom gives tribute to you, Adventurer Grandmaster!\n");
00187         k = 0;
00188     }
00189 
00190     if (!scorng) {
00191         kk2c = (k == 1) ? "." : "s.";
00192         printf("\nTo acheive the next higher rating,");
00193         if (cur_score == 501)
00194             printf(" would be a neat trick!\n\n  CONGRATULATIONS!!\n");
00195         else
00196             printf(" you need %3d more point%s\n", k, kk2c);
00197     }
00198     return;
00199 }

Generated on Fri Apr 14 22:56:39 2006 for minix by  doxygen 1.4.6