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
def __init__(self, symbol, store):
self.disable_dirty = False
self.store = store
self.symbol = symbol
self.define()
@ -36,7 +37,7 @@ class Base:
setattr(self, attr, lst)
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)
super().__setattr__(name, value)
@ -47,7 +48,9 @@ class Base:
return False
def load(self, d):
self.__dict__ = d
self.disable_dirty = True
self.__dict__.update(d)
self.disable_dirty = False
def dict(self):
r = {}

View File

@ -28,6 +28,9 @@ class Marketplace(SystemMember):
prices[symbol] = price
self.prices = prices
def sellable_items(self, resources):
return [r for r in resources if r in self.prices]
@classmethod
def ext(self):
return 'mkt'