Update analyzer.py and commander.py
This commit is contained in:
parent
0c1ec40090
commit
f079403535
@ -27,7 +27,7 @@ class Analyzer:
|
|||||||
def __init__(self, store):
|
def __init__(self, store):
|
||||||
self.store = store
|
self.store = store
|
||||||
|
|
||||||
def find_markets(self, resource, sellbuy, location):
|
def find_markets(self, resource, sellbuy):
|
||||||
for m in self.store.all(Marketplace):
|
for m in self.store.all(Marketplace):
|
||||||
resources = m.imports if sellbuy == 'sell' else m.exports
|
resources = m.imports if sellbuy == 'sell' else m.exports
|
||||||
if resource in resources:
|
if resource in resources:
|
||||||
|
@ -77,13 +77,16 @@ class Commander(CommandLine):
|
|||||||
pprint(r)
|
pprint(r)
|
||||||
|
|
||||||
def do_query(self):
|
def do_query(self):
|
||||||
location = None # self.ask_obj(Waypoint, 'Where are you? ')
|
location = self.ask_obj(System, 'Where are you? ')
|
||||||
resource = input('what resource?').upper()
|
resource = input('what resource?').upper()
|
||||||
sellbuy = self.ask_multichoice(['sell','buy'], 'do you want to sell or buy?')
|
sellbuy = self.ask_multichoice(['sell','buy'], 'do you want to sell or buy?')
|
||||||
print('Found markets:')
|
print('Found markets:')
|
||||||
for m in self.analyzer.find_markets(resource, sellbuy, location):
|
for m in self.analyzer.find_markets(resource, sellbuy):
|
||||||
print(m)
|
system = self.store.get(System, m.system())
|
||||||
|
p = self.analyzer.find_path(location, system)
|
||||||
|
if p is None: continue
|
||||||
|
print(m, f'{len(p)} hops')
|
||||||
|
|
||||||
def do_path(self):
|
def do_path(self):
|
||||||
orig = self.ask_obj(System, 'from: ')
|
orig = self.ask_obj(System, 'from: ')
|
||||||
dest = self.ask_obj(System, 'to: ')
|
dest = self.ask_obj(System, 'to: ')
|
||||||
|
Loading…
Reference in New Issue
Block a user