def _stopListening(self): """ Unsubscribe from player events. """ g_eventsCache.companies.onCompanyStateChanged -= self.onCompanyStateChanged g_playerEvents.onPrebattleJoined -= self.pe_onPrebattleJoined g_playerEvents.onPrebattleJoinFailure -= self.pe_onPrebattleJoinFailure g_playerEvents.onPrebattleLeft -= self.pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle -= self.pe_onKickedFromPrebattle g_playerEvents.onArenaJoinFailure -= self.pe_onArenaJoinFailure g_playerEvents.onKickedFromArena -= self.pe_onKickedFromArena g_playerEvents.onPrebattleAutoInvitesChanged -= self.pe_onPrebattleAutoInvitesChanged game_control.g_instance.captcha.onCaptchaInputCanceled -= self.captcha_onCaptchaInputCanceled game_control.g_instance.gameSession.onTimeTillBan -= self.gs_onTillBanNotification game_control.g_instance.rentals.onRentChangeNotify -= self.rc_onRentChange game_control.g_instance.igr.onIgrTypeChanged -= self.igr_onRoomChange unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined -= self.unitMgr_onUnitJoined unitMgr.onUnitLeft -= self.unitMgr_onUnitLeft unitMgr.onUnitRestored -= self.unitMgr_onUnitRestored unitMgr.onUnitErrorReceived -= self.unitMgr_onUnitErrorReceived unitBrowser = getClientUnitBrowser() if unitBrowser: unitBrowser.onErrorReceived -= self.unitBrowser_onErrorReceived fortMgr = getClientFortMgr() if fortMgr: fortMgr.onFortResponseReceived -= self.fortMgr_onFortResponseReceived fortMgr.onFortStateChanged -= self.forMgr_onFortStateChanged g_prbCtrlEvents.clear()
def _stopListening(self): """ Unsubscribe from player events. """ g_playerEvents.onEnqueuedRandom -= self.pe_onEnqueuedRandom g_playerEvents.onDequeuedRandom -= self.pe_onDequeuedRandom g_playerEvents.onEnqueueRandomFailure -= self.pe_onEnqueueRandomFailure g_playerEvents.onKickedFromRandomQueue -= self.pe_onKickedFromRandomQueue g_playerEvents.onPrebattleJoined -= self.pe_onPrebattleJoined g_playerEvents.onPrebattleJoinFailure -= self.pe_onPrebattleJoinFailure g_playerEvents.onPrebattleLeft -= self.pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle -= self.pe_onKickedFromPrebattle g_playerEvents.onArenaJoinFailure -= self.pe_onArenaJoinFailure g_playerEvents.onKickedFromArena -= self.pe_onKickedFromArena g_playerEvents.onPrebattleAutoInvitesChanged -= self.pe_onPrebattleAutoInvitesChanged game_control.g_instance.gameSession.onTimeTillBan -= self.gs_onTillBanNotification unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined -= self.unitMgr_onUnitJoined unitMgr.onUnitLeft -= self.unitMgr_onUnitLeft unitMgr.onUnitErrorReceived -= self.unitMgr_onUnitErrorReceived unitBrowser = getClientUnitBrowser() if unitBrowser: unitBrowser.onErrorReceived -= self.unitBrowser_onErrorReceived g_prbCtrlEvents.clear()
def init(self): unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitResponseReceived += self.unitMgr_onUnitResponseReceived unitMgr.onUnitErrorReceived += self.unitMgr_onUnitErrorReceived else: LOG_ERROR('Unit manager is not defined')
def _startListening(self): """ Subscribes to player events. """ g_playerEvents.onEnqueuedRandom += self.pe_onEnqueuedRandom g_playerEvents.onDequeuedRandom += self.pe_onDequeuedRandom g_playerEvents.onEnqueueRandomFailure += self.pe_onEnqueueRandomFailure g_playerEvents.onKickedFromRandomQueue += self.pe_onKickedFromRandomQueue g_playerEvents.onPrebattleJoined += self.pe_onPrebattleJoined g_playerEvents.onPrebattleJoinFailure += self.pe_onPrebattleJoinFailure g_playerEvents.onPrebattleLeft += self.pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle += self.pe_onKickedFromPrebattle g_playerEvents.onArenaJoinFailure += self.pe_onArenaJoinFailure g_playerEvents.onKickedFromArena += self.pe_onKickedFromArena g_playerEvents.onPrebattleAutoInvitesChanged += self.pe_onPrebattleAutoInvitesChanged gameSession = game_control.g_instance.gameSession if gameSession.lastBanMsg is not None: self.gs_onTillBanNotification(*gameSession.lastBanMsg) gameSession.onTimeTillBan += self.gs_onTillBanNotification unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined += self.unitMgr_onUnitJoined unitMgr.onUnitLeft += self.unitMgr_onUnitLeft unitMgr.onUnitErrorReceived += self.unitMgr_onUnitErrorReceived else: LOG_ERROR('Unit manager is not defined') unitBrowser = getClientUnitBrowser() if unitBrowser: unitBrowser.onErrorReceived += self.unitBrowser_onErrorReceived else: LOG_ERROR('Unit browser is not defined') g_prbCtrlEvents.onPrebattleInited += self.ctrl_onPrebattleInited g_prbCtrlEvents.onUnitIntroModeJoined += self.ctrl_onUnitIntroModeJoined g_prbCtrlEvents.onUnitIntroModeLeft += self.ctrl_onUnitIntroModeLeft return
def createFunctional(self, dispatcher, ctx): unitMrg = prb_control.getClientUnitMgr() if unitMrg.id and unitMrg.unitIdx: unit = prb_control.getUnit(unitMrg.unitIdx, safe=True) prbType = PREBATTLE_TYPE.UNIT if unit.isSortie(): prbType = PREBATTLE_TYPE.SORTIE elif unit.isFortBattle(): prbType = PREBATTLE_TYPE.FORT_BATTLE if unit: unitFunctional = UnitFunctional(prbType, DynamicRosterSettings(unit)) for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: LOG_ERROR('Unit is not found in unit manager', unitMrg.unitIdx, unitMrg.units) unitMrg.leave() unitFunctional = NoUnitFunctional() else: prbType = ctx.getPrbType() if prbType: unitFunctional = IntroFunctional(prbType, ctx.getCreateParams().get('modeFlags', UNIT_MODE_FLAGS.UNDEFINED), SupportedRosterSettings.last(prbType)) for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: unitFunctional = NoUnitFunctional() return unitFunctional
def createFunctional(self, dispatcher, ctx): unitMrg = prb_control.getClientUnitMgr() if unitMrg.id and unitMrg.unitIdx: unit = prb_control.getUnit(unitMrg.unitIdx, safe=True) if unit: unitFunctional = UnitFunctional(unit.getPrebattleType(), DynamicRosterSettings(unit)) for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: LOG_ERROR('Unit is not found in unit manager', unitMrg.unitIdx, unitMrg.units) unitMrg.leave() unitFunctional = NoUnitFunctional() else: prbType = ctx.getPrbType() if prbType: unitFunctional = IntroFunctional( prbType, ctx.getCreateParams().get('modeFlags', UNIT_MODE_FLAGS.UNDEFINED), SupportedRosterSettings.last(prbType)) for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: unitFunctional = NoUnitFunctional() return unitFunctional
def doRawRequest(self, methodName, *args, **kwargs): unitMgr = prb_control.getClientUnitMgr() method = getattr(unitMgr, methodName) if callable(method): method(*args, **kwargs) else: LOG_ERROR('Name of method is invalid', methodName)
def fini(self): unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitResponseReceived -= self.unitMgr_onUnitResponseReceived unitMgr.onUnitErrorReceived -= self.unitMgr_onUnitErrorReceived self.__requests.clear() self.__functional = None
def _unsubscribe(self): g_playerEvents.onEnqueuedRandom -= self.__pe_onEnqueued g_playerEvents.onDequeuedRandom -= self.__pe_onDequeued g_playerEvents.onKickedFromRandomQueue -= self.__pe_onKickedFromQueue g_playerEvents.onPrebattleJoined -= self.__pe_onPrebattleJoined g_playerEvents.onPrebattleLeft -= self.__pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle -= self.__pe_onKickedFromPrebattle connectionManager.onDisconnected -= self.__cm_onDisconnected unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined -= self.__cum_onUnitJoined unitMgr.onUnitLeft -= self.__cum_onUnitLeft
def _sendRequest(self, ctx, methodName, chain, *args, **kwargs): unitMgr = prb_control.getClientUnitMgr() result = False method = getattr(unitMgr, methodName) if callable(method): requestID = method(*args, **kwargs) if requestID > 0: self.__requests[requestID] = (ctx, chain) result = True else: LOG_ERROR('Request ID can not be null') else: LOG_ERROR('Name of method is invalid', methodName) return result
def _subscribe(self): g_playerEvents.onEnqueuedRandom += self.__pe_onEnqueued g_playerEvents.onDequeuedRandom += self.__pe_onDequeued g_playerEvents.onKickedFromRandomQueue += self.__pe_onKickedFromQueue g_playerEvents.onPrebattleJoined += self.__pe_onPrebattleJoined g_playerEvents.onPrebattleLeft += self.__pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle += self.__pe_onKickedFromPrebattle connectionManager.onDisconnected += self.__cm_onDisconnected unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined += self.__cum_onUnitJoined unitMgr.onUnitLeft += self.__cum_onUnitLeft else: LOG_ERROR('Unit manager is not defined')
def _startListening(self): """ Subscribes to player events. """ g_playerEvents.onPrebattleJoined += self.pe_onPrebattleJoined g_playerEvents.onPrebattleJoinFailure += self.pe_onPrebattleJoinFailure g_playerEvents.onPrebattleLeft += self.pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle += self.pe_onKickedFromPrebattle g_playerEvents.onArenaJoinFailure += self.pe_onArenaJoinFailure g_playerEvents.onKickedFromArena += self.pe_onKickedFromArena g_playerEvents.onPrebattleAutoInvitesChanged += self.pe_onPrebattleAutoInvitesChanged gameSession = game_control.g_instance.gameSession captchaCtrl = game_control.g_instance.captcha rentCtr = game_control.g_instance.rentals igrCtr = game_control.g_instance.igr if gameSession.lastBanMsg is not None: self.gs_onTillBanNotification(*gameSession.lastBanMsg) gameSession.onTimeTillBan += self.gs_onTillBanNotification rentCtr.onRentChangeNotify += self.rc_onRentChange captchaCtrl.onCaptchaInputCanceled += self.captcha_onCaptchaInputCanceled igrCtr.onIgrTypeChanged += self.igr_onRoomChange unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined += self.unitMgr_onUnitJoined unitMgr.onUnitLeft += self.unitMgr_onUnitLeft unitMgr.onUnitRestored += self.unitMgr_onUnitRestored unitMgr.onUnitErrorReceived += self.unitMgr_onUnitErrorReceived else: LOG_ERROR('Unit manager is not defined') unitBrowser = getClientUnitBrowser() if unitBrowser: unitBrowser.onErrorReceived += self.unitBrowser_onErrorReceived else: LOG_ERROR('Unit browser is not defined') fortMgr = getClientFortMgr() if fortMgr: fortMgr.onFortStateChanged += self.forMgr_onFortStateChanged fortMgr.onFortResponseReceived += self.fortMgr_onFortResponseReceived else: LOG_ERROR('Fort manager is not defined') g_prbCtrlEvents.onPrebattleIntroModeJoined += self.ctrl_onPrebattleIntroModeJoined g_prbCtrlEvents.onPrebattleIntroModeLeft += self.ctrl_onPrebattleIntroModeLeft g_prbCtrlEvents.onPrebattleInited += self.ctrl_onPrebattleInited g_prbCtrlEvents.onUnitIntroModeJoined += self.ctrl_onUnitIntroModeJoined g_prbCtrlEvents.onUnitIntroModeLeft += self.ctrl_onUnitIntroModeLeft g_prbCtrlEvents.onPreQueueFunctionalCreated += self.ctrl_onPreQueueFunctionalCreated g_prbCtrlEvents.onPreQueueFunctionalDestroyed += self.ctrl_onPreQueueFunctionalDestroyed g_eventsCache.companies.onCompanyStateChanged += self.onCompanyStateChanged return
def _startListening(self): """ Subscribes to player events. """ g_playerEvents.onPrebattleJoined += self.pe_onPrebattleJoined g_playerEvents.onPrebattleJoinFailure += self.pe_onPrebattleJoinFailure g_playerEvents.onPrebattleLeft += self.pe_onPrebattleLeft g_playerEvents.onKickedFromPrebattle += self.pe_onKickedFromPrebattle g_playerEvents.onArenaJoinFailure += self.pe_onArenaJoinFailure g_playerEvents.onKickedFromArena += self.pe_onKickedFromArena g_playerEvents.onPrebattleAutoInvitesChanged += self.pe_onPrebattleAutoInvitesChanged gameSession = game_control.g_instance.gameSession captchaCtrl = game_control.g_instance.captcha rentCtr = game_control.g_instance.rentals igrCtr = game_control.g_instance.igr if gameSession.lastBanMsg is not None: self.gs_onTillBanNotification(*gameSession.lastBanMsg) gameSession.onTimeTillBan += self.gs_onTillBanNotification rentCtr.onRentChangeNotify += self.rc_onRentChange captchaCtrl.onCaptchaInputCanceled += self.captcha_onCaptchaInputCanceled igrCtr.onIgrTypeChanged += self.igr_onRoomChange unitMgr = getClientUnitMgr() if unitMgr: unitMgr.onUnitJoined += self.unitMgr_onUnitJoined unitMgr.onUnitLeft += self.unitMgr_onUnitLeft unitMgr.onUnitRestored += self.unitMgr_onUnitRestored unitMgr.onUnitErrorReceived += self.unitMgr_onUnitErrorReceived else: LOG_ERROR('Unit manager is not defined') unitBrowser = getClientUnitBrowser() if unitBrowser: unitBrowser.onErrorReceived += self.unitBrowser_onErrorReceived else: LOG_ERROR('Unit browser is not defined') fortMgr = getClientFortMgr() if fortMgr: fortMgr.onFortStateChanged += self.forMgr_onFortStateChanged fortMgr.onFortResponseReceived += self.fortMgr_onFortResponseReceived else: LOG_ERROR('Fort manager is not defined') g_prbCtrlEvents.onPrebattleIntroModeJoined += self.ctrl_onPrebattleIntroModeJoined g_prbCtrlEvents.onPrebattleIntroModeLeft += self.ctrl_onPrebattleIntroModeLeft g_prbCtrlEvents.onPrebattleInited += self.ctrl_onPrebattleInited g_prbCtrlEvents.onUnitIntroModeJoined += self.ctrl_onUnitIntroModeJoined g_prbCtrlEvents.onUnitIntroModeLeft += self.ctrl_onUnitIntroModeLeft g_prbCtrlEvents.onPreQueueFunctionalCreated += self.ctrl_onPreQueueFunctionalCreated g_prbCtrlEvents.onPreQueueFunctionalDestroyed += self.ctrl_onPreQueueFunctionalDestroyed g_eventsCache.companies.onCompanyStateChanged += self.onCompanyStateChanged
def createUnitFunctional(dispatcher): unitMrg = prb_control.getClientUnitMgr() if unitMrg.id and unitMrg.unitIdx: if unitMrg.unitIdx in unitMrg.units: unitFunctional = UnitFunctional() for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: LOG_ERROR('Unit not found in unit manager', unitMrg.unitIdx, unitMrg.units) unitMrg.leave() unitFunctional = NoUnitFunctional() else: func = dispatcher.getUnitFunctional() if func and func.getExit() == FUNCTIONAL_EXIT.INTRO_UNIT: unitFunctional = IntroFunctional() for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: unitFunctional = NoUnitFunctional() return unitFunctional
def createUnitFunctional(dispatcher): unitMrg = prb_control.getClientUnitMgr() if unitMrg.id and unitMrg.unitIdx: if unitMrg.unitIdx in unitMrg.units: unitFunctional = UnitFunctional() for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: LOG_ERROR("Unit not found in unit manager", unitMrg.unitIdx, unitMrg.units) unitMrg.leave() unitFunctional = NoUnitFunctional() else: func = dispatcher.getUnitFunctional() if func and func.getExit() == FUNCTIONAL_EXIT.INTRO_UNIT: unitFunctional = IntroFunctional() for listener in dispatcher._globalListeners: unitFunctional.addListener(listener()) else: unitFunctional = NoUnitFunctional() return unitFunctional