rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
idebug = True | game.idebug = True | def debugme(): "Access to the internals for debugging." proutn("Reset levels? ") if ja() == True: if game.energy < game.inenrg: game.energy = game.inenrg game.shield = game.inshld game.torps = game.intorps game.lsupres = game.inlsr proutn("Reset damage? ") if ja() == True: for i in range(NDEVICES): if game.damage[i] > ... |
s3 = (None, _("novice"). _("fair"), | s3 = (None, _("novice"), _("fair"), | def report(): # report on general game status scanner.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... |
self.future = [] for i_unused in range(NEVENTS): | self.future = [] i = NEVENTS while i > 0: i -= 1 | def __init__(self): self.options = None # Game options self.state = snapshot() # A snapshot structure self.snapsht = snapshot() # Last snapshot taken for time-travel purposes self.quad = None # contents of our quadrant self.damage = [0.0] * NDEVICES # damage encountered self.future = [] # future events for i_unused in... |
if ja() == False: | if not ja(): | def supercommander(): "Move the Super Commander." iq = coord(); sc = coord(); ibq = coord(); idelta = coord() basetbl = [] if game.idebug: prout("== SUPERCOMMANDER") # Decide on being active or passive avoid = ((game.incom - len(game.state.kcmdr) + game.inkling - game.state.remkl)/(game.state.date+0.01-game.indate) < 0... |
game.optime = course.time(warp=4) | game.optime = scourse.time(warp=4) | def nova(nov): "Star goes nova." ncourse = (0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5) newc = coord(); neighbor = coord(); bump = coord(0, 0) if withprob(0.05): # Wow! We've supernova'ed supernova(game.quadrant) return # handle initial nova game.quad[nov.i][nov.j] = '.' prout(crmena(False, '*', "sector", nov) ... |
for j_unused in range(rows): sys.stdout.write('\n') | sys.stdout.write('\n' * rows) | 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.clear() prompt_window.addstr(prompt) prompt_window.getstr() prompt_window.clear() prompt_window.refresh() setwnd(message... |
def imove(course=None, noattack=False): | def imove(icourse=None, noattack=False): | def imove(course=None, noattack=False): "Movement execution for warp, impulse, supernova, and tractor-beam events." w = coord() def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies:... |
if course.final.i < 0: course.final.i = -course.final.i | if icourse.final.i < 0: icourse.final.i = -icourse.final.i | def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies: finald = (w - enemy.location).distance() enemy.kavgd = 0.5 * (finald + enemy.kdist) # Stas Sergeev added the condition # that at... |
if course.final.j < 0: course.final.j = -course.final.j | if icourse.final.j < 0: icourse.final.j = -icourse.final.j | def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies: finald = (w - enemy.location).distance() enemy.kavgd = 0.5 * (finald + enemy.kdist) # Stas Sergeev added the condition # that at... |
if course.final.i >= GALSIZE*QUADSIZE: course.final.i = (GALSIZE*QUADSIZE*2) - course.final.i | if icourse.final.i >= GALSIZE*QUADSIZE: icourse.final.i = (GALSIZE*QUADSIZE*2) - icourse.final.i | def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies: finald = (w - enemy.location).distance() enemy.kavgd = 0.5 * (finald + enemy.kdist) # Stas Sergeev added the condition # that at... |
if course.final.j >= GALSIZE*QUADSIZE: course.final.j = (GALSIZE*QUADSIZE*2) - course.final.j | if icourse.final.j >= GALSIZE*QUADSIZE: icourse.final.j = (GALSIZE*QUADSIZE*2) - icourse.final.j | def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies: finald = (w - enemy.location).distance() enemy.kavgd = 0.5 * (finald + enemy.kdist) # Stas Sergeev added the condition # that at... |
game.quadrant = course.final.quadrant() game.sector = course.final.sector() | game.quadrant = icourse.final.quadrant() game.sector = icourse.final.sector() | def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies: finald = (w - enemy.location).distance() enemy.kavgd = 0.5 * (finald + enemy.kdist) # Stas Sergeev added the condition # that at... |
stopegy = 50.0*course.distance/game.optime | stopegy = 50.0*icourse.distance/game.optime | def check_collision(h): iquad = game.quad[h.i][h.j] if iquad != '.': # object encountered in flight path stopegy = 50.0*course.distance/game.optime if iquad in ('T', 'K', 'C', 'S', 'R', '?'): for enemy in game.enemies: if enemy.location == game.sector: break collision(rammed=False, enemy=enemy) return True elif iquad =... |
course.distance = course.distance*(scheduled(FTBEAM)-game.state.date)/game.optime + 0.1 | icourse.distance = icourse.distance*(scheduled(FTBEAM)-game.state.date)/game.optime + 0.1 | def check_collision(h): iquad = game.quad[h.i][h.j] if iquad != '.': # object encountered in flight path stopegy = 50.0*course.distance/game.optime if iquad in ('T', 'K', 'C', 'S', 'R', '?'): for enemy in game.enemies: if enemy.location == game.sector: break collision(rammed=False, enemy=enemy) return True elif iquad =... |
for m in range(course.moves): course.next() w = course.sector() if course.origin.quadrant() != course.location.quadrant(): | for m in range(icourse.moves): icourse.next() w = icourse.sector() if icourse.origin.quadrant() != icourse.location.quadrant(): | def check_collision(h): iquad = game.quad[h.i][h.j] if iquad != '.': # object encountered in flight path stopegy = 50.0*course.distance/game.optime if iquad in ('T', 'K', 'C', 'S', 'R', '?'): for enemy in game.enemies: if enemy.location == game.sector: break collision(rammed=False, enemy=enemy) return True elif iquad =... |
elif check_collision(w): | elif check_collision(icourse, w): | def check_collision(h): iquad = game.quad[h.i][h.j] if iquad != '.': # object encountered in flight path stopegy = 50.0*course.distance/game.optime if iquad in ('T', 'K', 'C', 'S', 'R', '?'): for enemy in game.enemies: if enemy.location == game.sector: break collision(rammed=False, enemy=enemy) return True elif iquad =... |
def warp(course, involuntary): | def warp(wcourse, involuntary): | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
if course==None: | if wcourse==None: | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
course = getcourse(isprobe=False) | wcourse = getcourse(isprobe=False) | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
if course.power(game.warpfac) >= game.energy: | if wcourse.power(game.warpfac) >= game.energy: | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
if not game.shldup or 0.5*course.power(game.warpfac) > game.energy: iwarp = (game.energy/(course.dist+0.05)) ** 0.333333333 | if not game.shldup or 0.5*wcourse.power(game.warpfac) > game.energy: iwarp = (game.energy/(wcourse.dist+0.05)) ** 0.333333333 | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
game.optime = course.time(game.warpfac) | game.optime = wcourse.time(game.warpfac) | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
prob = course.distance*(6.0-game.warpfac)**2/66.666666666 | prob = wcourse.distance*(6.0-game.warpfac)**2/66.666666666 | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
course.distance = randreal(course.distance) | wcourse.distance = randreal(wcourse.distance) | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
if 0.5*course.distance*math.pow(7.0,game.warpfac-10.0) > randreal(): | if 0.5*wcourse.distance*math.pow(7.0,game.warpfac-10.0) > randreal(): | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
for m_unused in range(course.moves): course.next() w = course.sector() | for m_unused in range(wcourse.moves): wcourse.next() w = wcourse.sector() | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
course.reset() | wcourse.reset() | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
game.energy -= course.power(game.warpfac) | game.energy -= wcourse.power(game.warpfac) | def warp(course, involuntary): "ove under warp drive." blooey = False; twarp = False if not involuntary: # Not WARPX entry game.ididit = False if game.damage[DWARPEN] > 10.0: scanner.chew() skip(1) prout(_("Engineer Scott- \"The warp engines are damaged, Sir.\"")) return if damaged(DWARPEN) and game.warpfac > 4.0: scan... |
for i_unused in range(3): game.passwd += chr(ord('a')+randrange(26)) | game.passwd += chr(ord('a')+randrange(26)) game.passwd += chr(ord('a')+randrange(26)) game.passwd += chr(ord('a')+randrange(26)) | def setpassword(): "Set the self-destruct password." if game.options & OPTION_PLAIN: while True: scanner.chew() proutn(_("Please type in a secret password- ")) scanner.next() game.passwd = scanner.token if game.passwd != None: break else: game.passwd = "" for i_unused in range(3): game.passwd += chr(ord('a')+randrange(... |
warp(course=None, involuntary=False) | warp(wcourse=None, involuntary=False) | def makemoves(): "Command-interpretation loop." clrscr() setwnd(message_window) while True: # command loop drawmaps(1) while True: # get a command hitme = False game.optime = game.justin = False scanner.chew() setwnd(prompt_window) clrscr() proutn("COMMAND> ") if scanner.next() == "IHEOL": if game.options & OPTION_CUR... |
pass class coord: | pass class Coord: | def _(str): return gettext.gettext(str) |
return coord(self.i+other.i, self.j+other.j) | return Coord(self.i+other.i, self.j+other.j) | def __add__(self, other): return coord(self.i+other.i, self.j+other.j) |
return coord(self.i-other.i, self.j-other.j) | return Coord(self.i-other.i, self.j-other.j) | def __sub__(self, other): return coord(self.i-other.i, self.j-other.j) |
return coord(self.i*other, self.j*other) | return Coord(self.i*other, self.j*other) | def __mul__(self, other): return coord(self.i*other, self.j*other) |
return coord(self.i*other, self.j*other) | return Coord(self.i*other, self.j*other) | def __rmul__(self, other): return coord(self.i*other, self.j*other) |
return coord(self.i/other, self.j/other) | return Coord(self.i/other, self.j/other) | def __div__(self, other): return coord(self.i/other, self.j/other) |
return coord(self.i % other, self.j % other) | return Coord(self.i % other, self.j % other) | def __mod__(self, other): return coord(self.i % other, self.j % other) |
return coord(self.i/other, self.j/other) | return Coord(self.i/other, self.j/other) | def __rdiv__(self, other): return coord(self.i/other, self.j/other) |
return coord(int(round(self.i)), int(round(self.j))) | return Coord(int(round(self.i)), int(round(self.j))) | def roundtogrid(self): return coord(int(round(self.i)), int(round(self.j))) |
if not other: other = coord(0, 0) | if not other: other = Coord(0, 0) | def distance(self, other=None): if not other: other = coord(0, 0) return math.sqrt((self.i - other.i)**2 + (self.j - other.j)**2) |
s = coord() | s = Coord() | def sgn(self): s = coord() if self.i == 0: s.i = 0 else: s.i = self.i / abs(self.i) if self.j == 0: s.j = 0 else: s.j = self.j / abs(self.j) return s |
s = coord() | s = Coord() | def scatter(self): s = coord() s.i = self.i + randrange(-1, 2) s.j = self.j + randrange(-1, 2) return s |
class planet: | class Planet: | def __str__(self): if self.i == None or self.j == None: return "Nowhere" return "%s - %s" % (self.i+1, self.j+1) |
self.quadrant = coord() | self.quadrant = Coord() | def __init__(self): self.name = None # string-valued if inhabited self.quadrant = coord() # quadrant located self.pclass = None # could be ""M", "N", "O", or "destroyed" self.crystals = "absent"# could be "mined", "present", "absent" self.known = "unknown" # could be "unknown", "known", "shuttle_down" self.inhabited = ... |
class quadrant: | class Quadrant: | def __str__(self): return self.name |
class page: | class Page: | def __init__(self): self.stars = 0 self.planet = None |
class snapshot: | class Snapshot: | def fill2d(size, fillfun): "Fill an empty list in 2D." lst = [] for i in range(size): lst.append([]) for j in range(size): lst[i].append(fillfun(i, j)) return lst |
self.kscmdr = coord() | self.kscmdr = Coord() | def __init__(self): self.snap = False # snapshot taken self.crew = 0 # crew complement |
self.galaxy = fill2d(GALSIZE, lambda i_unused, j_unused: quadrant()) | self.galaxy = fill2d(GALSIZE, lambda i_unused, j_unused: Quadrant()) | def __init__(self): self.snap = False # snapshot taken self.crew = 0 # crew complement |
self.chart = fill2d(GALSIZE, lambda i_unused, j_unused: page()) class event: | self.chart = fill2d(GALSIZE, lambda i_unused, j_unused: Page()) class Event: | def __init__(self): self.snap = False # snapshot taken self.crew = 0 # crew complement |
class enemy: | class Enemy: | def findevent(evtype): return game.future[evtype] |
self.location = coord() | self.location = Coord() | def __init__(self, type=None, loc=None, power=None): self.type = type self.location = coord() if loc: self.move(loc) self.power = power # enemy energy level game.enemies.append(self) |
self.location = coord() | self.location = Coord() | def move(self, loc): motion = (loc != self.location) if self.location.i is not None and self.location.j is not None: if motion: if self.type == 'T': game.quad[self.location.i][self.location.j] = '#' else: game.quad[self.location.i][self.location.j] = '.' if loc: self.location = copy.copy(loc) game.quad[self.location.i]... |
class gamestate: | class Gamestate: | def __repr__(self): return "<%s,%s.%f>" % (self.type, self.location, self.power) # For debugging |
self.state = snapshot() self.snapsht = snapshot() | self.state = Snapshot() self.snapsht = Snapshot() | def __init__(self): self.options = None # Game options self.state = snapshot() # A snapshot structure self.snapsht = snapshot() # Last snapshot taken for time-travel purposes self.quad = None # contents of our quadrant self.damage = [0.0] * NDEVICES # damage encountered self.future = [] # future events i = NEVENTS whil... |
self.future.append(event()) | self.future.append(Event()) | def __init__(self): self.options = None # Game options self.state = snapshot() # A snapshot structure self.snapsht = snapshot() # Last snapshot taken for time-travel purposes self.quad = None # contents of our quadrant self.damage = [0.0] * NDEVICES # damage encountered self.future = [] # future events i = NEVENTS whil... |
return iq.valid_quadrant() and \ | return iq.valid_Quadrant() and \ | def welcoming(iq): "Would this quadrant welcome another Klingon?" return iq.valid_quadrant() and \ not game.state.galaxy[iq.i][iq.j].supernova and \ game.state.galaxy[iq.i][iq.j].klingons < MAXKLQUAD |
iq = coord() | iq = Coord() | def tryexit(enemy, look, irun): "A bad guy attempts to bug out." iq = coord() iq.i = game.quadrant.i+(look.i+(QUADSIZE-1))/QUADSIZE - 1 iq.j = game.quadrant.j+(look.j+(QUADSIZE-1))/QUADSIZE - 1 if not welcoming(iq): return False; if enemy.type == 'R': return False; # Romulans cannot escape! if not irun: # avoid intrudi... |
goto = coord(); look = coord() | goto = Coord(); look = Coord() | def movebaddy(enemy): "Tactical movement for the bad guys." goto = coord(); look = coord() irun = False # This should probably be just (game.quadrant in game.state.kcmdr) + (game.state.kscmdr==game.quadrant) if game.skill >= SKILL_EXPERT: nbaddys = (((game.quadrant in game.state.kcmdr)*2 + (game.state.kscmdr==game.quad... |
iq = coord(); sc = coord(); ibq = coord(); idelta = coord() | iq = Coord(); sc = Coord(); ibq = Coord(); idelta = Coord() | def supercommander(): "Move the Super Commander." iq = coord(); sc = coord(); ibq = coord(); idelta = coord() basetbl = [] if game.idebug: prout("== SUPERCOMMANDER") # Decide on being active or passive avoid = ((game.incom - len(game.state.kcmdr) + game.inkling - game.state.remkl)/(game.state.date+0.01-game.indate) < 0... |
tid = coord() | tid = Coord() | def movetholian(): "Move the Tholian." if not game.tholian or game.justin: return tid = coord() if game.tholian.location.i == 0 and game.tholian.location.j == 0: tid.i = 0; tid.j = QUADSIZE-1 elif game.tholian.location.i == 0 and game.tholian.location.j == QUADSIZE-1: tid.i = QUADSIZE-1; tid.j = QUADSIZE-1 elif game.th... |
bumpto = coord(0, 0) | bumpto = Coord(0, 0) | def torpedo(origin, bearing, dispersion, number, nburst): "Let a photon torpedo fly" if not damaged(DSRSENS) or game.condition=="docked": setwnd(srscan_window) else: setwnd(message_window) ac = bearing + 0.25*dispersion # dispersion is a random variable bullseye = (15.0 - bearing)*0.5235988 track = course(bearing=ac, d... |
delta = coord() | delta = Coord() | def targetcheck(w): "Return None if target is invalid, otherwise return a course angle." if not w.valid_sector(): huh() return None delta = coord() # FIXME: C code this was translated from is wacky -- why the sign reversal? delta.j = (w.j - game.sector.j); delta.i = (game.sector.i - w.i); if delta == coord(0, 0): skip(... |
if delta == coord(0, 0): | if delta == Coord(0, 0): | def targetcheck(w): "Return None if target is invalid, otherwise return a course angle." if not w.valid_sector(): huh() return None delta = coord() # FIXME: C code this was translated from is wacky -- why the sign reversal? delta.j = (w.j - game.sector.j); delta.i = (game.sector.i - w.i); if delta == coord(0, 0): skip(... |
w = coord() | w = Coord() | def hittem(hits): "Register a phaser hit on Klingons and Romulans." kk = 0 w = coord() skip(1) for (k, wham) in enumerate(hits): if wham==0: continue dustfac = randreal(0.9, 1.0) hit = wham*math.pow(dustfac,game.enemies[kk].kdist) kpini = game.enemies[kk].power kp = math.fabs(kpini) if PHASEFAC*hit < kp: kp = PHASEFAC*... |
w = coord(); hold = coord() ev = event(); ev2 = event() | w = Coord(); hold = Coord() ev = Event(); ev2 = Event() | def events(): "Run through the event queue looking for things to do." i=0 fintim = game.state.date + game.optime; yank=0 ictbeam = False; istract = False w = coord(); hold = coord() ev = event(); ev2 = event() def tractorbeam(yank): "Tractor-beaming cases merge here." announce() game.optime = (10.0/(7.5*7.5))*yank # 7... |
except coord: | except Coord: | def destroybase(): "Code merges here for any commander destroying a starbase." # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.i][game.battle.j].starbase = False game.quad[game.base.i][game.base.j] = '.' game.base.... |
m = coord() | m = Coord() | def destroybase(): "Code merges here for any commander destroying a starbase." # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.i][game.battle.j].starbase = False game.quad[game.base.i][game.base.j] = '.' game.base.... |
newc = coord(); neighbor = coord(); bump = coord(0, 0) | newc = Coord(); neighbor = Coord(); bump = Coord(0, 0) | def nova(nov): "Star goes nova." ncourse = (0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5) newc = coord(); neighbor = coord(); bump = coord(0, 0) if withprob(0.05): # Wow! We've supernova'ed supernova(game.quadrant) return # handle initial nova game.quad[nov.i][nov.j] = '.' prout(crmena(False, '*', "sector", nov) ... |
offset = coord() | offset = Coord() | def nova(nov): "Star goes nova." ncourse = (0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5) newc = coord(); neighbor = coord(); bump = coord(0, 0) if withprob(0.05): # Wow! We've supernova'ed supernova(game.quadrant) return # handle initial nova game.quad[nov.i][nov.j] = '.' prout(crmena(False, '*', "sector", nov) ... |
nq = coord() | nq = Coord() | def supernova(w): "Star goes supernova." num = 0; npdead = 0 if w != None: nq = copy.copy(w) else: # Scheduled supernova -- select star at random. stars = 0 nq = coord() for nq.i in range(GALSIZE): for nq.j in range(GALSIZE): stars += game.state.galaxy[nq.i][nq.j].stars if stars == 0: return # nothing to supernova exis... |
ns = coord() | ns = Coord() | def supernova(w): "Star goes supernova." num = 0; npdead = 0 if w != None: nq = copy.copy(w) else: # Scheduled supernova -- select star at random. stars = 0 nq = coord() for nq.i in range(GALSIZE): for nq.j in range(GALSIZE): stars += game.state.galaxy[nq.i][nq.j].stars if stars == 0: return # nothing to supernova exis... |
w = coord() | w = Coord() | def imove(icourse=None, noattack=False): "Movement execution for warp, impulse, supernova, and tractor-beam events." w = coord() def newquadrant(noattack): # Leaving quadrant -- allow final enemy attack # Don't do it if being pushed by Nova if len(game.enemies) != 0 and not noattack: newcnd() for enemy in game.enemies... |
dsect = coord() | dsect = Coord() | def getcourse(isprobe): "Get a course and distance from the user." key = 0 dquad = copy.copy(game.quadrant) navmode = "unspecified" itemp = "curt" dsect = coord() iprompt = False if game.landed and not isprobe: prout(_("Dummy! You can't leave standard orbit until you")) proutn(_("are back aboard the ship.")) scanner.ch... |
delta = coord() | delta = Coord() | def getcourse(isprobe): "Get a course and distance from the user." key = 0 dquad = copy.copy(game.quadrant) navmode = "unspecified" itemp = "curt" dsect = coord() iprompt = False if game.landed and not isprobe: prout(_("Dummy! You can't leave standard orbit until you")) proutn(_("are back aboard the ship.")) scanner.ch... |
self.increment = coord(-math.sin(self.angle), math.cos(self.angle)) | self.increment = Coord(-math.sin(self.angle), math.cos(self.angle)) | def __init__(self, bearing, distance, origin=None): self.distance = distance self.bearing = bearing if origin is None: self.origin = cartesian(game.quadrant, game.sector) else: self.origin = origin # The bearing() code we inherited from FORTRAN is actually computing # clockface directions! if self.bearing < 0.0: self.b... |
if not coord(x, y).valid_quadrant(): | if not Coord(x, y).valid_quadrant(): | def lrscan(silent): "Long-range sensor scan." if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": if not silent: prout(_("LONG-RANGE SENSORS DAMAGED.")) return if not silent: prout(_("Starbase's long-range scan")) elif not silent: prout(_("Long-range scan")) for x in range(game.quad... |
w1 = coord(); w2 = coord() | w1 = Coord(); w2 = Coord() | 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 scanner.next() != "IHREAL": prompt = True scanner.chew() proutn(_("Destination quadrant and/or sector? ")) i... |
w = coord() | w = Coord() | def setup(): "Prepare to play, set up cosmos." w = coord() # Decide how many of everything if choose(): return # frozen game # Prepare the Enterprise game.alldone = game.gamewon = game.shldchg = game.shldup = False game.ship = 'E' game.state.crew = FULLCREW game.energy = game.inenrg = 5000.0 game.shield = game.inshld ... |
game.battle = coord() | game.battle = Coord() | def setup(): "Prepare to play, set up cosmos." w = coord() # Decide how many of everything if choose(): return # frozen game # Prepare the Enterprise game.alldone = game.gamewon = game.shldchg = game.shldup = False game.ship = 'E' game.state.crew = FULLCREW game.energy = game.inenrg = 5000.0 game.shield = game.inshld ... |
new = planet() | new = Planet() | def setup(): "Prepare to play, set up cosmos." w = coord() # Decide how many of everything if choose(): return # frozen game # Prepare the Enterprise game.alldone = game.gamewon = game.shldchg = game.shldup = False game.ship = 'E' game.state.crew = FULLCREW game.energy = game.inenrg = 5000.0 game.shield = game.inshld ... |
return enemy('K', loc=dropin(), power=randreal(300,450)+25.0*game.skill) | return Enemy('K', loc=dropin(), power=randreal(300,450)+25.0*game.skill) | def newkling(): "Drop new Klingon into current quadrant." return enemy('K', loc=dropin(), power=randreal(300,450)+25.0*game.skill) |
enemy('R', loc=dropin(), power=randreal(400.0,850.0)+50.0*game.skill) | Enemy('R', loc=dropin(), power=randreal(400.0,850.0)+50.0*game.skill) | def newqad(): "Set up a new state of quadrant, for when we enter or re-enter it." game.justin = True game.iplnet = None game.neutz = game.inorbit = game.landed = False game.ientesc = game.iseenit = False # Create a blank quadrant game.quad = fill2d(QUADSIZE, lambda i, j: '.') if game.iscate: # Attempt to escape Super-c... |
enemy(type='?', loc=dropin(), | Enemy(type='?', loc=dropin(), | def newqad(): "Set up a new state of quadrant, for when we enter or re-enter it." game.justin = True game.iplnet = None game.neutz = game.inorbit = game.landed = False game.ientesc = game.iseenit = False # Create a blank quadrant game.quad = fill2d(QUADSIZE, lambda i, j: '.') if game.iscate: # Attempt to escape Super-c... |
w = coord() | w = Coord() | def newqad(): "Set up a new state of quadrant, for when we enter or re-enter it." game.justin = True game.iplnet = None game.neutz = game.inorbit = game.landed = False game.ientesc = game.iseenit = False # Create a blank quadrant game.quad = fill2d(QUADSIZE, lambda i, j: '.') if game.iscate: # Attempt to escape Super-c... |
game.tholian = enemy(type='T', loc=w, | game.tholian = Enemy(type='T', loc=w, | def newqad(): "Set up a new state of quadrant, for when we enter or re-enter it." game.justin = True game.iplnet = None game.neutz = game.inorbit = game.landed = False game.ientesc = game.iseenit = False # Create a blank quadrant game.quad = fill2d(QUADSIZE, lambda i, j: '.') if game.iscate: # Attempt to escape Super-c... |
w = coord() | w = Coord() | def randplace(size): "Choose a random location." w = coord() w.i = randrange(size) w.j = randrange(size) return w |
s = coord() | s = Coord() | def getcoord(self): s = coord() scanner.next() if scanner.type != "IHREAL": huh() return None |
ev = event() w = coord() | ev = Event() w = Coord() | def debugme(): "Access to the internals for debugging." proutn("Reset levels? ") if ja(): if game.energy < game.inenrg: game.energy = game.inenrg game.shield = game.inshld game.torps = game.intorps game.lsupres = game.inlsr proutn("Reset damage? ") if ja(): for i in range(NDEVICES): if game.damage[i] > 0.0: game.damage... |
thing = coord() | thing = Coord() | def debugme(): "Access to the internals for debugging." proutn("Reset levels? ") if ja(): if game.energy < game.inenrg: game.energy = game.inenrg game.shield = game.inshld game.torps = game.intorps game.lsupres = game.inlsr proutn("Reset damage? ") if ja(): for i in range(NDEVICES): if game.damage[i] > 0.0: game.damage... |
game = gamestate() | game = Gamestate() | def debugme(): "Access to the internals for debugging." proutn("Reset levels? ") if ja(): if game.energy < game.inenrg: game.energy = game.inenrg game.shield = game.inshld game.torps = game.intorps game.lsupres = game.inlsr proutn("Reset damage? ") if ja(): for i in range(NDEVICES): if game.damage[i] > 0.0: game.damage... |
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0: | if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)<=0: | def torps(): "Launch photon torpedo salvo." course = [] game.ididit = False if damaged(DPHOTON): prout(_("Photon tubes damaged.")) scanner.chew() return if game.torps == 0: prout(_("No torpedoes left.")) scanner.chew() return # First, get torpedo count while True: scanner.next() if scanner.token == "IHALPHA": huh() ret... |
if curwnd == message_window and y >= my - 3: | if curwnd == message_window and y >= my - 2: | def skip(i): "Skip i lines. Pause game if this would cause a scrolling event." for 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: try: curwnd.move(y+1, 0) except curses.error: pass else: g... |
prout(" ") | if not silent: prout(" ") | def lrscan(silent): "Long-range sensor scan." if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": if not silent: prout(_("LONG-RANGE SENSORS DAMAGED.")) return if not silent: prout(_("Starbase's long-range scan")) elif not silent: prout(_("Long-range scan")) for x in range(game.quad... |
scanner.chew() | def setwarp(): "Change the warp factor." while True: key=scanner.next() if key != "IHEOL": break scanner.chew() proutn(_("Warp factor- ")) scanner.chew() if key != "IHREAL": huh() return if game.damage[DWARPEN] > 10.0: prout(_("Warp engines inoperative.")) return if damaged(DWARPEN) and scanner.real > 4.0: prout(_("Eng... | |
scanner.chew() | def selfdestruct(): "Self-destruct maneuver. Finish with a BANG!" scanner.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) pro... | |
for base in game.state.baseq: | for (i, base) in enumerate(game.state.baseq): | def supercommander(): "Move the Super Commander." iq = Coord(); sc = Coord(); ibq = Coord(); idelta = Coord() basetbl = [] if game.idebug: prout("== SUPERCOMMANDER") # Decide on being active or passive avoid = ((game.incom - len(game.state.kcmdr) + game.inkling - game.state.remkl)/(game.state.date+0.01-game.indate) < 0... |
tracktorpedo(origin, w, step, number, nburst, iquad) | tracktorpedo(w, step, number, nburst, iquad) | def torpedo(origin, bearing, dispersion, number, nburst): "Let a photon torpedo fly" if not damaged(DSRSENS) or game.condition=="docked": setwnd(srscan_window) else: setwnd(message_window) ac = bearing + 0.25*dispersion # dispersion is a random variable bullseye = (15.0 - bearing)*0.5235988 track = course(bearing=ac, d... |
1000.0 * (w-origin).distance() * math.fabs(math.sin(bullseye-angle)) | 1000.0 * (w-origin).distance() * math.fabs(math.sin(bullseye-track.angle)) | def torpedo(origin, bearing, dispersion, number, nburst): "Let a photon torpedo fly" if not damaged(DSRSENS) or game.condition=="docked": setwnd(srscan_window) else: setwnd(message_window) ac = bearing + 0.25*dispersion # dispersion is a random variable bullseye = (15.0 - bearing)*0.5235988 track = course(bearing=ac, d... |
raise ibq | raise JumpOut | def destroybase(): "Code merges here for any commander destroying a starbase." # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.i][game.battle.j].starbase = False game.quad[game.base.i][game.base.j] = '.' game.base.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.