Update base.py and marketplace.py

This commit is contained in:
Richard Bronkhorst 2023-06-18 20:42:30 +02:00
parent f849f871d2
commit 3a3e3b9da2
2 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ class Base:
store: object store: object
def __init__(self, symbol, store): def __init__(self, symbol, store):
self.disable_dirty = False
self.store = store self.store = store
self.symbol = symbol self.symbol = symbol
self.define() self.define()
@ -36,7 +37,7 @@ class Base:
setattr(self, attr, lst) setattr(self, attr, lst)
def __setattr__(self, name, value): def __setattr__(self, name, value):
if name not in ['symbol','store','__dict__']: if name not in ['symbol','store','disable_dirty'] and not self.disable_dirty:
self.store.dirty(self) self.store.dirty(self)
super().__setattr__(name, value) super().__setattr__(name, value)
@ -47,7 +48,9 @@ class Base:
return False return False
def load(self, d): def load(self, d):
self.__dict__ = d self.disable_dirty = True
self.__dict__.update(d)
self.disable_dirty = False
def dict(self): def dict(self):
r = {} r = {}

View File

@ -27,7 +27,10 @@ class Marketplace(SystemMember):
price['sell'] = mg(g, 'sellPrice') price['sell'] = mg(g, 'sellPrice')
prices[symbol] = price prices[symbol] = price
self.prices = prices self.prices = prices
def sellable_items(self, resources):
return [r for r in resources if r in self.prices]
@classmethod @classmethod
def ext(self): def ext(self):
return 'mkt' return 'mkt'