X-Git-Url: https://plomlompom.com/repos/?p=plomrogue2-experiments;a=blobdiff_plain;f=new%2Fplomrogue%2Fthings.py;h=13384fc76935d14e328287a34a0716805b75fe6d;hp=f020edae3d4f0cafe3f77d2ed0de252c3aa2553f;hb=52cf6eee2b83be0fedd0df716395eb715ffddebb;hpb=1aa93f6152f585ae1b0e69e99e0f68254b0716ee diff --git a/new/plomrogue/things.py b/new/plomrogue/things.py index f020eda..13384fc 100644 --- a/new/plomrogue/things.py +++ b/new/plomrogue/things.py @@ -13,6 +13,26 @@ class ThingBase: else: self.id_ = id_ + @property + def position(self): + return self._position + + def _position_set(self, pos): + """Set self._position to pos. + + We use this setter as core to the @position.setter property + method due to property setter subclassing not yet working + properly, see . We will + therefore super() _position_set instead of @position.setter in + subclasses. + + """ + self._position = pos + + @position.setter + def position(self, pos): + self._position_set(pos) + class Thing(ThingBase): @@ -20,12 +40,18 @@ class Thing(ThingBase): in_inventory = False def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) self.inventory = [] + super().__init__(*args, **kwargs) def proceed(self): pass + def _position_set(self, pos): + super()._position_set(pos) + for t_id in self.inventory: + t = self.world.get_thing(t_id) + t.position = self.position + class ThingItem(Thing):