X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=reports.c;h=858c70cb479f66689b0b5b3ff3a3fda391658fa2;hp=afed60a5aaaea88811f3dfbd2c5477a88dff3bf1;hb=d5826a672dd4afc591476655b4905cb6542cd89c;hpb=e1d80424873d901a732bf81c3a7ecc564636375e diff --git a/reports.c b/reports.c index afed60a..858c70c 100644 --- a/reports.c +++ b/reports.c @@ -4,21 +4,17 @@ #include void attakreport(void) { - if (future[FCDBAS] < 1e30) { - proutn("Starbase in "); - cramlc(1, batx, baty); - prout(" is currently under attack."); - proutn("It can hold out until Stardate "); - cramf(future[FCDBAS], 0,1); - prout("."); + if (game.future[FCDBAS] < 1e30) { + prout("Starbase in %s is currently under attack.", + cramlc(quadrant, batx, baty)); + prout("It can hold out until Stardate %d.", + (int)game.future[FCDBAS]); } if (isatb == 1) { - proutn("Starbase in "); - cramlc(1, state.isx, state.isy); - prout(" is under Super-commander attack."); - proutn("It can hold out until Stardate "); - cramf(future[FSCDBAS], 0, 1); - prout("."); + prout("Starbase in %s is under Super-commander attack.", + cramlc(quadrant, game.state.isx, game.state.isy)); + prout("It can hold out until Stardate %d.", + (int)game.future[FSCDBAS]); } } @@ -42,56 +38,53 @@ void report(int f) { case 5: s3="emeritus"; break; default: s3="skilled"; break; } - printf("\nYou %s playing a %s%s %s frozen.\n", + prout(""); + prout("You %s playing a %s%s %s game.", alldone? "were": "are now", s1, s2, s3); if (skill>3 && thawed && !alldone) prout("No plaque is allowed."); - if (tourn) printf("This is tournament game %d.\n", tourn); - if (f) printf("Your secret password is \"%s\"\n",passwd); - printf("%d of %d Klingons have been killed", - state.killk+state.killc+state.nsckill, inkling); - if (state.killc) printf(", including %d Commander%s.\n", state.killc, state.killc==1?"":"s"); - else if (state.killk+state.nsckill > 0) prout(", but no Commanders."); + if (tourn) prout("This is tournament game %d.", tourn); + if (f) prout("Your secret password is \"%s\"",game.passwd); + proutn("%d of %d Klingons have been killed", + game.state.killk+game.state.killc+game.state.nsckill, inkling); + if (game.state.killc) prout(", including %d Commander%s.", game.state.killc, game.state.killc==1?"":"s"); + else if (game.state.killk+game.state.nsckill > 0) prout(", but no Commanders."); else prout("."); - if (skill > 2) printf("The Super Commander has %sbeen destroyed.\n", - state.nscrem?"not ":""); - if (state.rembase != inbase) { + if (skill > 2) prout("The Super Commander has %sbeen destroyed.", + game.state.nscrem?"not ":""); + if (game.state.rembase != inbase) { proutn("There "); - if (inbase-state.rembase==1) proutn("has been 1 base"); + if (inbase-game.state.rembase==1) proutn("has been 1 base"); else { - proutn("have been "); - crami(inbase-state.rembase, 1); - proutn(" bases"); + proutn("have been %d bases", inbase-game.state.rembase); } - proutn(" destroyed, "); - crami(state.rembase, 1); - prout(" remaining."); + prout(" destroyed, %d remaining.", game.state.rembase); } - else printf("There are %d bases.\n", inbase); - if (damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) { + else prout("There are %d bases.", inbase); + if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) { /* Don't report this if not seen and either the radio is dead or not at base! */ attakreport(); iseenit = 1; } - if (casual) printf("%d casualt%s suffered so far.\n", + if (casual) prout("%d casualt%s suffered so far.", casual, casual==1? "y" : "ies"); - if (nhelp) printf("There were %d call%s for help.\n", + if (nhelp) prout("There were %d call%s for help.", nhelp, nhelp==1 ? "" : "s"); if (ship == IHE) { proutn("You have "); - if (nprobes) crami(nprobes,1); + if (nprobes) proutn("%d", nprobes); else proutn("no"); proutn(" deep space probe"); if (nprobes!=1) proutn("s"); prout("."); } - if ((damage[DRADIO] == 0.0 || condit == IHDOCKED)&& - future[FDSPROB] != 1e30) { + if ((game.damage[DRADIO] == 0.0 || condit == IHDOCKED)&& + game.future[FDSPROB] != 1e30) { if (isarmed) proutn("An armed deep space probe is in"); else proutn("A deep space probe is in"); - cramlc(1, probecx, probecy); + proutn(cramlc(quadrant, probecx, probecy)); prout("."); } if (icrystl) { @@ -104,7 +97,7 @@ void report(int f) { ai *= 2.0; i++; } - printf("Dilithium crystals have been used %d time%s.\n", + prout("Dilithium crystals have been used %d time%s.", i, i==1? "" : "s"); } } @@ -114,7 +107,7 @@ void report(int f) { void lrscan(void) { int x, y; chew(); - if (damage[DLRSENS] != 0.0) { + if (game.damage[DLRSENS] != 0.0) { /* Now allow base's sensors if docked */ if (condit != IHDOCKED) { prout("LONG-RANGE SENSORS DAMAGED."); @@ -127,15 +120,14 @@ void lrscan(void) { skip(1); proutn("Long-range scan for"); } - cramlc(1, quadx, quady); - skip(1); + prout(cramlc(quadrant, quadx, quady)); for (x = quadx-1; x <= quadx+1; x++) { for (y = quady-1; y <= quady+1; y++) { if (x == 0 || x > 8 || y == 0 || y > 8) - printf(" -1"); + proutn(" -1"); else { - printf("%5d", state.galaxy[x][y]); - starch[x][y] = damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1; + proutn("%5d", game.state.galaxy[x][y]); + game.starch[x][y] = game.damage[DRADIO] > 0 ? game.state.galaxy[x][y]+1000 :1; } } putchar('\n'); @@ -147,19 +139,18 @@ void dreprt(void) { int jdam = FALSE, i; chew(); - for (i = 1; i <= ndevice; i++) { - if (damage[i] > 0.0) { + for (i = 1; i <= NDEVICES; i++) { + if (game.damage[i] > 0.0) { if (!jdam) { skip(1); prout("DEVICE -REPAIR TIMES-"); prout(" IN FLIGHT DOCKED"); jdam = TRUE; } - printf(" %16s ", device[i]); - cramf(damage[i]+0.05, 8, 2); - proutn(" "); - cramf(docfac*damage[i]+0.005, 8, 2); - skip(1); + prout(" %16s %8.2f %8.2f", + device[i], + game.damage[i]+0.05, + docfac*game.damage[i]+0.005); } } if (!jdam) prout("All devices functional."); @@ -170,7 +161,7 @@ void chart(int nn) { chew(); skip(1); - if (stdamtim != 1e30 && stdamtim != state.date && condit == IHDOCKED) { + if (stdamtim != 1e30 && stdamtim != game.state.date && condit == IHDOCKED) { prout("Spock- \"I revised the Star Chart from the"); prout(" starbase's records.\""); skip(1); @@ -179,43 +170,40 @@ void chart(int nn) { if (stdamtim != 1e30) { if (condit == IHDOCKED) { /* We are docked, so restore chart from base information */ - stdamtim = state.date; + stdamtim = game.state.date; for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) - if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000; + if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000; } else { - proutn("(Last surveillance update "); - cramf(state.date-stdamtim, 0, 1); - prout(" stardates ago.)"); + proutn("(Last surveillance update %d stardates ago.", + (int)(game.state.date-stdamtim)); } } if (nn ==0) skip(1); prout(" 1 2 3 4 5 6 7 8"); prout(" ----------------------------------------"); - if (nn==0) prout(" -"); + /* if (nn==0) prout(" -"); */ for (i = 1; i <= 8; i++) { - printf("%d -", i); + proutn("%d -", i); for (j = 1; j <= 8; j++) { - if (starch[i][j] < 0) - printf(" .1."); - else if (starch[i][j] == 0) - printf(" ..."); - else if (starch[i][j] > 999) - printf("%5d", starch[i][j]-1000); + if (game.starch[i][j] < 0) + proutn(" .1."); + else if (game.starch[i][j] == 0) + proutn(" ..."); + else if (game.starch[i][j] > 999) + proutn("%5d", game.starch[i][j]-1000); else - printf("%5d", state.galaxy[i][j]); + proutn("%5d", game.state.galaxy[i][j]); } prout(" -"); } if (nn == 0) { skip(1); crmshp(); - proutn(" is currently in"); - cramlc(1, quadx, quady); - skip(1); - } + prout(" is currently in %s", cramlc(quadrant, quadx, quady)); +} } @@ -227,7 +215,7 @@ void srscan(int l) { int goodScan=TRUE; switch (l) { case 1: // SRSCAN - if (damage[DSRSENS] != 0) { + if (game.damage[DSRSENS] != 0) { /* Allow base's sensors if docked */ if (condit != IHDOCKED) { prout("SHORT-RANGE SENSORS DAMAGED"); @@ -237,8 +225,8 @@ void srscan(int l) { prout("[Using starbase's sensors]"); } if (goodScan) - starch[quadx][quady] = damage[DRADIO]>0.0 ? - state.galaxy[quadx][quady]+1000:1; + game.starch[quadx][quady] = game.damage[DRADIO]>0.0 ? + game.state.galaxy[quadx][quady]+1000:1; scan(); if (isit("chart")) nn = TRUE; if (isit("no")) rightside = FALSE; @@ -247,7 +235,7 @@ void srscan(int l) { break; case 2: // REQUEST while (scan() == IHEOL) - printf("Information desired? "); + proutn("Information desired? "); chew(); for (k = 1; k <= 10; k++) if (strncmp(citem,requests[k],min(2,strlen(citem)))==0) @@ -267,18 +255,18 @@ void srscan(int l) { for (i = 1; i <= 10; i++) { int jj = (k!=0 ? k : i); if (leftside) { - printf("%2d ", i); + proutn("%2d ", i); for (j = 1; j <= 10; j++) { if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1)) - printf("%c ",quad[i][j]); + proutn("%c ",game.quad[i][j]); else - printf("- "); + proutn("- "); } } if (rightside) { switch (jj) { case 1: - printf(" Stardate %.1f", state.date); + proutn(" Stardate %.1f", game.state.date); break; case 2: if (condit != IHDOCKED) newcnd(); @@ -288,50 +276,50 @@ void srscan(int l) { case IHYELLOW: cp = "YELLOW"; break; case IHDOCKED: cp = "DOCKED"; break; } - printf(" Condition %s", cp); + proutn(" Condition %s", cp); break; case 3: - printf(" Position "); - cramlc(0, quadx, quady); - putchar(','); - cramlc(0, sectx, secty); + proutn(" Position "); + proutn(cramlc(neither, quadx, quady)); + proutn(" , "); + proutn(cramlc(neither, sectx, secty)); break; case 4: - printf(" Life Support "); - if (damage[DLIFSUP] != 0.0) { + proutn(" Life Support "); + if (game.damage[DLIFSUP] != 0.0) { if (condit == IHDOCKED) - printf("DAMAGED, supported by starbase"); + proutn("DAMAGED, supported by starbase"); else - printf("DAMAGED, reserves=%4.2f", lsupres); + proutn("DAMAGED, reserves=%.2f", lsupres); } else - printf("ACTIVE"); + proutn("ACTIVE"); break; case 5: - printf(" Warp Factor %.1f", warpfac); + proutn(" Warp Factor %.1f", warpfac); break; case 6: - printf(" Energy %.2f", energy); + proutn(" Energy %.2f", energy); break; case 7: - printf(" Torpedoes %d", torps); + proutn(" Torpedoes %d", torps); break; case 8: - printf(" Shields "); - if (damage[DSHIELD] != 0) - printf("DAMAGED,"); + proutn(" Shields "); + if (game.damage[DSHIELD] != 0) + proutn("DAMAGED,"); else if (shldup) - printf("UP,"); + proutn("UP,"); else - printf("DOWN,"); - printf(" %d%% %.1f units", + proutn("DOWN,"); + proutn(" %d%% %.1f units", (int)((100.0*shield)/inshld + 0.5), shield); break; case 9: - printf(" Klingons Left %d", state.remkl); + proutn(" Klingons Left %d", game.state.remkl); break; case 10: - printf(" Time Left %.2f", state.remtime); + proutn(" Time Left %.2f", game.state.remtime); break; } @@ -347,7 +335,7 @@ void eta(void) { int key, ix1, ix2, iy1, iy2, prompt=FALSE; int wfl; double ttime, twarp, tpower; - if (damage[DCOMPTR] != 0.0) { + if (game.damage[DCOMPTR] != 0.0) { prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR."); skip(1); return; @@ -397,7 +385,7 @@ void eta(void) { proutn("Time or arrival date? "); if (scan()==IHREAL) { ttime = aaitem; - if (ttime > state.date) ttime -= state.date; // Actually a star date + if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date if (ttime <= 1e-10 || (twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) { prout("We'll never make it, sir."); @@ -450,31 +438,25 @@ void eta(void) { } else proutn("Remaining"); - proutn(" energy will be "); - cramf(energy-tpower, 1, 1); - prout("."); + prout(" energy will be %.2f.", energy-tpower); if (wfl) { - proutn("And we will arrive at stardate "); - cramf(state.date+ttime, 1, 1); - prout("."); + prout("And we will arrive at stardate %.2f.", + game.state.date+ttime); } else if (twarp==1.0) prout("Any warp speed is adequate."); else { - proutn("Minimum warp needed is "); - cramf(twarp, 1, 2); - skip(1); - proutn("and we will arrive at stardate "); - cramf(state.date+ttime, 1, 2); - prout("."); + prout("Minimum warp needed is %.2f,", twarp); + prout("and we will arrive at stardate %.2f.", + game.state.date+ttime); } - if (state.remtime < ttime) + if (game.state.remtime < ttime) prout("Unfortunately, the Federation will be destroyed by then."); if (twarp > 6.0) prout("You'll be taking risks at that speed, Captain"); - if ((isatb==1 && state.isy == ix1 && state.isx == iy1 && - future[FSCDBAS]< ttime+state.date)|| - (future[FCDBAS]