+
+# Code from reports.c begins here
+
+def attackreport(curt):
+ # report status of bases under attack
+ if not curt:
+ if is_scheduled(FCDBAS):
+ prout(_("Starbase in Quadrant %s is currently under Commander attack.") % game.battle)
+ prout(_("It can hold out until Stardate %d.") % int(scheduled(FCDBAS)))
+ elif game.isatb == 1:
+ prout(_("Starbase in Quadrant %s is under Super-commander attack.") % game.state.kscmdr)
+ prout(_("It can hold out until Stardate %d.") % int(scheduled(FSCDBAS)))
+ else:
+ prout(_("No Starbase is currently under attack."))
+ else:
+ if is_scheduled(FCDBAS):
+ proutn(_("Base in %s attacked by C. Alive until %.1f") % (game.battle, scheduled(FCDBAS)))
+ if game.isatb:
+ proutn(_("Base in %s attacked by S. Alive until %.1f") % (game.state.kscmdr, scheduled(FSCDBAS)))
+ clreol()
+
+def report():
+ # report on general game status
+ chew()
+ s1 = "" and game.thawed and _("thawed ")
+ s2 = {1:"short", 2:"medium", 4:"long"}[game.length]
+ s3 = (None, _("novice"). _("fair"),
+ _("good"), _("expert"), _("emeritus"))[game.skill]
+ prout(_("You %s a %s%s %s game.") % ((_("were playing"), _("are playing"))[game.alldone], s1, s2, s3))
+ if game.skill>SKILL_GOOD and game.thawed and not game.alldone:
+ prout(_("No plaque is allowed."))
+ if game.tourn:
+ prout(_("This is tournament game %d.") % game.tourn)
+ prout(_("Your secret password is \"%s\"") % game.passwd)
+ proutn(_("%d of %d Klingons have been killed") % (((game.inkling + game.incom + game.inscom) - (game.state.remkl + game.state.remcom + game.state.nscrem)),
+ (game.inkling + game.incom + game.inscom)))
+ if game.incom - game.state.remcom:
+ prout(_(", including %d Commander%s.") % (game.incom - game.state.remcom, (_("s"), "")[(game.incom - game.state.remcom)==1]))
+ elif game.inkling - game.state.remkl + (game.inscom - game.state.nscrem) > 0:
+ prout(_(", but no Commanders."))
+ else:
+ prout(".")
+ if game.skill > SKILL_FAIR:
+ prout(_("The Super Commander has %sbeen destroyed.") % ("", _("not "))[game.state.nscrem])
+ if game.state.rembase != game.inbase:
+ proutn(_("There "))
+ if game.inbase-game.state.rembase==1:
+ proutn(_("has been 1 base"))
+ else:
+ proutn(_("have been %d bases") % (game.inbase-game.state.rembase))
+ prout(_(" destroyed, %d remaining.") % game.state.rembase)
+ else:
+ prout(_("There are %d bases.") % game.inbase)
+ if communicating() or game.iseenit:
+ # Don't report this if not seen and
+ # either the radio is dead or not at base!
+ attackreport(False)
+ game.iseenit = True
+ if game.casual:
+ prout(_("%d casualt%s suffered so far.") % (game.casual, ("y", "ies")[game.casual!=1]))
+ if game.nhelp:
+ prout(_("There were %d call%s for help.") % (game.nhelp, ("" , _("s"))[game.nhelp!=1]))
+ if game.ship == IHE:
+ proutn(_("You have "))
+ if game.nprobes:
+ proutn("%d" % (game.nprobes))
+ else:
+ proutn(_("no"))
+ proutn(_(" deep space probe"))
+ if game.nprobes!=1:
+ proutn(_("s"))
+ prout(".")
+ if communicating() and is_scheduled(FDSPROB):
+ if game.isarmed:
+ proutn(_("An armed deep space probe is in "))
+ else:
+ proutn(_("A deep space probe is in "))
+ prout("Quadrant %s." % game.probec)
+ if game.icrystl:
+ if game.cryprob <= .05:
+ prout(_("Dilithium crystals aboard ship... not yet used."))
+ else:
+ i=0
+ ai = 0.05
+ while game.cryprob > ai:
+ ai *= 2.0
+ i += 1
+ prout(_("Dilithium crystals have been used %d time%s.") % \
+ (i, (_("s"), "")[i==1]))
+ skip(1)
+
+def lrscan():
+ # long-range sensor scan
+ if damaged(DLRSENS):
+ # Now allow base's sensors if docked
+ if game.condition != "docked":
+ prout(_("LONG-RANGE SENSORS DAMAGED."))
+ return
+ prout(_("Starbase's long-range scan"))
+ else:
+ prout(_("Long-range scan"))
+ for x in range(game.quadrant.x-1, game.quadrant.x+2):
+ proutn(" ")
+ for y in range(game.quadrant.y-1, game.quadrant.y+2):
+ if not VALID_QUADRANT(x, y):
+ proutn(" -1")
+ else:
+ if not damaged(DRADIO):
+ game.state.galaxy[x][y].charted = True
+ game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons
+ game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase
+ game.state.chart[x][y].stars = game.state.galaxy[x][y].stars
+ if game.state.galaxy[x][y].supernova:
+ proutn(" ***")
+ else:
+ proutn(" %3d" % (game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars))
+ prout(" ")
+
+def damagereport():
+ # damage report
+ jdam = False
+ chew()
+
+ for i in range(NDEVICES):
+ if damaged(i):
+ if not jdam:
+ prout(_("\tDEVICE\t\t\t-REPAIR TIMES-"))
+ prout(_("\t\t\tIN FLIGHT\t\tDOCKED"))
+ jdam = True
+ prout(" %-26s\t%8.2f\t\t%8.2f" % (device[i],
+ game.damage[i]+0.05,
+ game.docfac*game.damage[i]+0.005))
+ if not jdam:
+ prout(_("All devices functional."))
+
+def rechart():
+ # update the chart in the Enterprise's computer from galaxy data
+ game.lastchart = game.state.date
+ for i in range(1, GALSIZE+1):
+ for j in range(1, GALSIZE+1):
+ if game.state.galaxy[i][j].charted:
+ game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons
+ game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase
+ game.state.chart[i][j].stars = game.state.galaxy[i][j].stars
+
+def chart():
+ # display the star chart
+ chew()
+ if not damaged(DRADIO):
+ rechart()
+ if game.lastchart < game.state.date and game.condition == "docked":
+ prout(_("Spock- \"I revised the Star Chart from the starbase's records.\""))
+ rechart()
+
+ prout(_(" STAR CHART FOR THE KNOWN GALAXY"))
+ if game.state.date > game.lastchart:
+ prout(_("(Last surveillance update %d stardates ago).") % ((int)(game.state.date-game.lastchart)))
+ prout(" 1 2 3 4 5 6 7 8")
+ for i in range(1, GALSIZE+1):
+ proutn("%d |" % (i))
+ for j in range(1, GALSIZE+1):
+ if (game.options & OPTION_SHOWME) and i == game.quadrant.x and j == game.quadrant.y:
+ proutn("<")
+ else:
+ proutn(" ")
+ if game.state.galaxy[i][j].supernova:
+ strcpy(buf, "***")
+ elif not game.state.galaxy[i][j].charted and game.state.galaxy[i][j].starbase:
+ strcpy(buf, ".1.")
+ elif game.state.galaxy[i][j].charted:
+ sprintf(buf, "%3d" % (game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars))
+ else:
+ strcpy(buf, "...")
+ proutn(buf)
+ if (game.options & OPTION_SHOWME) and i == game.quadrant.x and j == game.quadrant.y:
+ proutn(">")
+ else:
+ proutn(" ")
+ proutn(" |")
+ if i<GALSIZE:
+ skip(1)
+
+def sectscan(goodScan, i, j):
+ # light up an individual dot in a sector
+ if goodScan or (abs(i-game.sector.x)<= 1 and abs(j-game.sector.y) <= 1):
+ if (game.quad[i][j]==IHMATER0) or (game.quad[i][j]==IHMATER1) or (game.quad[i][j]==IHMATER2) or (game.quad[i][j]==IHE) or (game.quad[i][j]==IHF):
+ if game.condition == "red": textcolor(RED)
+ elif game.condition == "green": textcolor(GREEN)
+ elif game.condition == "yellow": textcolor(YELLOW)
+ elif game.condition == "docked": textcolor(CYAN)
+ elif game.condition == "dead": textcolor(BROWN)
+ if game.quad[i][j] != game.ship:
+ highvideo()
+ proutn("%c " % game.quad[i][j])
+ textcolor(DEFAULT)
+ else:
+ proutn("- ")
+
+def status(req):
+ # print status report lines
+
+ if not req or req == 1:
+ prstat(_("Stardate"), _("%.1f, Time Left %.2f") \
+ % (game.state.date, game.state.remtime))
+ elif not req or req == 2:
+ if game.condition != "docked":
+ newcnd()
+ dam = 0
+ for t in range(0, NDEVICES):
+ if game.damage[t]>0:
+ dam += 1
+ prstat(_("Condition"), _("%s, %i DAMAGES") % (game.condition.upper(), dam))
+ elif not req or req == 3:
+ prstat(_("Position"), "%s , %s" % (game.quadrant, game.sector))
+ elif not req or req == 4:
+ if damaged(DLIFSUP):
+ if game.condition == "docked":
+ sprintf(s, _("DAMAGED, Base provides"))
+ else:
+ sprintf(s, _("DAMAGED, reserves=%4.2f") % game.lsupres)
+ else:
+ sprintf(s, _("ACTIVE"))
+ prstat(_("Life Support"), s)
+ elif not req or req == 5:
+ prstat(_("Warp Factor"), "%.1f" % (game.warpfac))
+ elif not req or req == 6:
+ extra = ""
+ if game.icrystl and (game.options & OPTION_SHOWME):
+ extra = _(" (have crystals)")
+ prstat(_("Energy"), "%.2f%s" % game.energy, extra)
+ elif not req or req == 7:
+ prstat(_("Torpedoes"), "%d" % (game.torps))
+ elif not req or req == 8:
+ if damaged(DSHIELD):
+ strcpy(s, _("DAMAGED,"))
+ elif game.shldup:
+ strcpy(s, _("UP,"))
+ else:
+ strcpy(s, _("DOWN,"))
+ data = _(" %d%% %.1f units") \
+ % (int((100.0*game.shield)/game.inshld + 0.5), game.shield)
+ prstat(_("Shields"), s)
+ elif not req or req == 9:
+ prstat(_("Klingons Left"), "%d" \
+ % (game.state.remkl + game.state.remcom + game.state.nscrem))
+ elif not req or req == 10:
+ if game.options & OPTION_WORLDS:
+ plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet
+ if plnet != NOPLANET and game.state.planets[plnet].inhabited != UNINHABITED:
+ prstat(_("Major system"), plnet.name)
+ else:
+ prout(_("Sector is uninhabited"))
+ elif not req or req == 11:
+ attackreport(not req)
+
+def request():
+ requests = ("da","co","po","ls","wa","en","to","sh","kl","sy", "ti")
+ while scan() == IHEOL:
+ proutn(_("Information desired? "))
+ chew()
+ if citem in requests:
+ status(requests.index(citem))
+ else:
+ prout(_("UNRECOGNIZED REQUEST. Legal requests are:"))
+ prout((" date, condition, position, lsupport, warpfactor,"))
+ prout((" energy, torpedoes, shields, klingons, system, time."))
+
+def srscan():
+ # short-range scan
+ goodScan=True
+ if damaged(DSRSENS):
+ # Allow base's sensors if docked
+ if game.condition != "docked":
+ prout(_(" S.R. SENSORS DAMAGED!"))
+ goodScan=False
+ else:
+ prout(_(" [Using Base's sensors]"))
+ else:
+ prout(_(" Short-range scan"))
+ if goodScan and not damaged(DRADIO):
+ game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons
+ game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase
+ game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = True
+ prout(" 1 2 3 4 5 6 7 8 9 10")
+ if game.condition != "docked":
+ newcnd()
+ for i in range(1, QUADSIZE+1):
+ proutn("%2d " % (i))
+ for j in range(1, QUADSIZE+1):
+ sectscan(goodScan, i, j)
+ skip(1)
+
+
+def eta():
+ # use computer to get estimated time of arrival for a warp jump
+ w1 = coord(); w2 = coord()
+ prompt = False
+ if damaged(DCOMPTR):
+ prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."))
+ skip(1)
+ return
+ if scan() != IHREAL:
+ prompt = True
+ chew()
+ proutn(_("Destination quadrant and/or sector? "))
+ if scan()!=IHREAL:
+ huh()
+ return
+ w1.y = aaitem +0.5
+ if scan() != IHREAL:
+ huh()
+ return
+ w1.x = aaitem + 0.5
+ if scan() == IHREAL:
+ w2.y = aaitem + 0.5
+ if scan() != IHREAL:
+ huh()
+ return
+ w2.x = aaitem + 0.5
+ else:
+ if game.quadrant.y>w1.x:
+ w2.x = 1
+ else:
+ w2.x=QUADSIZE
+ if game.quadrant.x>w1.y:
+ w2.y = 1
+ else:
+ w2.y=QUADSIZE
+
+ if not VALID_QUADRANT(w1.x, w1.y) or not VALID_SECTOR(w2.x, w2.y):
+ huh()
+ return
+ game.dist = math.sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
+ square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)))
+ wfl = False
+
+ if prompt:
+ prout(_("Answer \"no\" if you don't know the value:"))
+ while True:
+ chew()
+ proutn(_("Time or arrival date? "))
+ if scan()==IHREAL:
+ ttime = aaitem
+ if ttime > game.state.date:
+ ttime -= game.state.date # Actually a star date
+ twarp=(math.floor(math.sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0
+ if ttime <= 1e-10 or twarp > 10:
+ prout(_("We'll never make it, sir."))
+ chew()
+ return
+ if twarp < 1.0:
+ twarp = 1.0
+ break
+ chew()
+ proutn(_("Warp factor? "))
+ if scan()== IHREAL:
+ wfl = True
+ twarp = aaitem
+ if twarp<1.0 or twarp > 10.0:
+ huh()
+ return
+ break
+ prout(_("Captain, certainly you can give me one of these."))
+ while True:
+ chew()
+ ttime = (10.0*game.dist)/square(twarp)
+ tpower = game.dist*twarp*twarp*twarp*(game.shldup+1)
+ if tpower >= game.energy:
+ prout(_("Insufficient energy, sir."))
+ if not game.shldup or tpower > game.energy*2.0:
+ if not wfl:
+ return
+ proutn(_("New warp factor to try? "))
+ if scan() == IHREAL:
+ wfl = True
+ twarp = aaitem
+ if twarp<1.0 or twarp > 10.0:
+ huh()
+ return
+ continue
+ else:
+ chew()
+ skip(1)
+ return
+ prout(_("But if you lower your shields,"))
+ proutn(_("remaining"))
+ tpower /= 2
+ else:
+ proutn(_("Remaining"))
+ prout(_(" energy will be %.2f.") % (game.energy-tpower))
+ if wfl:
+ prout(_("And we will arrive at stardate %.2f.") % (game.state.date+ttime))
+ elif twarp==1.0:
+ prout(_("Any warp speed is adequate."))
+ else:
+ prout(_("Minimum warp needed is %.2f,") % (twarp))
+ prout(_("and we will arrive at stardate %.2f.") % (game.state.date+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 (game.isatb==1 and game.state.kscmdr == w1 and \
+ scheduled(FSCDBAS)< ttime+game.state.date) or \
+ (scheduled(FCDBAS)<ttime+game.state.date and game.battle == w1):
+ prout(_("The starbase there will be destroyed by then."))
+ proutn(_("New warp factor to try? "))
+ if scan() == IHREAL:
+ wfl = True
+ twarp = aaitem
+ if twarp<1.0 or twarp > 10.0:
+ huh()
+ return
+ else:
+ chew()
+ skip(1)
+ return
+
+
+#ifdef BSD_BUG_FOR_BUG
+# A visual scan is made in a particular direction of three sectors
+# in the general direction specified. This takes time, and
+# Klingons can attack you, so it should be done only when sensors
+# are out. Code swiped from BSD-Trek. Not presently used, as we
+# automatically display all adjacent sectors on the short-range
+# scan even when short-range sensors are out.
+
+# This struct[] has the delta x, delta y for particular directions
+
+visdelta = (
+ (-1,-1),
+ (-1, 0),
+ (-1, 1),
+ (0, 1),
+ (1, 1),
+ (1, 0),
+ (1, -1),
+ (0, -1),
+ (-1,-1),
+ (-1, 0),
+ (-1, 1),
+)
+
+def visual():
+ v = coord()
+ if scan() != IHREAL:
+ chew()
+ proutn(_("Direction? "))
+ if scan()!=IHREAL:
+ huh()
+ return
+ if aaitem < 0.0 or aaitem > 360.0:
+ return
+ co = (aaitem + 22) / 45
+ v = visdelta[co]
+ ix = game.sector.x + v.x
+ iy = game.sector.y + v.y
+ if ix < 0 or ix >= QUADSIZE or iy < 0 or iy >= QUADSIZE:
+ co = '?'
+ else:
+ co = game.quad[ix][iy]
+ printf("%d,%d %c " % (ix, iy, co))
+ v += 1
+ ix = game.sector.x + v.x
+ iy = game.sector.y + v.y
+ if ix < 0 or ix >= QUADSIZE or iy < 0 or iy >= QUADSIZE:
+ co = '?'
+ else:
+ co = game.quad[ix][iy]
+ printf("%c " % (co))
+ v += 1
+ ix = game.sector.x + v.x
+ iy = game.sector.y + v.y
+ if ix < 0 or ix >= QUADSIZE or iy < 0 or iy >= QUADSIZE:
+ co = '?'
+ else:
+ co = game.quad[ix][iy]
+ prout("%c %d,%d\n" % (co, ix, iy))
+ game.optime = 0.5
+ game.ididit = True
+#endif