improving haulers

This commit is contained in:
Richard
2024-01-06 07:17:53 +01:00
parent 524ba45639
commit 2181583843
9 changed files with 175 additions and 48 deletions

View File

@@ -57,6 +57,9 @@ class Base:
val = interp(val)
setattr(self, attr, val)
def __lt__(self, o):
return self.symbol < o.symbol
def setlst(self, attr, d, name, member=None, interp=None):
val = sg(d, name)
if val is not None:

View File

@@ -19,6 +19,9 @@ class Marketplace(Base):
waypoint = self.store.get(Waypoint, self.symbol, create=True)
self.waypoint = waypoint
def is_fuel(self):
return self.imports + self.exports + self.exchange == ['FUEL']
def update(self, d):
self.setlst('imports', d, 'imports', 'symbol')
self.setlst('exports', d, 'exports', 'symbol')
@@ -40,6 +43,11 @@ class Marketplace(Base):
if resource not in self.prices:
return None
return self.prices[resource]['buy']
def volume(self, resource):
if resource not in self.prices:
return None
return self.prices[resource]['volume']
def sellable_items(self, resources):
return [r for r in resources if r in self.prices]

View File

@@ -23,6 +23,11 @@ class Ship(Base):
def ext(self):
return 'shp'
def range(self):
if self.fuel_capacity == 0:
return 100000
return self.fuel_capacity
def update(self, d):
self.seta('status', d, 'nav.status')
getter = self.store.getter(Waypoint, create=True)