diff --git a/nullptr/analyzer.py b/nullptr/analyzer.py index 9dd2b57..99b49b2 100644 --- a/nullptr/analyzer.py +++ b/nullptr/analyzer.py @@ -27,7 +27,7 @@ class Analyzer: def __init__(self, store): self.store = store - def find_markets(self, resource, sellbuy, location): + def find_markets(self, resource, sellbuy): for m in self.store.all(Marketplace): resources = m.imports if sellbuy == 'sell' else m.exports if resource in resources: diff --git a/nullptr/commander.py b/nullptr/commander.py index d6b7f2f..191245b 100644 --- a/nullptr/commander.py +++ b/nullptr/commander.py @@ -77,13 +77,16 @@ class Commander(CommandLine): pprint(r) 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() sellbuy = self.ask_multichoice(['sell','buy'], 'do you want to sell or buy?') print('Found markets:') - for m in self.analyzer.find_markets(resource, sellbuy, location): - print(m) - + for m in self.analyzer.find_markets(resource, sellbuy): + 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): orig = self.ask_obj(System, 'from: ') dest = self.ask_obj(System, 'to: ')