This commit is contained in:
richmans 2023-07-10 21:10:49 +02:00
parent b2f2dc520e
commit ea34bcfab7
4 changed files with 16 additions and 6 deletions

1
main.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
import argparse import argparse
from nullptr.commander import Commander from nullptr.commander import Commander
from nullptr.models.base import Base from nullptr.models.base import Base

View File

@ -80,7 +80,10 @@ class Api:
def list_systems(self, page=1): def list_systems(self, page=1):
data = self.request('get', 'systems', params={'page': page}) data = self.request('get', 'systems', params={'page': page})
#pprint(self.last_meta) #pprint(self.last_meta)
return self.store.update_list(System, data) systems = self.store.update_list(System, data)
for s in data:
self.store.update_list(Waypoint, mg(s, 'waypoints'))
return systems
def list_waypoints(self, system): def list_waypoints(self, system):
data = self.request('get', f'systems/{system}/waypoints/') data = self.request('get', f'systems/{system}/waypoints/')
@ -89,6 +92,7 @@ class Api:
def marketplace(self, waypoint): def marketplace(self, waypoint):
system = waypoint.system system = waypoint.system
print(f'systems/{system}/waypoints/{waypoint}/market')
data = self.request('get', f'systems/{system}/waypoints/{waypoint}/market') data = self.request('get', f'systems/{system}/waypoints/{waypoint}/market')
return self.store.update(Marketplace, data) return self.store.update(Marketplace, data)

View File

@ -26,17 +26,18 @@ class AtlasBuilder:
def all_specials(self, waypoints): def all_specials(self, waypoints):
for w in waypoints: for w in waypoints:
print(w)
if self.stop_auto: if self.stop_auto:
break break
if 'UNCHARTED' in w.traits: if 'UNCHARTED' in w.traits:
continue continue
if 'MARKETPLACE' in w.traits: if 'MARKETPLACE' in w.traits:
self.api.marketplace(w)
print(f'marketplace at {w}') print(f'marketplace at {w}')
self.api.marketplace(w)
sleep(0.5) sleep(0.5)
if w.type == 'JUMP_GATE': if w.type == 'JUMP_GATE':
self.api.jumps(w)
print(f'jumpgate at {w}') print(f'jumpgate at {w}')
self.api.jumps(w)
def all_waypoints(self, systems): def all_waypoints(self, systems):
for s in systems: for s in systems:

View File

@ -9,7 +9,7 @@ class Waypoint(Base):
self.type:str = 'unknown' self.type:str = 'unknown'
self.traits:list = [] self.traits:list = []
self.faction:str = '' self.faction:str = ''
self.system = None self.set_system()
def update(self, d): def update(self, d):
self.seta('x', d) self.seta('x', d)
@ -17,7 +17,11 @@ class Waypoint(Base):
self.seta('type', d) self.seta('type', d)
self.seta('faction', d, 'faction.symbol') self.seta('faction', d, 'faction.symbol')
self.setlst('traits', d, 'traits', 'symbol') self.setlst('traits', d, 'traits', 'symbol')
self.seta('system', d, self.store.getter(System))
def set_system(self):
parts = self.symbol.split('-')
system_str = f'{parts[0]}-{parts[1]}'
self.system = self.store.get(System, system_str, create=True)
@classmethod @classmethod
def ext(self): def ext(self):