+
+# Code from finish.c ends here.
+
+def selfdestruct():
+ # self-destruct maneuver
+ # Finish with a BANG!
+ chew()
+ if damaged(DCOMPTR):
+ 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 game.passwd != citem:
+ 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()
+
+def kaboom():
+ stars()
+ if game.ship==IHE:
+ prouts("***")
+ prouts(_("********* Entropy of "))
+ crmshp()
+ prouts(_(" maximized *********"))
+ skip(1)
+ stars()
+ skip(1)
+ if game.nenhere != 0:
+ whammo = 25.0 * game.energy
+ l=1
+ while l <= game.nenhere:
+ if game.kpower[l]*game.kdist[l] <= whammo:
+ deadkl(game.ks[l], game.quad[game.ks[l].x][game.ks[l].y], game.ks[l])
+ l += 1
+ finish(FDILITHIUM)
+
+def killrate():
+ "Compute our rate of kils over time."
+ return ((game.inkling + game.incom + game.inscom) - (game.state.remkl + game.state.remcom + game.state.nscrem))/(game.state.date-game.indate)
+
+def badpoints():
+ "Compute demerits."
+ badpt = 5.0*game.state.starkl + \
+ game.casual + \
+ 10.0*game.state.nplankl + \
+ 300*game.state.nworldkl + \
+ 45.0*game.nhelp +\
+ 100.0*game.state.basekl +\
+ 3.0*game.abandoned
+ if game.ship == IHF:
+ badpt += 100.0
+ elif game.ship == None:
+ badpt += 200.0
+ return badpt
+
+
+def finish(ifin):
+ # end the game, with appropriate notfications
+ igotit = False
+ game.alldone = True
+ skip(3)
+ prout(_("It is stardate %.1f." % (game.state.date)))
+ skip(1)
+ if ifin == 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."))
+ game.gamewon = True
+ if game.alive:
+ badpt = badpoints()
+ if badpt < 100.0:
+ badpt = 0.0 # Close enough!
+ # killsPerDate >= RateMax
+ if game.state.date-game.indate < 5.0 or \
+ killrate() >= 0.1*game.skill*(game.skill+1.0) + 0.1 + 0.008*badpt:
+ skip(1)
+ prout(_("In fact, you have done so well that Starfleet Command"))
+ if game.skill == SKILL_NOVICE:
+ prout(_("promotes you one step in rank from \"Novice\" to \"Fair\"."))
+ elif game.skill == SKILL_FAIR:
+ prout(_("promotes you one step in rank from \"Fair\" to \"Good\"."))
+ elif game.skill == SKILL_GOOD:
+ prout(_("promotes you one step in rank from \"Good\" to \"Expert\"."))
+ elif game.skill == SKILL_EXPERT:
+ 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."))
+ elif game.skill == SKILL_EMERITUS:
+ 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)
+ elif game.skill >= SKILL_EXPERT:
+ if game.thawed and not idebug:
+ prout(_("You cannot get a citation, so..."))
+ else:
+ proutn(_("Do you want your Commodore Emeritus Citation printed? "))
+ chew()
+ if ja() == True:
+ igotit = True
+ # Only grant long life if alive (original didn't!)
+ skip(1)
+ prout(_("LIVE LONG AND PROSPER."))
+ score()
+ if igotit:
+ plaque()
+ return
+ elif ifin == 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 + game.state.remcom + game.state.nscrem)*3.0 > (game.inkling + game.incom + game.inscom):
+ prout(_("acquitted."))
+ skip(1)
+ prout(_("LIVE LONG AND PROSPER."))
+ else:
+ prout(_("found guilty and"))
+ prout(_("sentenced to death by slow torture."))
+ game.alive = False
+ score()
+ return
+ elif ifin == 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."))
+ elif ifin == FNRG:
+ prout(_("Your energy supply is exhausted."))
+ skip(1)
+ prout(_("Your starship is a derelict in space."))
+ elif ifin == FBATTLE:
+ proutn(_("The "))
+ crmshp()
+ prout(_("has been destroyed in battle."))
+ skip(1)
+ prout(_("Dulce et decorum est pro patria mori."))
+ elif ifin == 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()
+ elif ifin == FNOVA:
+ prout(_("Your starship has been destroyed by a nova."))
+ prout(_("That was a great shot."))
+ skip(1)
+ elif ifin == FSNOVAED:
+ proutn(_("The "))
+ crmshp()
+ prout(_(" has been fried by a supernova."))
+ prout(_("...Not even cinders remain..."))
+ elif ifin == 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."))
+ elif ifin == FDILITHIUM:
+ prout(_("Your starship is now an expanding cloud of subatomic particles"))
+ elif ifin == FMATERIALIZE:
+ prout(_("Starbase was unable to re-materialize your starship."))
+ prout(_("Sic transit gloria mundi"))
+ elif ifin == FPHASER:
+ proutn(_("The "))
+ crmshp()
+ prout(_(" has been cremated by its own phasers."))
+ elif ifin == FLOST:
+ prout(_("You and your landing party have been"))
+ prout(_("converted to energy, disipating through space."))
+ elif ifin == 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."))
+ elif ifin == FDPLANET:
+ prout(_("You and your mining party perish."))
+ skip(1)
+ prout(_("That was a great shot."))
+ skip(1)
+ elif ifin == FSSC:
+ prout(_("The Galileo is instantly annihilated by the supernova."))
+ 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."))
+ elif ifin == 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."))
+ elif ifin == 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."))
+ elif ifin == 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."))
+ elif ifin == 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."))
+ elif ifin == FHOLE:
+ prout(_("Your ship is drawn to the center of the black hole."))
+ prout(_("You are crushed into extremely dense matter."))
+ elif ifin == FCREW:
+ prout(_("Your last crew member has died."))
+ if game.ship == IHF:
+ game.ship = None
+ elif game.ship == IHE:
+ game.ship = IHF
+ game.alive = False
+ if (game.state.remkl + game.state.remcom + game.state.nscrem) != 0:
+ goodies = game.state.remres/game.inresor
+ baddies = (game.state.remkl + 2.0*game.state.remcom)/(game.inkling+2.0*game.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."))
+ game.gamewon = True
+ score()
+
+def score():
+ # compute player's score
+ timused = game.state.date - game.indate
+
+ iskill = game.skill
+ if (timused == 0 or (game.state.remkl + game.state.remcom + game.state.nscrem) != 0) and timused < 5.0:
+ timused = 5.0
+ perdate = killrate()
+ ithperd = 500*perdate + 0.5
+ iwon = 0
+ if game.gamewon:
+ iwon = 100*game.skill
+ if game.ship == IHE:
+ klship = 0
+ elif game.ship == IHF:
+ klship = 1
+ else:
+ klship = 2
+ if not game.gamewon:
+ game.state.nromrem = 0 # None captured if no win
+ iscore = 10*(game.inkling - game.state.remkl) \
+ + 50*(game.incom - game.state.remcom) \
+ + ithperd + iwon \
+ + 20*(game.inrom - game.state.nromrem) \
+ + 200*(game.inscom - game.state.nscrem) \
+ - game.state.nromrem \
+ - badpoints()
+ if not game.alive:
+ iscore -= 200
+ skip(2)
+ prout(_("Your score --"))
+ if game.inrom - game.state.nromrem:
+ prout(_("%6d Romulans destroyed %5d" %
+ (game.inrom - game.state.nromrem, 20*(game.inrom - game.state.nromrem))))
+ if game.state.nromrem:
+ prout(_("%6d Romulans captured %5d" %
+ (game.state.nromrem, game.state.nromrem)))
+ if game.inkling - game.state.remkl:
+ prout(_("%6d ordinary Klingons destroyed %5d" %
+ (game.inkling - game.state.remkl, 10*(game.inkling - game.state.remkl))))
+ if game.incom - game.state.remcom:
+ prout(_("%6d Klingon commanders destroyed %5d" %
+ (game.incom - game.state.remcom, 50*(game.incom - game.state.remcom))))
+ if game.inscom - game.state.nscrem:
+ prout(_("%6d Super-Commander destroyed %5d" %
+ (game.inscom - game.state.nscrem, 200*(game.inscom - game.state.nscrem))))
+ 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.options & OPTION_WORLDS) and 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)))
+ if game.nhelp:
+ prout(_("%6d calls for help from starbase %5d" %
+ (game.nhelp, -45*game.nhelp)))
+ 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 not game.alive:
+ prout(_("Penalty for getting yourself killed -200"))
+ if game.gamewon:
+ proutn(_("Bonus for winning "))
+ if game.skill == SKILL_NOVICE: proutn(_("Novice game "))
+ elif game.skill == SKILL_FAIR: proutn(_("Fair game "))
+ elif game.skill == SKILL_GOOD: proutn(_("Good game "))
+ elif game.skill == SKILL_EXPERT: proutn(_("Expert game "))
+ elif game.skill == SKILL_EMERITUS: proutn(_("Emeritus game"))
+ prout(" %5d" % (iwon))
+ skip(1)
+ prout(_("TOTAL SCORE %5d" % iscore))
+
+def plaque():
+ # emit winner's commemmorative plaque
+ skip(2)
+ while True:
+ proutn(_("File or device name for your plaque: "))
+ cgetline(winner, sizeof(winner))
+ try:
+ fp = open(winner, "w")
+ break
+ except IOError:
+ prout(_("Invalid name."))
+
+ proutn(_("Enter name to go on plaque (up to 30 characters): "))
+ cgetline(winner, sizeof(winner))
+ # The 38 below must be 64 for 132-column paper
+ nskip = 38 - len(winner)/2
+
+ fp.write("\n\n\n\n")
+ # --------DRAW ENTERPRISE PICTURE.
+ fp.write(" EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" )
+ fp.write(" EEE E : : : E\n" )
+ fp.write(" EE EEE E : : NCC-1701 : E\n")
+ fp.write("EEEEEEEEEEEEEEEE EEEEEEEEEEEEEEE : : : E\n")
+ fp.write(" E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n")
+ fp.write(" EEEEEEEEE EEEEEEEEEEEEE E E\n")
+ fp.write(" EEEEEEE EEEEE E E E E\n")
+ fp.write(" EEE E E E E\n")
+ fp.write(" E E E E\n")
+ fp.write(" EEEEEEEEEEEEE E E\n")
+ fp.write(" EEE : EEEEEEE EEEEEEEE\n")
+ fp.write(" :E : EEEE E\n")
+ fp.write(" .-E -:----- E\n")
+ fp.write(" :E : E\n")
+ fp.write(" EE : EEEEEEEE\n")
+ fp.write(" EEEEEEEEEEEEEEEEEEEEEEE\n")
+ fp.write("\n\n\n")
+ fp.write(_(" U. S. S. ENTERPRISE\n"))
+ fp.write("\n\n\n\n")
+ fp.write(_(" For demonstrating outstanding ability as a starship captain\n"))
+ fp.write("\n")
+ fp.write(_(" Starfleet Command bestows to you\n"))
+ fp.write("\n")
+ fp.write("%*s%s\n\n" % (nskip, "", winner))
+ fp.write(_(" the rank of\n\n"))
+ fp.write(_(" \"Commodore Emeritus\"\n\n"))
+ fp.write(" ")
+ if game.skill == SKILL_EXPERT:
+ fp.write(_(" Expert level\n\n"))
+ elif game.skill == SKILL_EMERITUS:
+ fp.write(_("Emeritus level\n\n"))
+ else:
+ fp.write(_(" Cheat level\n\n"))
+ timestring = ctime()
+ fp.write(_(" This day of %.6s %.4s, %.8s\n\n" %
+ (timestring+4, timestring+20, timestring+11)))
+ fp.write(_(" Your score: %d\n\n" % iscore))
+ fp.write(_(" Klingons per stardate: %.2f\n" % perdate))
+ fp.close()
+
+# Code from io.c begins here
+
+rows = linecount = 0 # for paging
+stdscr = None
+fullscreen_window = None
+srscan_window = None
+report_window = None
+status_window = None
+lrscan_window = None
+message_window = None
+prompt_window = None
+
+def outro():
+ "wrap up, either normally or due to signal"
+ if game.options & OPTION_CURSES:
+ #clear()
+ #curs_set(1)
+ #refresh()
+ #resetterm()
+ #echo()
+ curses.endwin()
+ stdout.write('\n')
+ if logfp:
+ logfp.close()
+
+def iostart():
+ global stdscr
+ #setlocale(LC_ALL, "")
+ #bindtextdomain(PACKAGE, LOCALEDIR)
+ #textdomain(PACKAGE)
+ if atexit.register(outro):
+ sys.stderr.write("Unable to register outro(), exiting...\n")
+ os.exit(1)
+ if not (game.options & OPTION_CURSES):
+ ln_env = os.getenv("LINES")
+ if ln_env:
+ rows = ln_env
+ else:
+ rows = 25
+ else:
+ stdscr = curses.initscr()
+ stdscr.keypad(True)
+ #saveterm()
+ curses.nonl()
+ curses.cbreak()
+ curses.start_color()
+ curses.init_pair(curses.COLOR_BLACK, curses.COLOR_BLACK, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_GREEN, curses.COLOR_GREEN, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_RED, curses.COLOR_RED, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_CYAN, curses.COLOR_CYAN, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_WHITE, curses.COLOR_WHITE, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_MAGENTA, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_BLUE, curses.COLOR_BLUE, curses.COLOR_BLACK)
+ curses.init_pair(curses.COLOR_YELLOW, curses.COLOR_YELLOW, curses.COLOR_BLACK)
+ #noecho()
+ global fullscreen_window, srscan_window, report_window, status_window
+ global lrscan_window, message_window, prompt_window
+ fullscreen_window = stdscr
+ srscan_window = curses.newwin(12, 25, 0, 0)
+ report_window = curses.newwin(11, 0, 1, 25)
+ status_window = curses.newwin(10, 0, 1, 39)
+ lrscan_window = curses.newwin(5, 0, 0, 64)
+ message_window = curses.newwin(0, 0, 12, 0)
+ prompt_window = curses.newwin(1, 0, rows-2, 0)
+ message_window.scrollok(True)
+ setwnd(fullscreen_window)
+ textcolor(DEFAULT)
+
+
+def waitfor():
+ "wait for user action -- OK to do nothing if on a TTY"
+ if game.options & OPTION_CURSES:
+ stsdcr.getch()
+
+def announce():
+ skip(1)
+ if game.skill > SKILL_FAIR:
+ prouts(_("[ANOUNCEMENT ARRIVING...]"))
+ else:
+ prouts(_("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]"))
+ skip(1)
+
+def pause_game():
+ if game.skill > SKILL_FAIR:
+ prompt = _("[CONTINUE?]")
+ else:
+ prompt = _("[PRESS ENTER TO CONTINUE]")
+
+ if game.options & OPTION_CURSES:
+ drawmaps(0)
+ setwnd(prompt_window)
+ prompt_window.wclear()
+ prompt_window.addstr(prompt)
+ prompt_window.getstr()
+ prompt_window.clear()
+ prompt_window.refresh()
+ setwnd(message_window)
+ else:
+ global linecount
+ stdout.write('\n')
+ proutn(prompt)
+ raw_input()
+ for j in range(0, rows):
+ stdout.write('\n')
+ linecount = 0
+
+def skip(i):
+ "Skip i lines. Pause game if this would cause a scrolling event."
+ while dummy in range(i):
+ if game.options & OPTION_CURSES:
+ (y, x) = curwnd.getyx()
+ (my, mx) = curwnd.getmaxyx()
+ if curwnd == message_window and y >= my - 3:
+ pause_game()
+ clrscr()
+ else:
+ proutn("\n")
+ else:
+ global linecount
+ linecount += 1
+ if linecount >= rows:
+ pause_game()
+ else:
+ stdout.write('\n')
+
+def proutn(line):
+ "Utter a line with no following line feed."
+ if game.options & OPTION_CURSES:
+ curwnd.addstr(line)
+ curwnd.refresh()
+ else:
+ stdout.write(line)
+
+def prout(line):
+ proutn(line)
+ skip(1)
+
+def prouts(line):
+ "print slowly!"
+ for c in line:
+ curses.delay_output(30)
+ proutn(c)
+ if game.options & OPTION_CURSES:
+ wrefresh(curwnd)
+ else:
+ sys.stdout.flush()
+ curses.delay_output(300)
+
+def cgetline(line, max):
+ "Get a line of input."
+ if game.options & OPTION_CURSES:
+ line = curwnd.getstr() + "\n"
+ curwnd.refresh()
+ else:
+ if replayfp and not replayfp.closed:
+ line = replayfp.readline()
+ else:
+ sys.stdin.readline()
+ if logfp:
+ logfp.write(line)
+
+def setwnd(wnd):
+ "Change windows -- OK for this to be a no-op in tty mode."
+ if game.options & OPTION_CURSES:
+ curwnd = wnd
+ curses.curs_set(wnd == fullscreen_window or wnd == message_window or wnd == prompt_window)
+
+def clreol():
+ "Clear to end of line -- can be a no-op in tty mode"
+ if game.options & OPTION_CURSES:
+ wclrtoeol(curwnd)
+ wrefresh(curwnd)
+
+def clrscr():
+ "Clear screen -- can be a no-op in tty mode."
+ global linecount
+ if game.options & OPTION_CURSES:
+ curwnd.clear()
+ curwnd.move(0, 0)
+ curwnd.refresh()
+ linecount = 0
+
+def textcolor(color):
+ "Set the current text color"
+ if game.options & OPTION_CURSES:
+ if color == DEFAULT:
+ curwnd.attrset(0)
+ elif color == BLACK:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_BLACK))
+ elif color == BLUE:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_BLUE))
+ elif color == GREEN:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_GREEN))
+ elif color == CYAN:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_CYAN))
+ elif color == RED:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_RED))
+ elif color == MAGENTA:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_MAGENTA))
+ elif color == BROWN:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_YELLOW))
+ elif color == LIGHTGRAY:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_WHITE))
+ elif color == DARKGRAY:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_BLACK) | curses.A_BOLD)
+ elif color == LIGHTBLUE:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_BLUE) | curses.A_BOLD)
+ elif color == LIGHTGREEN:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_GREEN) | curses.A_BOLD)
+ elif color == LIGHTCYAN:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_CYAN) | curses.A_BOLD)
+ elif color == LIGHTRED:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_RED) | curses.A_BOLD)
+ elif color == LIGHTMAGENTA:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_MAGENTA) | curses.A_BOLD)
+ elif color == YELLOW:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_YELLOW) | curses.A_BOLD)
+ elif color == WHITE:
+ curwnd.attron(curses.COLOR_PAIR(curses.COLOR_WHITE) | curses.A_BOLD)
+
+def highvideo():
+ "Set highlight video, if this is reasonable."
+ if game.options & OPTION_CURSES:
+ curwnd.attron(curses.A_REVERSE)
+
+def commandhook(cmd, before):
+ pass
+
+#
+# Things past this point have policy implications.
+#
+
+def drawmaps(mode):
+ "Hook to be called after moving to redraw maps."
+ if game.options & OPTION_CURSES:
+ if mode == 1:
+ sensor()
+ setwnd(srscan_window)
+ curwnd.move(0, 0)
+ srscan()
+ if mode != 2:
+ setwnd(status_window)
+ status_window.clear()
+ status_window.move(0, 0)
+ setwnd(report_window)
+ report_window.clear()
+ report_window.move(0, 0)
+ status(0)
+ setwnd(lrscan_window)
+ lrscan_window.clear()
+ lrscan_window.move(0, 0)
+ lrscan()
+
+def put_srscan_sym(w, sym):
+ "Emit symbol for short-range scan."
+ srscan_window.move(w.x+1, w.y*2+2)
+ srscan_window.addch(sym)
+ srscan_window.refresh()
+
+def boom(w):
+ "Enemy fall down, go boom."
+ if game.options & OPTION_CURSES:
+ drawmaps(2)
+ setwnd(srscan_window)
+ srscan_window.attron(curses.A_REVERSE)
+ put_srscan_sym(w, game.quad[w.x][w.y])
+ #sound(500)
+ #delay(1000)
+ #nosound()
+ srscan_window.attroff(curses.A_REVERSE)
+ put_srscan_sym(w, game.quad[w.x][w.y])
+ curses.delay_output(500)
+ setwnd(message_window)
+
+def warble():
+ "Sound and visual effects for teleportation."
+ if game.options & OPTION_CURSES:
+ drawmaps(2)
+ setwnd(message_window)
+ #sound(50)
+ prouts(" . . . . . ")
+ if game.options & OPTION_CURSES:
+ #curses.delay_output(1000)
+ #nosound()
+ pass
+
+def tracktorpedo(w, l, i, n, iquad):
+ "Torpedo-track animation."
+ if not game.options & OPTION_CURSES:
+ if l == 1:
+ if n != 1:
+ skip(1)
+ proutn(_("Track for torpedo number %d- " % i))
+ else:
+ skip(1)
+ proutn(_("Torpedo track- "))
+ elif l==4 or l==9:
+ skip(1)
+ proutn("%d - %d " % (w.x, w.y))
+ else:
+ if not damaged(DSRSENS) or game.condition=="docked":
+ if i != 1 and l == 1:
+ drawmaps(2)
+ curses.delay_output(400)
+ if (iquad==IHDOT) or (iquad==IHBLANK):
+ put_srscan_sym(w, '+')
+ #sound(l*10)
+ #curses.delay_output(100)
+ #nosound()
+ put_srscan_sym(w, iquad)
+ else:
+ curwnd.attron(curses.A_REVERSE)
+ put_srscan_sym(w, iquad)
+ #sound(500)
+ #curses.delay_output(1000)
+ #nosound()
+ curwnd.attroff(curses.A_REVERSE)
+ put_srscan_sym(w, iquad)
+ else:
+ proutn("%d - %d " % (w.x, w.y))
+
+def makechart():
+ "Display the current galaxy chart."
+ if game.options & OPTION_CURSES:
+ setwnd(message_window)
+ message_window.clear()
+ chart()
+ if game.options & OPTION_TTY:
+ skip(1)
+
+NSYM = 14
+
+def prstat(txt, data):
+ proutn(txt)
+ if game.options & OPTION_CURSES:
+ skip(1)
+ setwnd(status_window)
+ else:
+ proutn(" " * NSYM - len(tx))
+ vproutn(data)
+ skip(1)
+ if game.options & OPTION_CURSES:
+ setwnd(report_window)