def addController(self, ctrl): ctrlID = ctrl.getControllerID() if ctrlID in REUSABLE_BATTLE_CTRL_IDS: LOG_ERROR('Controller can not be added to repository, controllerID is not unique', ctrlID) return if ctrlID in self._ctrls: LOG_ERROR('Controller with given ID already exists', ctrlID) return self._ctrls[ctrlID] = ctrl if not isinstance(ctrl, IArenaController): ctrl.startControl() LOG_DEBUG('GUI Controller is started', getBattleCtrlName(ctrlID))
def addController(self, ctrl): if not isinstance(ctrl, interfaces.IBattleController): raise AssertionError('Controller is not valid') ctrlID = ctrl.getControllerID() if ctrlID in REUSABLE_BATTLE_CTRL_IDS: LOG_ERROR('Controller can not be added to repository, controllerID is not unique', ctrlID) return if ctrlID in self._ctrls: LOG_ERROR('Controller with given ID already exists', ctrlID) return self._ctrls[ctrlID] = ctrl isinstance(ctrl, IArenaController) or ctrl.startControl() LOG_DEBUG('GUI Controller is started', getBattleCtrlName(ctrlID))
def destroy(self): while self._ctrls: _, ctrl = self._ctrls.popitem() ctrl.stopControl() LOG_DEBUG('GUI Controller is stopped', getBattleCtrlName(ctrl.getControllerID()))