self.i = x # Row
self.j = y # Column
def valid_quadrant(self):
- return self.i >= 0 and self.i < GALSIZE and self.j >= 0 and self.j < GALSIZE
+ return (self.i is not None) and (self.j is not None) and (self.i >= 0) and (self.i < GALSIZE) and (self.j >= 0) and (self.j < GALSIZE)
def valid_sector(self):
- return self.i >= 0 and self.i < QUADSIZE and self.j >= 0 and self.j < QUADSIZE
+ return (self.i is not None) and (self.j is not None) and (self.i >= 0) and (self.i < QUADSIZE) and (self.j >= 0) and (self.j < QUADSIZE)
def invalidate(self):
self.i = self.j = None
def __eq__(self, other):
deadkl(w, iquad, w)
return None
proutn(crmena(True, iquad, "sector", w))
- displacement = course(track.bearing+rnd.real(-2.4, 2.4), distance=2**0.5)
+ displacement = course(track.bearing+rnd.real(-2.4, 2.4), distance=2**0.5, origin=w)
displacement.nexttok()
bumpto = displacement.sector()
- if not bumpto.valid_sector():
- prout(_(" damaged but not destroyed."))
- return None
if game.quad[bumpto.i][bumpto.j] == ' ':
prout(_(" buffeted into black hole."))
deadkl(w, iquad, bumpto)
+ return None
+ if not bumpto.valid_sector():
+ prout(_(" damaged but not destroyed."))
+ return None
if game.quad[bumpto.i][bumpto.j] != '.':
prout(_(" damaged but not destroyed."))
else:
if game.inorbit:
prout(_("You must first leave standard orbit."))
return
- if game.base is None or abs(game.sector.i-game.base.i) > 1 or abs(game.sector.j-game.base.j) > 1:
+ if game.base is None or not game.base.valid_sector():
+ prout(_("No starbase available for docking in this quadrant."))
+ return
+ if (abs(game.sector.i-game.base.i) > 1) or (abs(game.sector.j-game.base.j) > 1):
prout(crmshp() + _(" not adjacent to base."))
return
if game.iscloaked:
logfp.write("# options %s\n" % " ".join(arguments))
logfp.write("# SST2K version %s\n" % version)
logfp.write("# recorded by %s@%s on %s\n" % \
- (getpass.getuser(),socket.gethostname(),time.ctime()))
+ (getpass.getuser(),socket.getfqdn(),time.ctime()))
rnd.seed(seed)
scanner = sstscanner()
for arg in arguments: