def __init__(self): self._eos = Eos() self._linkTracker = LinkTracker(self) self.__ship = None self.__character = None self.items = HolderContainer(self)
class Fit: def __init__(self): self._eos = Eos() self._linkTracker = LinkTracker(self) self.__ship = None self.__character = None self.items = HolderContainer(self) @property def ship(self): return self.__ship @ship.setter def ship(self, ship): if self.__ship is not None: self._removeHolder(self.__ship) self.__ship = ship if ship is not None: self._addHolder(self.__ship) @property def character(self): return self.__character @character.setter def character(self, character): if self.__character is not None: self._removeHolder(self.__character) self.__character = character if character is not None: self._addHolder(self.__character) def _addHolder(self, holder): if holder.fit is not None: raise Exception holder.fit = self self._linkTracker.addHolder(holder) enabledStates = set(filter(lambda s: s <= holder.state, State)) self._linkTracker.enableStates(holder, enabledStates) def _removeHolder(self, holder): if holder.fit is None: raise Exception disabledStates = set(filter(lambda s: s <= holder.state, State)) self._linkTracker.disableStates(holder, disabledStates) self._linkTracker.removeHolder(holder) holder.fit = None def _holderStateSwitch(self, holder, newState): enabledStates = set(filter(lambda s: s > holder.state and s <= newState, State)) disabledStates = set(filter(lambda s: s > newState and s <= holder.state, State)) self._linkTracker.enableStates(holder, enabledStates) self._linkTracker.disableStates(holder, disabledStates)