IHMATER1 = 'o',
IHMATER2 = '0'
-IHEOL = '\n'
-IHREAL = 0.0
-IHALPHA = " "
-
class coord:
def __init__(self, x=None, y=None):
self.i = x
else:
motion = game.skill
# calculate preferred number of steps
- if motion < 0:
- nsteps = -motion
- else:
- nsteps = motion
+ nsteps = abs(int(motion))
if motion > 0 and nsteps > mdist:
nsteps = mdist; # don't overshoot
if nsteps > QUADSIZE:
m.i = 0
if 2.0 * abs(m.j) < abs(game.sector.i-enemy.kloc.i):
m.j = 0
- if m.i != 0:
- if m.i*motion < 0:
- m.i = -1
- else:
- m.i = 1
- if m.j != 0:
- if m.j*motion < 0:
- m.j = -1
- else:
- m.j = 1
+ m = (motion * m).sgn()
next = enemy.kloc
# main move loop
for ll in range(nsteps):
# Check if preferred position available
look = next + m
if m.i < 0:
- krawlx = 1
+ krawli = 1
else:
- krawlx = -1
+ krawli = -1
if m.j < 0:
- krawly = 1
+ krawlj = 1
else:
- krawly = -1
+ krawlj = -1
success = False
attempts = 0; # Settle mysterious hang problem
while attempts < 20 and not success:
if look.i < 0 or look.i >= QUADSIZE:
if motion < 0 and tryexit(enemy, look, irun):
return
- if krawlx == m.i or m.j == 0:
+ if krawli == m.i or m.j == 0:
break
- look.i = next.i + krawlx
- krawlx = -krawlx
+ look.i = next.i + krawli
+ krawli = -krawli
elif look.j < 0 or look.j >= QUADSIZE:
if motion < 0 and tryexit(enemy, look, irun):
return
- if krawly == m.j or m.i == 0:
+ if krawlj == m.j or m.i == 0:
break
- look.j = next.j + krawly
- krawly = -krawly
+ look.j = next.j + krawlj
+ krawlj = -krawlj
elif (game.options & OPTION_RAMMING) and game.quad[look.i][look.j] != IHDOT:
# See if enemy should ram ship
if game.quad[look.i][look.j] == game.ship and \
(enemy.type == IHC or enemy.type == IHS):
collision(rammed=True, enemy=enemy)
return
- if krawlx != m.i and m.j != 0:
- look.i = next.i + krawlx
- krawlx = -krawlx
- elif krawly != m.j and m.i != 0:
- look.j = next.j + krawly
- krawly = -krawly
+ if krawli != m.i and m.j != 0:
+ look.i = next.i + krawli
+ krawli = -krawli
+ elif krawlj != m.j and m.i != 0:
+ look.j = next.j + krawlj
+ krawlj = -krawlj
else:
break; # we have failed
else:
action = "SHUP"
else:
key = scanner.next()
- if key == IHALPHA:
+ if key == "IHALPHA":
if scanner.sees("transfer"):
action = "NRG"
else:
game.ididit = True
return
elif action == "NRG":
- while scanner.next() != IHREAL:
+ while scanner.next() != "IHREAL":
scanner.chew()
proutn(_("Energy to transfer to shields- "))
scanner.chew()
def torpedo(origin, course, dispersion, number, nburst):
"Let a photon torpedo fly"
+ if not damaged(DSRSENS) or game.condition=="docked":
+ setwnd(srscan_window)
+ else:
+ setwnd(message_window)
shoved = False
ac = course + 0.25*dispersion
angle = (15.0-ac)*0.5235988
delta = coord(-math.sin(angle), math.cos(angle))
bigger = max(abs(delta.i), abs(delta.j))
delta /= bigger
- x = origin.i; y = origin.j
w = coord(0, 0); jw = coord(0, 0)
- if not damaged(DSRSENS) or game.condition=="docked":
- setwnd(srscan_window)
- else:
- setwnd(message_window)
+ ungridded = copy.copy(origin)
# Loop to move a single torpedo
- for step in range(1, 15+1):
- x += delta.i
- y += delta.j
- w = coord(x, y).snaptogrid()
+ for step in range(1, QUADSIZE*2):
+ ungridded += delta
+ w = ungridded.snaptogrid()
if not VALID_SECTOR(w.i, w.j):
break
iquad=game.quad[w.i][w.j]
game.sector = jw
proutn(crmshp())
shoved = True
- elif iquad in (IHC, IHS): # Hit a commander
+ elif iquad in (IHC, IHS, IHR, IHK): # Hit a regular enemy
+ # find the enemy
if withprob(0.05):
prout(crmena(True, iquad, "sector", w) + _(" uses anti-photon device;"))
prout(_(" torpedo neutralized."))
return None
- elif iquad in (IHR, IHK): # Hit a regular enemy
- # find the enemy
for enemy in game.enemies:
if w == enemy.kloc:
break
# First, get torpedo count
while True:
scanner.next()
- if scanner.token == IHALPHA:
+ if scanner.token == "IHALPHA":
huh()
return
- elif scanner.token == IHEOL or not scanner.waiting():
+ elif scanner.token == "IHEOL" or not scanner.waiting():
prout(_("%d torpedoes left.") % game.torps)
scanner.chew()
proutn(_("Number of torpedoes to fire- "))
continue # Go back around to get a number
- else: # key == IHREAL
+ else: # key == "IHREAL"
n = scanner.int()
if n <= 0: # abort command
scanner.chew()
target = []
for i in range(n):
key = scanner.next()
- if i==0 and key == IHEOL:
+ if i==0 and key == "IHEOL":
break; # no coordinate waiting, we will try prompting
- if i==1 and key == IHEOL:
+ if i==1 and key == "IHEOL":
# direct all torpedoes at one target
while i < n:
- target.append(targets[0])
+ target.append(target[0])
course.append(course[0])
i += 1
break
- scanner.push(key)
+ scanner.push(scanner.token)
target.append(scanner.getcoord())
if target[-1] == None:
return
- course.append(targetcheck(target[1]))
- if course[i] == None:
+ course.append(targetcheck(target[-1]))
+ if course[-1] == None:
return
scanner.chew()
- if i == 0:
+ if len(target) == 0:
# prompt for each one
for i in range(n):
proutn(_("Target sector for torpedo number %d- ") % (i+1))
# (That was Tom Almy talking about the C code, I think -- ESR)
while automode=="NOTSET":
key=scanner.next()
- if key == IHALPHA:
+ if key == "IHALPHA":
if scanner.sees("manual"):
if len(game.enemies)==0:
prout(_("There is no enemy present to select."))
scanner.chew()
- key = IHEOL
+ key = "IHEOL"
automode="AUTOMATIC"
else:
automode = "MANUAL"
else:
huh()
return
- elif key == IHREAL:
+ elif key == "IHREAL":
if len(game.enemies)==0:
prout(_("Energy will be expended into space."))
automode = "AUTOMATIC"
else:
automode = "AUTOMATIC"
else:
- # IHEOL
+ # "IHEOL"
if len(game.enemies)==0:
prout(_("Energy will be expended into space."))
automode = "AUTOMATIC"
if ifast:
avail -= 200.0
if automode == "AUTOMATIC":
- if key == IHALPHA and scanner.sees("no"):
+ if key == "IHALPHA" and scanner.sees("no"):
no = True
key = scanner.next()
- if key != IHREAL and len(game.enemies) != 0:
+ if key != "IHREAL" and len(game.enemies) != 0:
prout(_("Phasers locked on target. Energy available: %.2f")%avail)
irec=0
while True:
scanner.chew()
proutn(_("Units to fire= "))
key = scanner.next()
- if key!=IHREAL:
+ if key!="IHREAL":
return
rpow = scanner.real
if rpow > avail:
proutn(_("Energy available= %.2f") % avail)
skip(1)
- key = IHEOL
+ key = "IHEOL"
if not rpow > avail:
break
if rpow<=0:
scanner.chew()
return
key=scanner.next()
- if key == IHALPHA and scanner.sees("no"):
+ if key == "IHALPHA" and scanner.sees("no"):
no = True
if ifast:
game.energy -= 200; # Go and do it!
prout(_("%d expended on empty space.") % int(extra))
elif automode == "FORCEMAN":
scanner.chew()
- key = IHEOL
+ key = "IHEOL"
if damaged(DCOMPTR):
prout(_("Battle computer damaged, manual fire only."))
else:
not game.sector.distance(aim)<2**0.5 and ienm in (IHC, IHS):
prout(cramen(ienm) + _(" can't be located without short range scan."))
scanner.chew()
- key = IHEOL
+ key = "IHEOL"
hits[k] = 0; # prevent overflow -- thanks to Alexei Voitenko
k += 1
continue
- if key == IHEOL:
+ if key == "IHEOL":
scanner.chew()
if itarg and k > kz:
irec=(abs(game.enemies[k].kpower)/(PHASEFAC*math.pow(0.9,game.enemies[k].kdist))) * randreal(1.01, 1.06) + 1.0
proutn(") ")
proutn(_("units to fire at %s- ") % crmena(False, ienm, "sector", aim))
key = scanner.next()
- if key == IHALPHA and scanner.sees("no"):
+ if key == "IHALPHA" and scanner.sees("no"):
no = True
key = scanner.next()
continue
- if key == IHALPHA:
+ if key == "IHALPHA":
huh()
return
- if key == IHEOL:
+ if key == "IHEOL":
if k==1: # Let me say I'm baffled by this
msgflag = True
continue
# zero energy -- abort
scanner.chew()
return
- if key == IHALPHA and scanner.sees("no"):
+ if key == "IHALPHA" and scanner.sees("no"):
no = True
game.energy -= rpow
scanner.chew()
game.optime -= xtime
if evcode == FSNOVA: # Supernova
announce()
- supernova(False)
+ supernova(None)
schedule(FSNOVA, expran(0.5*game.intime))
if game.state.galaxy[game.quadrant.i][game.quadrant.j].supernova:
return
for ibq in game.state.baseq:
for cmdr in game.state.kcmdr:
if ibq == cmdr and ibq != game.quadrant and ibq != game.state.kscmdr:
- raise "foundit"
- except "foundit":
- # no match found -- try later
- schedule(FBATTAK, expran(0.3*game.intime))
- unschedule(FCDBAS)
- continue
+ raise ibq
+ else:
+ # no match found -- try later
+ schedule(FBATTAK, expran(0.3*game.intime))
+ unschedule(FCDBAS)
+ continue
+ except coord:
+ pass
# commander + starbase combination found -- launch attack
game.battle = ibq
schedule(FCDBAS, randreal(1.0, 4.0))
game.proben -= 1 # One less to travel
if game.proben == 0 and game.isarmed and pdest.stars:
# lets blow the sucker!
- supernova(True, game.probec)
+ supernova(game.probec)
unschedule(FDSPROB)
if game.state.galaxy[game.quadrant.i][game.quadrant.j].supernova:
return
game.ididit = False
while True:
key = scanner.next()
- if key != IHEOL:
+ if key != "IHEOL":
break
proutn(_("How long? "))
scanner.chew()
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return
origTime = delay = scanner.real
newc = coord(); neighbor = coord(); bump = coord(0, 0)
if withprob(0.05):
# Wow! We've supernova'ed
- supernova(False, nov)
+ supernova(game.quadrant)
return
# handle initial nova
game.quad[nov.i][nov.j] = IHDOT
elif iquad == IHSTAR: # Affect another star
if withprob(0.05):
# This star supernovas
- supernova(False)
+ supernova(game.quadrant)
return
else:
hits.append(neighbor)
game.optime = 10.0*game.dist/16.0
return
-def supernova(induced, w=None):
+def supernova(w):
"Star goes supernova."
num = 0; npdead = 0
- nq = coord()
if w != None:
- nq = w
+ nq = copy.copy(w)
else:
+ # Scheduled supernova -- select star at random.
stars = 0
- # Scheduled supernova -- select star
- # logic changed here so that we won't favor quadrants in top
- # left of universe
+ nq = coord()
for nq.i in range(GALSIZE):
for nq.j in range(GALSIZE):
stars += game.state.galaxy[nq.i][nq.j].stars
skip(1)
stars()
game.alldone = True
- # destroy any Klingons in supernovaed quadrant
+ # destroy any Klingons in supernovaed quadrant
kldead = game.state.galaxy[nq.i][nq.j].klingons
game.state.galaxy[nq.i][nq.j].klingons = 0
if nq == game.state.kscmdr:
# Destroy any base in supernovaed quadrant
game.state.baseq = filter(lambda x: x != nq, game.state.baseq)
# If starship caused supernova, tally up destruction
- if induced:
+ if w != None:
game.state.starkl += game.state.galaxy[nq.i][nq.j].stars
game.state.basekl += game.state.galaxy[nq.i][nq.j].starbase
game.state.nplankl += npdead
# If supernova destroys last Klingons give special message
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0 and not nq == game.quadrant:
skip(2)
- if not induced:
+ if w == None:
prout(_("Lucky you!"))
proutn(_("A supernova in %s has just destroyed the last Klingons.") % nq)
finish(FWON)
prout(_("Computer damaged; manual movement only"))
scanner.chew()
navmode = "manual"
- key = IHEOL
+ key = "IHEOL"
break
if isprobe and akey != -1:
# For probe launch, use pre-scanned value first time
akey = -1
else:
key = scanner.next()
- if key == IHEOL:
+ if key == "IHEOL":
proutn(_("Manual or automatic- "))
iprompt = True
scanner.chew()
- elif key == IHALPHA:
+ elif key == "IHALPHA":
if scanner.sees("manual"):
navmode = "manual"
key = scanner.next()
navmode = "manual"
break
if navmode == "automatic":
- while key == IHEOL:
+ while key == "IHEOL":
if isprobe:
proutn(_("Target quadrant or quadrant§or- "))
else:
scanner.chew()
iprompt = True
key = scanner.next()
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return False
xi = int(round(scanner.real))-1
key = scanner.next()
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return False
xj = int(round(scanner.real))-1
key = scanner.next()
- if key == IHREAL:
+ if key == "IHREAL":
# both quadrant and sector specified
xk = int(round(scanner.real))-1
key = scanner.next()
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return False
xl = int(round(scanner.real))-1
dquad.i = xi
dquad.j = xj
- dsect.j = xk
- dsect.i = xl
+ dsect.i = xk
+ dsect.j = xl
else:
# only one pair of numbers was specified
if isprobe:
dsect.j = dsect.i = 4 # preserves 1-origin behavior
else:
# only sector specified
- dsect.j = xi
- dsect.i = xj
+ dsect.i = xi
+ dsect.j = xj
itemp = "normal"
- if not VALID_QUADRANT(dquad.j,dquad.i) or not VALID_SECTOR(dsect.i,dsect.j):
+ if not VALID_QUADRANT(dquad.i,dquad.j) or not VALID_SECTOR(dsect.i,dsect.j):
huh()
return False
skip(1)
prout(_("Ensign Chekov- \"Course laid in, Captain.\""))
# the actual deltas get computed here
delta = coord()
- delta.i = dquad.j-game.quadrant.j + 0.1*(dsect.i-game.sector.j)
- delta.j = game.quadrant.i-dquad.i + 0.1*(game.sector.i-dsect.j)
+ delta.i = dquad.j-game.quadrant.j + 0.1*(dsect.j-game.sector.j)
+ delta.j = game.quadrant.i-dquad.i + 0.1*(game.sector.i-dsect.i)
else: # manual
- while key == IHEOL:
+ while key == "IHEOL":
proutn(_("X and Y displacements- "))
scanner.chew()
iprompt = True
key = scanner.next()
itemp = "verbose"
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return False
delta.j = scanner.real
key = scanner.next()
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return False
delta.i = scanner.real
return
# Make sure enough time is left for the trip
- game.optime = 10.0*game.dist/game.wfacsq
+ game.optime = 10.0*game.dist/game.warpfac**2
if game.optime >= 0.8*game.state.remtime:
skip(1)
prout(_("First Officer Spock- \"Captain, I compute that such"))
game.energy -= game.dist*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1)
if game.energy <= 0:
finish(FNRG)
- game.optime = 10.0*game.dist/game.wfacsq
+ game.optime = 10.0*game.dist/game.warpfac**2
if twarp:
timwrp()
if blooey:
"Change the warp factor."
while True:
key=scanner.next()
- if key != IHEOL:
+ if key != "IHEOL":
break
scanner.chew()
proutn(_("Warp factor- "))
scanner.chew()
- if key != IHREAL:
+ if key != "IHREAL":
huh()
return
if game.damage[DWARPEN] > 10.0:
return
oldfac = game.warpfac
game.warpfac = scanner.real
- game.wfacsq=game.warpfac*game.warpfac
if game.warpfac <= oldfac or game.warpfac <= 6.0:
prout(_("Helmsman Sulu- \"Warp factor %d, Captain.\"") %
int(game.warpfac))
finish(FSNOVAED)
return
game.warpfac = randreal(6.0, 8.0)
- game.wfacsq = game.warpfac * game.warpfac
prout(_("Warp factor set to %d") % int(game.warpfac))
power = 0.75*game.energy
game.dist = power/(game.warpfac*game.warpfac*game.warpfac*(game.shldup+1))
distreq = randreal(math.sqrt(2))
if distreq < game.dist:
game.dist = distreq
- game.optime = 10.0*game.dist/game.wfacsq
+ game.optime = 10.0*game.dist/game.warpfac**2
game.direc = randreal(12) # How dumb!
game.justin = False
game.inorbit = False
prout(_("Uhura- \"The previous probe is still reporting data, Sir.\""))
return
key = scanner.next()
- if key == IHEOL:
+ if key == "IHEOL":
# slow mode, so let Kirk know how many probes there are left
if game.nprobes == 1:
prout(_("1 probe left."))
if ja() == False:
return
game.isarmed = False
- if key == IHALPHA and scanner.token == "armed":
+ if key == "IHALPHA" and scanner.token == "armed":
game.isarmed = True
key = scanner.next()
- elif key == IHEOL:
+ elif key == "IHEOL":
proutn(_("Arm NOVAMAX warhead? "))
game.isarmed = ja()
if not getcourse(isprobe=True, akey=key):
game.lsupres=game.inlsr=3.0
game.shldup=False
game.warpfac=5.0
- game.wfacsq=25.0
return
# Code from planets.c begins here.
def request():
"Request specified status data, a historical relic from slow TTYs."
requests = ("da","co","po","ls","wa","en","to","sh","kl","sy", "ti")
- while scanner.next() == IHEOL:
+ while scanner.next() == "IHEOL":
proutn(_("Information desired? "))
scanner.chew()
if scanner.token in requests:
prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."))
skip(1)
return
- if scanner.next() != IHREAL:
+ if scanner.next() != "IHREAL":
prompt = True
scanner.chew()
proutn(_("Destination quadrant and/or sector? "))
- if scanner.next()!=IHREAL:
+ if scanner.next()!="IHREAL":
huh()
return
w1.j = int(scanner.real-0.5)
- if scanner.next() != IHREAL:
+ if scanner.next() != "IHREAL":
huh()
return
w1.i = int(scanner.real-0.5)
- if scanner.next() == IHREAL:
+ if scanner.next() == "IHREAL":
w2.j = int(scanner.real-0.5)
- if scanner.next() != IHREAL:
+ if scanner.next() != "IHREAL":
huh()
return
w2.i = int(scanner.real-0.5)
while True:
scanner.chew()
proutn(_("Time or arrival date? "))
- if scanner.next()==IHREAL:
+ if scanner.next()=="IHREAL":
ttime = scanner.real
if ttime > game.state.date:
ttime -= game.state.date # Actually a star date
break
scanner.chew()
proutn(_("Warp factor? "))
- if scanner.next()== IHREAL:
+ if scanner.next()== "IHREAL":
wfl = True
twarp = scanner.real
if twarp<1.0 or twarp > 10.0:
if not wfl:
return
proutn(_("New warp factor to try? "))
- if scanner.next() == IHREAL:
+ if scanner.next() == "IHREAL":
wfl = True
twarp = scanner.real
if twarp<1.0 or twarp > 10.0:
(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 scanner.next() == IHREAL:
+ if scanner.next() == "IHREAL":
wfl = True
twarp = scanner.real
if twarp<1.0 or twarp > 10.0:
scanner.token = "emsave.trk"
else:
key = scanner.next()
- if key == IHEOL:
+ if key == "IHEOL":
proutn(_("File name: "))
key = scanner.next()
- if key != IHALPHA:
+ if key != "IHALPHA":
huh()
return
scanner.chew()
"Retrieve saved game."
game.passwd[0] = '\0'
key = scanner.next()
- if key == IHEOL:
+ if key == "IHEOL":
proutn(_("File name: "))
key = scanner.next()
- if key != IHALPHA:
+ if key != "IHALPHA":
huh()
return True
scanner.chew()
if choose():
return # frozen game
# Prepare the Enterprise
- game.alldone = game.gamewon = False
+ game.alldone = game.gamewon = game.shldchg = game.shldup = False
game.ship = IHE
game.state.crew = FULLCREW
game.energy = game.inenrg = 5000.0
game.shield = game.inshld = 2500.0
- game.shldchg = False
- game.shldup = False
game.inlsr = 4.0
game.lsupres = 4.0
game.quadrant = randplace(GALSIZE)
game.torps = game.intorps = 10
game.nprobes = randrange(2, 5)
game.warpfac = 5.0
- game.wfacsq = game.warpfac * game.warpfac
for i in range(NDEVICES):
game.damage[i] = 0.0
# Set up assorted game parameters
if len(scanner.token)==0: # Try again
continue
if scanner.sees("tournament"):
- while scanner.next() == IHEOL:
+ while scanner.next() == "IHEOL":
proutn(_("Type in tournament number-"))
if scanner.real == 0:
scanner.chew()
proutn(_("What is \"%s\"?") % scanner.token)
scanner.chew()
while game.length==0 or game.skill==SKILL_NONE:
- if scanner.next() == IHALPHA:
+ if scanner.next() == "IHALPHA":
if scanner.sees("short"):
game.length = 1
elif scanner.sees("medium"):
elif game.skill == SKILL_NONE:
proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "))
# Choose game options -- added by ESR for SST2K
- if scanner.next() != IHALPHA:
+ if scanner.next() != "IHALPHA":
scanner.chew()
proutn(_("Choose your game style (or just press enter): "))
scanner.next()
"Browse on-line help."
key = scanner.next()
while True:
- if key == IHEOL:
+ if key == "IHEOL":
setwnd(prompt_window)
proutn(_("Help on what command? "))
key = scanner.next()
setwnd(message_window)
- if key == IHEOL:
+ if key == "IHEOL":
return
if scanner.token in commands or scanner.token == "ABBREV":
break
skip(1)
listCommands()
- key = IHEOL
+ key = "IHEOL"
scanner.chew()
skip(1)
cmd = scanner.token.upper()
setwnd(prompt_window)
clrscr()
proutn("COMMAND> ")
- if scanner.next() == IHEOL:
+ if scanner.next() == "IHEOL":
if game.options & OPTION_CURSES:
makechart()
continue
clrscr()
if line == '':
return None
- # Skip leading white space
- line = line.lstrip()
if not line:
continue
else:
- self.inqueue = line.lstrip().split() + [IHEOL]
+ self.inqueue = line.lstrip().split() + ["IHEOL"]
# From here on in it's all looking at the queue
self.token = self.inqueue.pop(0)
- if self.token == IHEOL:
- self.type = IHEOL
- return IHEOL
+ if self.token == "IHEOL":
+ self.type = "IHEOL"
+ return "IHEOL"
try:
self.real = float(self.token)
- self.type = IHREAL
- return IHREAL
+ self.type = "IHREAL"
+ return "IHREAL"
except ValueError:
pass
# Treat as alpha
self.token = self.token.lower()
- self.type = IHALPHA
+ self.type = "IHALPHA"
self.real = None
- return IHALPHA
- def push(self, tok):
+ return "IHALPHA"
+ def append(self, tok):
self.inqueue.append(tok)
+ def push(self, tok):
+ self.inqueue.insert(0, tok)
def waiting(self):
return self.inqueue
def chew(self):
self.inqueue = []
self.real = self.token = None
def chew2(self):
- # return IHEOL next time
- self.inqueue = [IHEOL]
+ # return "IHEOL" next time
+ self.inqueue = ["IHEOL"]
self.real = self.token = None
def sees(self, s):
# compares s to item and returns true if it matches to the length of s
def getcoord(self):
s = coord()
scanner.next()
- if scanner.type != IHREAL:
+ if scanner.type != "IHREAL":
huh()
return None
s.i = scanner.int()-1
scanner.next()
- if scanner.type != IHREAL:
+ if scanner.type != "IHREAL":
huh()
return None
s.j = scanner.int()-1
return s
+ def __repr__(str):
+ return "<sstcanner: token=%s, type=%s, queue=%s>" % (scanner.token, scanner.type, scanner.inqueue)
def ja():
"Yes-or-no confirmation."
scanner.chew()
while True:
scanner.next()
- scanner.chew()
if scanner.token == 'y':
return True
if scanner.token == 'n':
return False
+ scanner.chew()
proutn(_("Please answer with \"y\" or \"n\": "))
def huh():
proutn("Kill %s?" % device[i])
scanner.chew()
key = scanner.next()
- if key == IHALPHA and scanner.sees("y"):
+ if key == "IHALPHA" and scanner.sees("y"):
game.damage[i] = 10.0
proutn("Examine/change events? ")
if ja() == True:
if key == 'n':
unschedule(i)
scanner.chew()
- elif key == IHREAL:
+ elif key == "IHREAL":
ev = schedule(i, scanner.real)
if i == FENSLV or i == FREPRO:
scanner.chew()
proutn("In quadrant- ")
key = scanner.next()
- # IHEOL says to leave coordinates as they are
- if key != IHEOL:
- if key != IHREAL:
+ # "IHEOL" says to leave coordinates as they are
+ if key != "IHEOL":
+ if key != "IHREAL":
prout("Event %d canceled, no x coordinate." % (i))
unschedule(i)
continue
w.i = int(round(scanner.real))
key = scanner.next()
- if key != IHREAL:
+ if key != "IHREAL":
prout("Event %d canceled, no y coordinate." % (i))
unschedule(i)
continue
logfp.write("# options %s\n" % " ".join(arguments))
random.seed(seed)
scanner = sstscanner()
- map(scanner.push, arguments)
+ map(scanner.append, arguments)
try:
iostart()
while True: # Play a game
ioend()
raise SystemExit, 0
except KeyboardInterrupt:
- print""
+ print ""
pass