shipyards
This commit is contained in:
@@ -10,5 +10,6 @@ from nullptr.models.contract import Contract
|
||||
from nullptr.models.survey import Survey
|
||||
from nullptr.models.atlas import Atlas
|
||||
from nullptr.models.crew import Crew
|
||||
from nullptr.models.shipyard import Shipyard
|
||||
|
||||
__all__ = [ 'Waypoint', 'Sector', 'Ship', 'Survey', 'System', 'Agent', 'Marketplace', 'Jumpgate', 'Contract', 'Base', 'Atlas', 'Crew' ]
|
||||
__all__ = [ 'Waypoint', 'Sector', 'Ship', 'Survey', 'System', 'Agent', 'Marketplace', 'Jumpgate', 'Contract', 'Base', 'Atlas', 'Crew', 'Shipyard' ]
|
||||
|
||||
35
nullptr/models/shipyard.py
Normal file
35
nullptr/models/shipyard.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from nullptr.models import Base
|
||||
from time import time
|
||||
from nullptr.util import *
|
||||
|
||||
class Shipyard(Base):
|
||||
def define(self):
|
||||
self.last_prices = 0
|
||||
self.types = set()
|
||||
self.prices:dict = {}
|
||||
|
||||
def get_waypoint(self):
|
||||
return self.store.get('Waypoint', self.symbol, create=True)
|
||||
|
||||
@classmethod
|
||||
def ext(self):
|
||||
return 'syd'
|
||||
|
||||
def update(self, d):
|
||||
if 'ships' in d:
|
||||
self.last_prices = time()
|
||||
for s in must_get(d, 'ships'):
|
||||
self.prices[s['type']] = s['purchasePrice']
|
||||
for s in must_get(d, 'shipTypes'):
|
||||
self.types.add(s['type'])
|
||||
|
||||
def f(self, detail=1):
|
||||
r = super().f(detail)
|
||||
if detail > 2:
|
||||
r += '\n'
|
||||
for st in self.types:
|
||||
price = "Unknown"
|
||||
if st in self.prices:
|
||||
price = self.prices[st]
|
||||
r += f'{st:20} {price}\n'
|
||||
return r
|
||||
Reference in New Issue
Block a user