Chase more booleans and enums.
[super-star-trek.git] / src / finish.c
index e5a7386cf1cbfb2912a737a525fa5378ddfc94db..d39257422299a0ba4aa61eb6bb4d4291753537df 100644 (file)
@@ -2,11 +2,12 @@
 #include <string.h>
 #include <time.h>
 
-void dstrct() 
+void selfdestruct(void)
+/* self-destruct maneuver */
 {
     /* Finish with a BANG! */
     chew();
-    if (game.damage[DCOMPTR] != 0.0) {
+    if (damaged(DCOMPTR)) {
        prout(_("Computer damaged; cannot execute destruct sequence."));
        return;
     }
@@ -61,7 +62,7 @@ void kaboom(void)
        int l=1;
        while (l <= game.nenhere) {
            if (game.kpower[l]*game.kdist[l] <= whammo) 
-               deadkl(game.ks[l].x,game.ks[l].x, game.quad[game.ks[l].x][game.ks[l].y], game.ks[l].x, game.ks[l].y);
+               deadkl(game.ks[l], game.quad[game.ks[l].x][game.ks[l].y], game.ks[l]);
            l++;
        }
     }
@@ -69,10 +70,11 @@ void kaboom(void)
 }
                                
 
-void finish(FINTYPE ifin) 
+void finish(FINTYPE ifin)
+/* end the game, with appropriate notfications */
 {
-    int igotit = 0;
-    game.alldone = 1;
+    bool igotit = false;
+    game.alldone = true;
     skip(3);
     prout(_("It is stardate %.1f."), game.state.date);
     skip(1);
@@ -84,11 +86,11 @@ void finish(FINTYPE ifin)
 
        prout(_("You have smashed the Klingon invasion fleet and saved"));
        prout(_("the Federation."));
-       game.gamewon=1;
+       game.gamewon = true;
        if (game.alive) {
            double badpt;
            badpt = 5.0*game.state.starkl + game.casual + 10.0*game.state.nplankl +
-               45.*game.nhelp+100.*game.state.basekl;
+               45.*game.nhelp+100.*game.state.basekl+3.*game.abandoned;
            if (game.ship == IHF) badpt += 100.0;
            else if (game.ship == 0) badpt += 200.0;
            if (badpt < 100.0) badpt = 0.0;     // Close enough!
@@ -99,6 +101,8 @@ void finish(FINTYPE ifin)
                skip(1);
                prout(_("In fact, you have done so well that Starfleet Command"));
                switch (game.skill) {
+               case SKILL_NONE:
+                   break;      /* quiet gcc warning */
                case SKILL_NOVICE:
                    prout(_("promotes you one step in rank from \"Novice\" to \"Fair\"."));
                    break;
@@ -134,17 +138,13 @@ void finish(FINTYPE ifin)
                    break;
                }
                if (game.skill >= SKILL_EXPERT) {
-                   if (game.thawed
-#ifdef DEBUG
-                       && !game.idebug
-#endif
-                       )
+                   if (game.thawed && !idebug)
                        prout(_("You cannot get a citation, so..."));
                    else {
                        proutn(_("Do you want your Commodore Emeritus Citation printed? "));
                        chew();
-                       if (ja()) {
-                           igotit = 1;
+                       if (ja() == true) {
+                           igotit = true;
                        }
                    }
                }
@@ -154,7 +154,7 @@ void finish(FINTYPE ifin)
            prout(_("LIVE LONG AND PROSPER."));
        }
        score();
-       if (igotit != 0) plaque();
+       if (igotit) plaque();
        return;
     case FDEPLETE: // Federation Resources Depleted
        prout(_("Your time has run out and the Federation has been"));
@@ -169,7 +169,7 @@ void finish(FINTYPE ifin)
        else {
            prout(_("found guilty and"));
            prout(_("sentenced to death by slow torture."));
-           game.alive = 0;
+           game.alive = false;
        }
        score();
        return;
@@ -282,10 +282,13 @@ void finish(FINTYPE ifin)
        prout(_("Your ship is drawn to the center of the black hole."));
        prout(_("You are crushed into extremely dense matter."));
        break;
+    case FCREW:
+       prout(_("Your last crew member has died."));
+       break;
     }
     if (game.ship==IHF) game.ship= 0;
     else if (game.ship == IHE) game.ship = IHF;
-    game.alive = 0;
+    game.alive = false;
     if (KLINGREM != 0) {
        double goodies = game.state.remres/game.inresor;
        double baddies = (game.state.remkl + 2.0*game.state.remcom)/(game.inkling+2.0*game.incom);
@@ -308,12 +311,13 @@ void finish(FINTYPE ifin)
        prout(_("martyr and a hero. Someday maybe they'll erect a"));
        prout(_("statue in your memory. Rest in peace, and try not"));
        prout(_("to think about pigeons."));
-       game.gamewon = 1;
+       game.gamewon = true;
     }
     score();
 }
 
 void score(void) 
+/* compute player's score */
 {
     double timused = game.state.date - game.indate;
     int ithperd, iwon, klship;
@@ -327,11 +331,11 @@ void score(void)
     if (game.ship == IHE) klship = 0;
     else if (game.ship == IHF) klship = 1;
     else klship = 2;
-    if (game.gamewon == 0) game.state.nromrem = 0; // None captured if no win
+    if (!game.gamewon) game.state.nromrem = 0; // None captured if no win
     iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
        - 100*game.state.basekl - 100*klship - 45*game.nhelp -5*game.state.starkl - game.casual
-       + 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl + game.state.nromrem;
-    if (game.alive == 0) iscore -= 200;
+       + 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl - 300*game.state.nworldkl + game.state.nromrem;
+    if (!game.alive) iscore -= 200;
     skip(2);
     prout(_("Your score --"));
     if (NKILLROM)
@@ -358,6 +362,9 @@ void score(void)
     if (game.state.nplankl)
        prout(_("%6d planets destroyed by your action   %5d"),
              game.state.nplankl, -10*game.state.nplankl);
+    if ((game.options & OPTION_WORLDS) && game.state.nworldkl)
+       prout(_("%6d inhabited planets destroyed by your action   %5d"),
+             game.state.nplankl, -300*game.state.nworldkl);
     if (game.state.basekl)
        prout(_("%6d bases destroyed by your action     %5d"),
              game.state.basekl, -100*game.state.basekl);
@@ -367,14 +374,18 @@ void score(void)
     if (game.casual)
        prout(_("%6d casualties incurred                %5d"),
              game.casual, -game.casual);
+    if (game.abandoned)
+       prout(_("%6d crew abandoned in space            %5d"),
+             game.abandoned, -3*game.abandoned);
     if (klship)
        prout(_("%6d ship(s) lost or destroyed          %5d"),
              klship, -100*klship);
-    if (game.alive==0)
+    if (!game.alive)
        prout(_("Penalty for getting yourself killed        -200"));
     if (game.gamewon) {
        proutn(_("Bonus for winning "));
        switch (game.skill) {
+       case SKILL_NONE:     break;     /* quiet gcc warning */
        case SKILL_NOVICE:   proutn(_("Novice game  ")); break;
        case SKILL_FAIR:     proutn(_("Fair game    ")); break;
        case SKILL_GOOD:     proutn(_("Good game    ")); break;
@@ -387,7 +398,9 @@ void score(void)
     prout(_("TOTAL SCORE                               %5d"), iscore);
 }
 
-void plaque(void) {
+void plaque(void)
+/* emit winner's commemmorative plaque */
+{
        FILE *fp=NULL;
        time_t t;
        char *timestring;