-#include "sst.h"\r
-#include <string.h>\r
-#include <time.h>\r
-\r
-void dstrct() {\r
- /* Finish with a BANG! */\r
- chew();\r
- if (damage[DCOMPTR] != 0.0) {\r
- prout("Computer damaged; cannot execute destruct sequence.");\r
- return;\r
- }\r
- skip(1);\r
- prouts("---WORKING---"); skip(1);\r
- prout("SELF-DESTRUCT-SEQUENCE-ACTIVATED");\r
- prouts(" 10"); skip(1);\r
- prouts(" 9"); skip(1);\r
- prouts(" 8"); skip(1);\r
- prouts(" 7"); skip(1);\r
- prouts(" 6"); skip(1);\r
- prout("ENTER-CORRECT-PASSWORD-TO-CONTINUE-");\r
- prout("SELF-DESTRUCT-SEQUENCE-OTHERWISE-");\r
- prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED");\r
- scan();\r
- chew();\r
- if (strcmp(passwd, citem) != 0) {\r
- prouts("PASSWORD-REJECTED;"); skip(1);\r
- prout("CONTINUITY-EFFECTED");\r
- skip(1);\r
- return;\r
- }\r
- prouts("PASSWORD-ACCEPTED"); skip(1);\r
- prouts(" 5"); skip(1);\r
- prouts(" 4"); skip(1);\r
- prouts(" 3"); skip(1);\r
- prouts(" 2"); skip(1);\r
- prouts(" 1"); skip(1);\r
- if (Rand() < 0.15) {\r
- prouts("GOODBYE-CRUEL-WORLD");\r
- skip(1);\r
- }\r
- skip(2);\r
- kaboom();\r
-}\r
-\r
-void kaboom(void) {\r
- stars();\r
- if (ship==IHE) prouts("***");\r
- prouts("********* Entropy of ");\r
- crmshp();\r
- prouts(" maximized *********");\r
- skip(1);\r
- stars();\r
- skip(1);\r
- if (nenhere != 0) {\r
- double whammo = 25.0 * energy;\r
- int l=1;\r
- while (l <= nenhere) {\r
- if (kpower[l]*kdist[l] <= whammo) \r
- deadkl(kx[l],ky[l], quad[kx[l]][ky[l]], kx[l], ky[l]);\r
- l++;\r
- }\r
- }\r
- finish(FDILITHIUM);\r
-}\r
- \r
-\r
-void finish(FINTYPE ifin) {\r
- int igotit = 0;\r
- alldone = 1;\r
- skip(3);\r
- printf("It is stardate %.1f .\n\n", d.date);\r
- switch (ifin) {\r
- case FWON: // Game has been won\r
- if (d.nromrem != 0)\r
- printf("The remaining %d Romulans surrender to Starfleet Command.\n",\r
- d.nromrem);\r
- \r
- prout("You have smashed the Klingon invasion fleet and saved");\r
- prout("the Federation.");\r
- gamewon=1;\r
- if (alive) {\r
- double badpt;\r
- badpt = 5.*d.starkl + casual + 10.*d.nplankl +\r
- 45.*nhelp+100.*d.basekl;\r
- if (ship == IHF) badpt += 100.0;\r
- else if (ship == 0) badpt += 200.0;\r
- if (badpt < 100.0) badpt = 0.0; // Close enough!\r
- if (d.date-indate < 5.0 ||\r
- // killsPerDate >= RateMax\r
- (d.killk+d.killc+d.nsckill)/(d.date-indate) >=\r
- 0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {\r
- skip(1);\r
- prout("In fact, you have done so well that Starfleet Command");\r
- switch (skill) {\r
- case 1:\r
- prout("promotes you one step in rank from \"Novice\" to \"Fair\".");\r
- break;\r
- case 2:\r
- prout("promotes you one step in rank from \"Fair\" to \"Good\".");\r
- break;\r
- case 3:\r
- prout("promotes you one step in rank from \"Good\" to \"Expert\".");\r
- break;\r
- case 4:\r
- prout("promotes you to Commodore Emeritus.");\r
- skip(1);\r
- prout("Now that you think you're really good, try playing");\r
- prout("the \"Emeritus\" game. It will splatter your ego.");\r
- break;\r
- case 5:\r
- skip(1);\r
- prout("Computer- ERROR-ERROR-ERROR-ERROR");\r
- skip(1);\r
- prout(" YOUR-SKILL-HAS-EXCEEDED-THE-CAPACITY-OF-THIS-PROGRAM");\r
- prout(" THIS-PROGRAM-MUST-SURVIVE");\r
- prout(" THIS-PROGRAM-MUST-SURVIVE");\r
- prout(" THIS-PROGRAM-MUST-SURVIVE");\r
- prout(" THIS-PROGRAM-MUST?- MUST ? - SUR? ? -? VI");\r
- skip(1);\r
- prout("Now you can retire and write your own Star Trek game!");\r
- skip(1);\r
- break;\r
- }\r
- if (skill > 3) {\r
- if (thawed\r
-#ifdef DEBUG\r
- && !idebug\r
-#endif\r
- )\r
- prout("You cannot get a citation, so...");\r
- else {\r
- prout("Do you want your Commodore Emeritus Citation printed?");\r
- proutn("(You need a 132 column printer.)");\r
- chew();\r
- if (ja()) {\r
- igotit = 1;\r
- }\r
- }\r
- }\r
- }\r
- // Only grant long life if alive (original didn't!)\r
- skip(1);\r
- prout("LIVE LONG AND PROSPER.");\r
- }\r
- score();\r
- if (igotit != 0) plaque();\r
- return;\r
- case FDEPLETE: // Federation Resources Depleted\r
- prout("Your time has run out and the Federation has been");\r
- prout("conquered. Your starship is now Klingon property,");\r
- prout("and you are put on trial as a war criminal. On the");\r
- proutn("basis of your record, you are ");\r
- if (d.remkl*3.0 > inkling) {\r
- prout("aquitted.");\r
- skip(1);\r
- prout("LIVE LONG AND PROSPER.");\r
- }\r
- else {\r
- prout("found guilty and");\r
- prout("sentenced to death by slow torture.");\r
- alive = 0;\r
- }\r
- score();\r
- return;\r
- case FLIFESUP:\r
- prout("Your life support reserves have run out, and");\r
- prout("you die of thirst, starvation, and asphyxiation.");\r
- prout("Your starship is a derelict in space.");\r
- break;\r
- case FNRG:\r
- prout("Your energy supply is exhausted.");\r
- skip(1);\r
- prout("Your starship is a derelict in space.");\r
- break;\r
- case FBATTLE:\r
- proutn("The ");\r
- crmshp();\r
- prout("has been destroyed in battle.");\r
- skip(1);\r
- prout("Dulce et decorum est pro patria mori.");\r
- break;\r
- case FNEG3:\r
- prout("You have made three attempts to cross the negative energy");\r
- prout("barrier which surrounds the galaxy.");\r
- skip(1);\r
- prout("Your navigation is abominable.");\r
- score();\r
- return;\r
- case FNOVA:\r
- prout("Your starship has been destroyed by a nova.");\r
- prout("That was a great shot.");\r
- skip(1);\r
- break;\r
- case FSNOVAED:\r
- proutn("The ");\r
- crmshp();\r
- prout(" has been fried by a supernova.");\r
- prout("...Not even cinders remain...");\r
- break;\r
- case FABANDN:\r
- prout("You have been captured by the Klingons. If you still");\r
- prout("had a starbase to be returned to, you would have been");\r
- prout("repatriated and given another chance. Since you have");\r
- prout("no starbases, you will be mercilessly tortured to death.");\r
- break;\r
- case FDILITHIUM:\r
- prout("Your starship is now an expanding cloud of subatomic particles");\r
- break;\r
- case FMATERIALIZE:\r
- prout("Starbase was unable to re-materialize your starship.");\r
- prout("Sic transit gloria muntdi");\r
- break;\r
- case FPHASER:\r
- proutn("The ");\r
- crmshp();\r
- prout(" has been cremated by its own phasers.");\r
- break;\r
- case FLOST:\r
- prout("You and your landing party have been");\r
- prout("converted to energy, disipating through space.");\r
- break;\r
- case FMINING:\r
- prout("You are left with your landing party on");\r
- prout("a wild jungle planet inhabited by primitive cannibals.");\r
- skip(1);\r
- prout("They are very fond of \"Captain Kirk\" soup.");\r
- skip(1);\r
- proutn("Without your leadership, the ");\r
- crmshp();\r
- prout(" is destroyed.");\r
- break;\r
- case FDPLANET:\r
- prout("You and your mining party perish.");\r
- skip(1);\r
- prout("That was a great shot.");\r
- skip(1);\r
- break;\r
- case FSSC:\r
- prout("The Galileo is instantly annihilated by the supernova.");\r
- // no break;\r
- case FPNOVA:\r
- prout("You and your mining party are atomized.");\r
- skip(1);\r
- proutn("Mr. Spock takes command of the ");\r
- crmshp();\r
- prout(" and");\r
- prout("joins the Romulans, reigning terror on the Federation.");\r
- break;\r
- case FSTRACTOR:\r
- prout("The shuttle craft Galileo is also caught,");\r
- prout("and breaks up under the strain.");\r
- skip(1);\r
- prout("Your debris is scattered for millions of miles.");\r
- proutn("Without your leadership, the ");\r
- crmshp();\r
- prout(" is destroyed.");\r
- break;\r
- case FDRAY:\r
- prout("The mutants attack and kill Spock.");\r
- prout("Your ship is captured by Klingons, and");\r
- prout("your crew is put on display in a Klingon zoo.");\r
- break;\r
- case FTRIBBLE:\r
- prout("Tribbles consume all remaining water,");\r
- prout("food, and oxygen on your ship.");\r
- skip(1);\r
- prout("You die of thirst, starvation, and asphyxiation.");\r
- prout("Your starship is a derelict in space.");\r
- break;\r
- case FHOLE:\r
- prout("Your ship is drawn to the center of the black hole.");\r
- prout("You are crushed into extremely dense matter.");\r
- break;\r
- }\r
- if (ship==IHF) ship= 0;\r
- else if (ship == IHE) ship = IHF;\r
- alive = 0;\r
- if (d.remkl != 0) {\r
- double goodies = d.remres/inresor;\r
- double baddies = (d.remkl + 2.0*d.remcom)/(inkling+2.0*incom);\r
- if (goodies/baddies >= 1.0+0.5*Rand()) {\r
- prout("As a result of your actions, a treaty with the Klingon");\r
- prout("Empire has been signed. The terms of the treaty are");\r
- if (goodies/baddies >= 3.0+Rand()) {\r
- prout("favorable to the Federation.");\r
- skip(1);\r
- prout("Congratulations!");\r
- }\r
- else\r
- prout("highly unfavorable to the Federation.");\r
- }\r
- else\r
- prout("The Federation will be destroyed.");\r
- }\r
- else {\r
- prout("Since you took the last Klingon with you, you are a");\r
- prout("martyr and a hero. Someday maybe they'll erect a");\r
- prout("statue in your memory. Rest in peace, and try not");\r
- prout("to think about pigeons.");\r
- gamewon = 1;\r
- }\r
- score();\r
-}\r
-\r
-void score(void) {\r
- double timused = d.date - indate;\r
- int ithperd, iwon, klship;\r
-\r
- pause(0);\r
-\r
- iskill = skill;\r
- if ((timused == 0 || d.remkl != 0) && timused < 5.0) timused = 5.0;\r
- perdate = (d.killc + d.killk + d.nsckill)/timused;\r
- ithperd = 500*perdate + 0.5;\r
- iwon = 0;\r
- if (gamewon) iwon = 100*skill;\r
- if (ship == IHE) klship = 0;\r
- else if (ship == IHF) klship = 1;\r
- else klship = 2;\r
- if (gamewon == 0) d.nromrem = 0; // None captured if no win\r
- iscore = 10*d.killk + 50*d.killc + ithperd + iwon\r
- - 100*d.basekl - 100*klship - 45*nhelp -5*d.starkl - casual\r
- + 20*d.nromkl + 200*d.nsckill - 10*d.nplankl + d.nromrem;\r
- if (alive == 0) iscore -= 200;\r
- skip(2);\r
- prout("Your score --");\r
- if (d.nromkl)\r
- printf("%6d Romulans destroyed %5d\n",\r
- d.nromkl,20*d.nromkl);\r
- if (d.nromrem)\r
- printf("%6d Romulans captured %5d\n",\r
- d.nromrem, d.nromrem);\r
- if (d.killk)\r
- printf("%6d ordinary Klingons destroyed %5d\n",\r
- d.killk, 10*d.killk);\r
- if (d.killc)\r
- printf("%6d Klingon commanders destroyed %5d\n",\r
- d.killc, 50*d.killc);\r
- if (d.nsckill)\r
- printf("%6d Super-Commander destroyed %5d\n",\r
- d.nsckill, 200*d.nsckill);\r
- if (ithperd)\r
- printf("%6.2f Klingons per stardate %5d\n",\r
- perdate, ithperd);\r
- if (d.starkl)\r
- printf("%6d stars destroyed by your action %5d\n",\r
- d.starkl, -5*d.starkl);\r
- if (d.nplankl)\r
- printf("%6d planets destroyed by your action %5d\n",\r
- d.nplankl, -10*d.nplankl);\r
- if (d.basekl)\r
- printf("%6d bases destroyed by your action %5d\n",\r
- d.basekl, -100*d.basekl);\r
- if (nhelp)\r
- printf("%6d calls for help from starbase %5d\n",\r
- nhelp, -45*nhelp);\r
- if (casual)\r
- printf("%6d casualties incurred %5d\n",\r
- casual, -casual);\r
- if (klship)\r
- printf("%6d ship(s) lost or destroyed %5d\n",\r
- klship, -100*klship);\r
- if (alive==0)\r
- prout("Penalty for getting yourself killed -200");\r
- if (gamewon) {\r
- skip(1);\r
- proutn("Bonus for winning ");\r
- switch (skill) {\r
- case 1: proutn("Novice game "); break;\r
- case 2: proutn("Fair game "); break;\r
- case 3: proutn("Good game "); break;\r
- case 4: proutn("Expert game "); break;\r
- case 5: proutn("Emeritus game"); break;\r
- }\r
- printf(" %5d\n", iwon);\r
- }\r
- skip(2);\r
- printf("TOTAL SCORE %5d\n", iscore);\r
-}\r
-\r
-void plaque(void) {\r
- FILE *fp=NULL;\r
- time_t t;\r
- char *timestring;\r
- int nskip;\r
- char winner[128];\r
-\r
- skip(2);\r
- \r
- while (fp == NULL) {\r
- printf("File or device name for your plaque:");\r
- fgets(winner, 128, stdin);\r
- winner[strlen(winner)-1] = '\0';\r
- fp = fopen(winner, "w");\r
- if (fp==NULL) {\r
- printf("Invalid name.\n");\r
- }\r
- }\r
-\r
- printf("Enter name to go on plaque (up to 30 characters):");\r
- fgets(winner, 128, stdin);\r
- winner[strlen(winner)-1] = '\0';\r
- winner[30] = '\0';\r
- nskip = 64 - strlen(winner)/2;\r
-\r
- fprintf(fp,"\n\n\n\n");\r
- /* --------DRAW ENTERPRISE PICTURE. */\r
- fprintf(fp, " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" );\r
- fprintf(fp, " EEE E : : : E\n" );\r
- fprintf(fp, " EE EEE E : : NCC-1701 : E\n");\r
- fprintf(fp, " EEEEEEEEEEEEEEEE EEEEEEEEEEEEEEE E : : : E\n");\r
- fprintf(fp, " E E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n");\r
- fprintf(fp, " EEEEEEEEE EEEEEEEEEEEEE E E\n");\r
- fprintf(fp, " EEEEEEE EEEEE E E E E\n");\r
- fprintf(fp, " EEE E E E E\n");\r
- fprintf(fp, " E E E E\n");\r
- fprintf(fp, " EEEEEEEEEEEEE E E\n");\r
- fprintf(fp, " EEE : EEEEEEE EEEEEEEE\n");\r
- fprintf(fp, " :E : EEEE E\n");\r
- fprintf(fp, " .-E -:----- E\n");\r
- fprintf(fp, " :E : E\n");\r
- fprintf(fp, " EE : EEEEEEEE\n");\r
- fprintf(fp, " EEEEEEEEEEEEEEEEEEEEEEE\n");\r
- fprintf(fp, "\n\n\n");\r
- fprintf(fp, " U. S. S. ENTERPRISE\n");\r
- fprintf(fp, "\n\n\n\n");\r
- fprintf(fp, " For demonstrating outstanding ability as a starship captain\n");\r
- fprintf(fp, "\n");\r
- fprintf(fp, " Starfleet Command bestows to you\n");\r
- fprintf(fp, "\n");\r
- fprintf(fp,"%*s%s\n\n", nskip, "", winner);\r
- fprintf(fp, " the rank of\n\n");\r
- fprintf(fp, " \"Commodore Emeritus\"\n\n");\r
- fprintf(fp, " ");\r
- switch (iskill) {\r
- case 4: fprintf(fp," Expert level\n\n"); break;\r
- case 5: fprintf(fp,"Emeritus level\n\n"); break;\r
- default: fprintf(fp," Cheat level\n\n"); break;\r
- }\r
- t = time(NULL);\r
- timestring = ctime(&t);\r
- fprintf(fp, " This day of %.6s %.4s, %.8s\n\n",\r
- timestring+4, timestring+20, timestring+11);\r
- fprintf(fp," Your score: %d\n\n", iscore);\r
- fprintf(fp," Klingons per stardate: %.2f\n", perdate);\r
- fclose(fp);\r
-}\r
+#include "sst.h"
+#include <string.h>
+#include <time.h>
+
+void dstrct() {
+ /* Finish with a BANG! */
+ chew();
+ if (game.damage[DCOMPTR] != 0.0) {
+ prout("Computer damaged; cannot execute destruct sequence.");
+ return;
+ }
+ prouts("---WORKING---"); skip(1);
+ prouts("SELF-DESTRUCT-SEQUENCE-ACTIVATED"); skip(1);
+ prouts(" 10"); skip(1);
+ prouts(" 9"); skip(1);
+ prouts(" 8"); skip(1);
+ prouts(" 7"); skip(1);
+ prouts(" 6"); skip(1);
+ skip(1);
+ prout("ENTER-CORRECT-PASSWORD-TO-CONTINUE-");
+ skip(1);
+ prout("SELF-DESTRUCT-SEQUENCE-OTHERWISE-");
+ skip(1);
+ prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED");
+ skip(1);
+ scan();
+ chew();
+ if (strcmp(game.passwd, citem) != 0) {
+ prouts("PASSWORD-REJECTED;"); skip(1);
+ prouts("CONTINUITY-EFFECTED");
+ skip(2);
+ return;
+ }
+ prouts("PASSWORD-ACCEPTED"); skip(1);
+ prouts(" 5"); skip(1);
+ prouts(" 4"); skip(1);
+ prouts(" 3"); skip(1);
+ prouts(" 2"); skip(1);
+ prouts(" 1"); skip(1);
+ if (Rand() < 0.15) {
+ prouts("GOODBYE-CRUEL-WORLD");
+ skip(1);
+ }
+ kaboom();
+}
+
+void kaboom(void) {
+ stars();
+ if (ship==IHE) prouts("***");
+ prouts("********* Entropy of ");
+ crmshp();
+ prouts(" maximized *********");
+ skip(1);
+ stars();
+ skip(1);
+ if (nenhere != 0) {
+ double whammo = 25.0 * energy;
+ int l=1;
+ while (l <= nenhere) {
+ 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++;
+ }
+ }
+ finish(FDILITHIUM);
+}
+
+
+void finish(FINTYPE ifin) {
+ int igotit = 0;
+ alldone = 1;
+ skip(3);
+ prout("It is stardate %.1f.", game.state.date);
+ skip(1);
+ switch (ifin) {
+ case FWON: // Game has been won
+ 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.*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 (game.state.date-indate < 5.0 ||
+ // killsPerDate >= RateMax
+ (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");
+ switch (skill) {
+ case 1:
+ prout("promotes you one step in rank from \"Novice\" to \"Fair\".");
+ break;
+ case 2:
+ prout("promotes you one step in rank from \"Fair\" to \"Good\".");
+ break;
+ case 3:
+ prout("promotes you one step in rank from \"Good\" to \"Expert\".");
+ break;
+ case 4:
+ prout("promotes you to Commodore Emeritus.");
+ skip(1);
+ prout("Now that you think you're really good, try playing");
+ prout("the \"Emeritus\" game. It will splatter your ego.");
+ break;
+ case 5:
+ skip(1);
+ proutn("Computer- ");
+ prouts("ERROR-ERROR-ERROR-ERROR");
+ skip(2);
+ prouts(" YOUR-SKILL-HAS-EXCEEDED-THE-CAPACITY-OF-THIS-PROGRAM");
+ skip(1);
+ prouts(" THIS-PROGRAM-MUST-SURVIVE");
+ skip(1);
+ prouts(" THIS-PROGRAM-MUST-SURVIVE");
+ skip(1);
+ prouts(" THIS-PROGRAM-MUST-SURVIVE");
+ skip(1);
+ prouts(" THIS-PROGRAM-MUST?- MUST ? - SUR? ? -? VI");
+ skip(2);
+ prout("Now you can retire and write your own Star Trek game!");
+ skip(1);
+ break;
+ }
+ if (skill > 3) {
+ if (thawed
+#ifdef DEBUG
+ && !idebug
+#endif
+ )
+ prout("You cannot get a citation, so...");
+ else {
+ proutn("Do you want your Commodore Emeritus Citation printed? ");
+ chew();
+ if (ja()) {
+ igotit = 1;
+ }
+ }
+ }
+ }
+ // Only grant long life if alive (original didn't!)
+ skip(1);
+ prout("LIVE LONG AND PROSPER.");
+ }
+ score();
+ if (igotit != 0) plaque();
+ return;
+ case FDEPLETE: // Federation Resources Depleted
+ prout("Your time has run out and the Federation has been");
+ 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 (game.state.remkl*3.0 > inkling) {
+ prout("aquitted.");
+ skip(1);
+ prout("LIVE LONG AND PROSPER.");
+ }
+ else {
+ prout("found guilty and");
+ prout("sentenced to death by slow torture.");
+ alive = 0;
+ }
+ score();
+ return;
+ case FLIFESUP:
+ prout("Your life support reserves have run out, and");
+ prout("you die of thirst, starvation, and asphyxiation.");
+ prout("Your starship is a derelict in space.");
+ break;
+ case FNRG:
+ prout("Your energy supply is exhausted.");
+ skip(1);
+ prout("Your starship is a derelict in space.");
+ break;
+ case FBATTLE:
+ proutn("The ");
+ crmshp();
+ prout("has been destroyed in battle.");
+ skip(1);
+ prout("Dulce et decorum est pro patria mori.");
+ break;
+ case FNEG3:
+ prout("You have made three attempts to cross the negative energy");
+ prout("barrier which surrounds the galaxy.");
+ skip(1);
+ prout("Your navigation is abominable.");
+ score();
+ return;
+ case FNOVA:
+ prout("Your starship has been destroyed by a nova.");
+ prout("That was a great shot.");
+ skip(1);
+ break;
+ case FSNOVAED:
+ proutn("The ");
+ crmshp();
+ prout(" has been fried by a supernova.");
+ prout("...Not even cinders remain...");
+ break;
+ case FABANDN:
+ prout("You have been captured by the Klingons. If you still");
+ prout("had a starbase to be returned to, you would have been");
+ prout("repatriated and given another chance. Since you have");
+ prout("no starbases, you will be mercilessly tortured to death.");
+ break;
+ case FDILITHIUM:
+ prout("Your starship is now an expanding cloud of subatomic particles");
+ break;
+ case FMATERIALIZE:
+ prout("Starbase was unable to re-materialize your starship.");
+ prout("Sic transit gloria muntdi");
+ break;
+ case FPHASER:
+ proutn("The ");
+ crmshp();
+ prout(" has been cremated by its own phasers.");
+ break;
+ case FLOST:
+ prout("You and your landing party have been");
+ prout("converted to energy, disipating through space.");
+ break;
+ case FMINING:
+ prout("You are left with your landing party on");
+ prout("a wild jungle planet inhabited by primitive cannibals.");
+ skip(1);
+ prout("They are very fond of \"Captain Kirk\" soup.");
+ skip(1);
+ proutn("Without your leadership, the ");
+ crmshp();
+ prout(" is destroyed.");
+ break;
+ case FDPLANET:
+ prout("You and your mining party perish.");
+ skip(1);
+ prout("That was a great shot.");
+ skip(1);
+ break;
+ case FSSC:
+ prout("The Galileo is instantly annihilated by the supernova.");
+ // no break;
+ case FPNOVA:
+ prout("You and your mining party are atomized.");
+ skip(1);
+ proutn("Mr. Spock takes command of the ");
+ crmshp();
+ prout(" and");
+ prout("joins the Romulans, reigning terror on the Federation.");
+ break;
+ case FSTRACTOR:
+ prout("The shuttle craft Galileo is also caught,");
+ prout("and breaks up under the strain.");
+ skip(1);
+ prout("Your debris is scattered for millions of miles.");
+ proutn("Without your leadership, the ");
+ crmshp();
+ prout(" is destroyed.");
+ break;
+ case FDRAY:
+ prout("The mutants attack and kill Spock.");
+ prout("Your ship is captured by Klingons, and");
+ prout("your crew is put on display in a Klingon zoo.");
+ break;
+ case FTRIBBLE:
+ prout("Tribbles consume all remaining water,");
+ prout("food, and oxygen on your ship.");
+ skip(1);
+ prout("You die of thirst, starvation, and asphyxiation.");
+ prout("Your starship is a derelict in space.");
+ break;
+ case FHOLE:
+ prout("Your ship is drawn to the center of the black hole.");
+ prout("You are crushed into extremely dense matter.");
+ break;
+ }
+ if (ship==IHF) ship= 0;
+ else if (ship == IHE) ship = IHF;
+ alive = 0;
+ 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");
+ if (goodies/baddies >= 3.0+Rand()) {
+ prout("favorable to the Federation.");
+ skip(1);
+ prout("Congratulations!");
+ }
+ else
+ prout("highly unfavorable to the Federation.");
+ }
+ else
+ prout("The Federation will be destroyed.");
+ }
+ else {
+ prout("Since you took the last Klingon with you, you are a");
+ 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.");
+ gamewon = 1;
+ }
+ score();
+}
+
+void score(void) {
+ double timused = game.state.date - indate;
+ int ithperd, iwon, klship;
+
+ iskill = skill;
+ 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) 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 (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)
+ prout("%6.2f Klingons per stardate %5d",
+ perdate, ithperd);
+ 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)
+ prout("%6d calls for help from starbase %5d",
+ nhelp, -45*nhelp);
+ if (casual)
+ prout("%6d casualties incurred %5d",
+ casual, -casual);
+ if (klship)
+ prout("%6d ship(s) lost or destroyed %5d",
+ klship, -100*klship);
+ if (alive==0)
+ prout("Penalty for getting yourself killed -200");
+ if (gamewon) {
+ proutn("Bonus for winning ");
+ switch (skill) {
+ case 1: proutn("Novice game "); break;
+ case 2: proutn("Fair game "); break;
+ case 3: proutn("Good game "); break;
+ case 4: proutn("Expert game "); break;
+ case 5: proutn("Emeritus game"); break;
+ }
+ prout(" %5d", iwon);
+ }
+ skip(1);
+ prout("TOTAL SCORE %5d", iscore);
+}
+
+void plaque(void) {
+ FILE *fp=NULL;
+ time_t t;
+ char *timestring;
+ int nskip;
+ char winner[128];
+
+ skip(2);
+
+ while (fp == NULL) {
+ proutn("File or device name for your plaque: ");
+ getline(winner, sizeof(winner));
+ fp = fopen(winner, "w");
+ if (fp==NULL) {
+ prout("Invalid name.");
+ }
+ }
+
+ proutn("Enter name to go on plaque (up to 30 characters): ");
+ getline(winner, sizeof(winner));
+ /* The 38 below must be 64 for 132-column paper */
+ nskip = 38 - strlen(winner)/2;
+
+ fprintf(fp,"\n\n\n\n");
+ /* --------DRAW ENTERPRISE PICTURE. */
+ fprintf(fp, " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" );
+ fprintf(fp, " EEE E : : : E\n" );
+ fprintf(fp, " EE EEE E : : NCC-1701 : E\n");
+ fprintf(fp, "EEEEEEEEEEEEEEEE EEEEEEEEEEEEEEE : : : E\n");
+ fprintf(fp, " E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n");
+ fprintf(fp, " EEEEEEEEE EEEEEEEEEEEEE E E\n");
+ fprintf(fp, " EEEEEEE EEEEE E E E E\n");
+ fprintf(fp, " EEE E E E E\n");
+ fprintf(fp, " E E E E\n");
+ fprintf(fp, " EEEEEEEEEEEEE E E\n");
+ fprintf(fp, " EEE : EEEEEEE EEEEEEEE\n");
+ fprintf(fp, " :E : EEEE E\n");
+ fprintf(fp, " .-E -:----- E\n");
+ fprintf(fp, " :E : E\n");
+ fprintf(fp, " EE : EEEEEEEE\n");
+ fprintf(fp, " EEEEEEEEEEEEEEEEEEEEEEE\n");
+ fprintf(fp, "\n\n\n");
+ fprintf(fp, " U. S. S. ENTERPRISE\n");
+ fprintf(fp, "\n\n\n\n");
+ fprintf(fp, " For demonstrating outstanding ability as a starship captain\n");
+ fprintf(fp, "\n");
+ fprintf(fp, " Starfleet Command bestows to you\n");
+ fprintf(fp, "\n");
+ fprintf(fp,"%*s%s\n\n", nskip, "", winner);
+ fprintf(fp, " the rank of\n\n");
+ fprintf(fp, " \"Commodore Emeritus\"\n\n");
+ fprintf(fp, " ");
+ switch (iskill) {
+ case 4: fprintf(fp," Expert level\n\n"); break;
+ case 5: fprintf(fp,"Emeritus level\n\n"); break;
+ default: fprintf(fp," Cheat level\n\n"); break;
+ }
+ t = time(NULL);
+ timestring = ctime(&t);
+ fprintf(fp, " This day of %.6s %.4s, %.8s\n\n",
+ timestring+4, timestring+20, timestring+11);
+ fprintf(fp," Your score: %d\n\n", iscore);
+ fprintf(fp," Klingons per stardate: %.2f\n", perdate);
+ fclose(fp);
+}