Compare commits

...

2 Commits

Author SHA1 Message Date
Richard Bronkhorst
293b6d1c3e Merge remote-tracking branch 'refs/remotes/origin/master' 2023-06-17 20:23:27 +02:00
Richard Bronkhorst
e31dce9861 Update commander.py, jumpgate.py and two other files 2023-06-17 20:23:24 +02:00
4 changed files with 22 additions and 2 deletions

View File

@ -108,6 +108,9 @@ class Commander(CommandLine):
traits.append('ASTROIDS')
print(w.symbol.split('-')[2], ', '.join(traits))
def do_wp(self, s=''):
self.do_waypoints(s)
def do_marketplace(self, waypoint_str):
waypoint = self.store.get(Waypoint, waypoint_str.upper())
r = self.api.marketplace(waypoint)
@ -239,6 +242,9 @@ class Commander(CommandLine):
def do_jump(self, system_str):
if not self.has_ship(): return
if '-' not in system_str:
sector = self.ship.location_str.split('-')[0]
system_str = f'{sector}-{system_str}'
system = self.resolve('System', system_str)
self.api.jump(self.ship, system)
pprint(self.ship)

View File

@ -22,5 +22,6 @@ class Jumpgate(SystemMember):
def f(self, detail=1):
r = self.symbol
if detail > 1:
r += '\n'
r += '\n'.join(self.systems)
return r

View File

@ -31,6 +31,15 @@ class Marketplace(SystemMember):
def ext(self):
return 'mkt'
def rtype(self, r):
if r in self.imports:
return 'I'
if r in self.exports:
return 'E'
if r in self.exchange:
return 'X'
return '?'
def path(self):
sector, system, _ = self.symbol.split('-')
return f'atlas/{sector}/{system[0:1]}/{system}/{self.symbol}.{self.ext()}'
@ -40,5 +49,6 @@ class Marketplace(SystemMember):
if detail > 1:
r += '\n'
for p in self.prices.values():
r += f'{p["symbol"]:25s} {p["sell"]:5d} {p["buy"]:5d}\n'
t = self.rtype(p['symbol'])
r += f'{t} {p["symbol"]:25s} {p["sell"]:5d} {p["buy"]:5d}\n'
return r

View File

@ -22,3 +22,6 @@ class System(Base):
def distance(self, other):
return int(sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2))
def sector(self):
return self.symbol.split('-')[0]