Update api.py, commander.py and one other file

This commit is contained in:
Richard Bronkhorst
2023-06-16 23:05:47 +02:00
parent 3f93d863a0
commit bb93950fa3
3 changed files with 86 additions and 3 deletions

View File

@@ -17,8 +17,16 @@ class Marketplace(SystemMember):
self.setlst('exchange', d, 'exchange', 'symbol')
if 'tradeGoods' in d:
self.last_prices = time()
prices = {}
for g in mg(d, 'tradeGoods'):
pass
price = {}
symbol= mg(g, 'symbol')
price['symbol'] = symbol
price['buy'] = mg(g, 'purchasePrice')
price['sell'] = mg(g, 'sellPrice')
prices[symbol] = price
self.prices = prices
@classmethod
def ext(self):
return 'mkt'
@@ -26,3 +34,11 @@ class Marketplace(SystemMember):
def path(self):
sector, system, _ = self.symbol.split('-')
return f'atlas/{sector}/{system[0:1]}/{system}/{self.symbol}.{self.ext()}'
def f(self, detail=1):
r = self.symbol
if detail > 1:
r += '\n'
for p in self.prices.values():
r += f'{p["symbol"]:25s} {p["sell"]:5d} {p["buy"]:5d}\n'
return r