X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=finish.c;h=7144086973e2c8cca21efc56ed33578dcfa7c15e;hp=1d58840fa8361a76c5ffffd6614773949a238db7;hb=e38417cf291ac23e9de46b0376e42747d1d39582;hpb=b0629033955fcfdcd93a4a2cf3ab29e8adc56200 diff --git a/finish.c b/finish.c index 1d58840..7144086 100644 --- a/finish.c +++ b/finish.c @@ -5,7 +5,7 @@ void dstrct() { /* Finish with a BANG! */ chew(); - if (damage[DCOMPTR] != 0.0) { + if (game.damage[DCOMPTR] != 0.0) { prout("Computer damaged; cannot execute destruct sequence."); return; } @@ -22,7 +22,7 @@ void dstrct() { prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED"); scan(); chew(); - if (strcmp(passwd, citem) != 0) { + if (strcmp(game.passwd, citem) != 0) { prouts("PASSWORD-REJECTED;"); skip(1); prout("CONTINUITY-EFFECTED"); skip(1); @@ -55,8 +55,8 @@ void kaboom(void) { double whammo = 25.0 * energy; int l=1; while (l <= nenhere) { - if (kpower[l]*kdist[l] <= whammo) - deadkl(kx[l],ky[l], quad[kx[l]][ky[l]], kx[l], ky[l]); + if (game.kpower[l]*game.kdist[l] <= whammo) + deadkl(game.kx[l],game.ky[l], game.quad[game.kx[l]][game.ky[l]], game.kx[l], game.ky[l]); l++; } } @@ -68,26 +68,27 @@ void finish(FINTYPE ifin) { int igotit = 0; alldone = 1; skip(3); - printf("It is stardate %.1f .\n\n", d.date); + prout("It is stardate %.1f.", game.state.date); + prout(""); switch (ifin) { case FWON: // Game has been won - if (d.nromrem != 0) - printf("The remaining %d Romulans surrender to Starfleet Command.\n", - d.nromrem); + if (game.state.nromrem != 0) + prout("The remaining %d Romulans surrender to Starfleet Command.", + game.state.nromrem); prout("You have smashed the Klingon invasion fleet and saved"); prout("the Federation."); gamewon=1; if (alive) { double badpt; - badpt = 5.*d.starkl + casual + 10.*d.nplankl + - 45.*nhelp+100.*d.basekl; + badpt = 5.*game.state.starkl + casual + 10.*game.state.nplankl + + 45.*nhelp+100.*game.state.basekl; if (ship == IHF) badpt += 100.0; else if (ship == 0) badpt += 200.0; if (badpt < 100.0) badpt = 0.0; // Close enough! - if (d.date-indate < 5.0 || + if (game.state.date-indate < 5.0 || // killsPerDate >= RateMax - (d.killk+d.killc+d.nsckill)/(d.date-indate) >= + (game.state.killk+game.state.killc+game.state.nsckill)/(game.state.date-indate) >= 0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) { skip(1); prout("In fact, you have done so well that Starfleet Command"); @@ -150,7 +151,7 @@ void finish(FINTYPE ifin) { prout("conquered. Your starship is now Klingon property,"); prout("and you are put on trial as a war criminal. On the"); proutn("basis of your record, you are "); - if (d.remkl*3.0 > inkling) { + if (game.state.remkl*3.0 > inkling) { prout("aquitted."); skip(1); prout("LIVE LONG AND PROSPER."); @@ -275,9 +276,9 @@ void finish(FINTYPE ifin) { if (ship==IHF) ship= 0; else if (ship == IHE) ship = IHF; alive = 0; - if (d.remkl != 0) { - double goodies = d.remres/inresor; - double baddies = (d.remkl + 2.0*d.remcom)/(inkling+2.0*incom); + if (game.state.remkl != 0) { + double goodies = game.state.remres/inresor; + double baddies = (game.state.remkl + 2.0*game.state.remcom)/(inkling+2.0*incom); if (goodies/baddies >= 1.0+0.5*Rand()) { prout("As a result of your actions, a treaty with the Klingon"); prout("Empire has been signed. The terms of the treaty are"); @@ -303,62 +304,62 @@ void finish(FINTYPE ifin) { } void score(void) { - double timused = d.date - indate; + double timused = game.state.date - indate; int ithperd, iwon, klship; pause(0); iskill = skill; - if ((timused == 0 || d.remkl != 0) && timused < 5.0) timused = 5.0; - perdate = (d.killc + d.killk + d.nsckill)/timused; + if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0; + perdate = (game.state.killc + game.state.killk + game.state.nsckill)/timused; ithperd = 500*perdate + 0.5; iwon = 0; if (gamewon) iwon = 100*skill; if (ship == IHE) klship = 0; else if (ship == IHF) klship = 1; else klship = 2; - if (gamewon == 0) d.nromrem = 0; // None captured if no win - iscore = 10*d.killk + 50*d.killc + ithperd + iwon - - 100*d.basekl - 100*klship - 45*nhelp -5*d.starkl - casual - + 20*d.nromkl + 200*d.nsckill - 10*d.nplankl + d.nromrem; + if (gamewon == 0) game.state.nromrem = 0; // None captured if no win + iscore = 10*game.state.killk + 50*game.state.killc + ithperd + iwon + - 100*game.state.basekl - 100*klship - 45*nhelp -5*game.state.starkl - casual + + 20*game.state.nromkl + 200*game.state.nsckill - 10*game.state.nplankl + game.state.nromrem; if (alive == 0) iscore -= 200; skip(2); prout("Your score --"); - if (d.nromkl) - printf("%6d Romulans destroyed %5d\n", - d.nromkl,20*d.nromkl); - if (d.nromrem) - printf("%6d Romulans captured %5d\n", - d.nromrem, d.nromrem); - if (d.killk) - printf("%6d ordinary Klingons destroyed %5d\n", - d.killk, 10*d.killk); - if (d.killc) - printf("%6d Klingon commanders destroyed %5d\n", - d.killc, 50*d.killc); - if (d.nsckill) - printf("%6d Super-Commander destroyed %5d\n", - d.nsckill, 200*d.nsckill); + if (game.state.nromkl) + prout("%6d Romulans destroyed %5d", + game.state.nromkl,20*game.state.nromkl); + if (game.state.nromrem) + prout("%6d Romulans captured %5d", + game.state.nromrem, game.state.nromrem); + if (game.state.killk) + prout("%6d ordinary Klingons destroyed %5d", + game.state.killk, 10*game.state.killk); + if (game.state.killc) + prout("%6d Klingon commanders destroyed %5d", + game.state.killc, 50*game.state.killc); + if (game.state.nsckill) + prout("%6d Super-Commander destroyed %5d", + game.state.nsckill, 200*game.state.nsckill); if (ithperd) - printf("%6.2f Klingons per stardate %5d\n", + prout("%.2f Klingons per stardate %5d", perdate, ithperd); - if (d.starkl) - printf("%6d stars destroyed by your action %5d\n", - d.starkl, -5*d.starkl); - if (d.nplankl) - printf("%6d planets destroyed by your action %5d\n", - d.nplankl, -10*d.nplankl); - if (d.basekl) - printf("%6d bases destroyed by your action %5d\n", - d.basekl, -100*d.basekl); + if (game.state.starkl) + prout("%6d stars destroyed by your action %5d", + game.state.starkl, -5*game.state.starkl); + if (game.state.nplankl) + prout("%6d planets destroyed by your action %5d", + game.state.nplankl, -10*game.state.nplankl); + if (game.state.basekl) + prout("%6d bases destroyed by your action %5d", + game.state.basekl, -100*game.state.basekl); if (nhelp) - printf("%6d calls for help from starbase %5d\n", + prout("%6d calls for help from starbase %5d", nhelp, -45*nhelp); if (casual) - printf("%6d casualties incurred %5d\n", + prout("%6d casualties incurred %5d", casual, -casual); if (klship) - printf("%6d ship(s) lost or destroyed %5d\n", + prout("%6d ship(s) lost or destroyed %5d", klship, -100*klship); if (alive==0) prout("Penalty for getting yourself killed -200"); @@ -372,10 +373,10 @@ void score(void) { case 4: proutn("Expert game "); break; case 5: proutn("Emeritus game"); break; } - printf(" %5d\n", iwon); + prout(" %5d", iwon); } skip(2); - printf("TOTAL SCORE %5d\n", iscore); + prout("TOTAL SCORE %5d", iscore); } void plaque(void) { @@ -388,16 +389,16 @@ void plaque(void) { skip(2); while (fp == NULL) { - printf("File or device name for your plaque:"); + proutn("File or device name for your plaque:"); fgets(winner, 128, stdin); winner[strlen(winner)-1] = '\0'; fp = fopen(winner, "w"); if (fp==NULL) { - printf("Invalid name.\n"); + prout("Invalid name."); } } - printf("Enter name to go on plaque (up to 30 characters):"); + proutn("Enter name to go on plaque (up to 30 characters):"); fgets(winner, 128, stdin); winner[strlen(winner)-1] = '\0'; winner[30] = '\0';