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
from nullptr.commander import Commander
from nullptr.models.base import Base

View File

@ -80,7 +80,10 @@ class Api:
def list_systems(self, page=1):
data = self.request('get', 'systems', params={'page': page})
#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):
data = self.request('get', f'systems/{system}/waypoints/')
@ -89,6 +92,7 @@ class Api:
def marketplace(self, waypoint):
system = waypoint.system
print(f'systems/{system}/waypoints/{waypoint}/market')
data = self.request('get', f'systems/{system}/waypoints/{waypoint}/market')
return self.store.update(Marketplace, data)

View File

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

View File

@ -9,7 +9,7 @@ class Waypoint(Base):
self.type:str = 'unknown'
self.traits:list = []
self.faction:str = ''
self.system = None
self.set_system()
def update(self, d):
self.seta('x', d)
@ -17,8 +17,12 @@ class Waypoint(Base):
self.seta('type', d)
self.seta('faction', d, 'faction.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
def ext(self):
return 'way'