def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager() self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier() return
def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self)
def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) if self.__storage is None: self.__storage = PrbStorageDecorator() self.__storage.init() return
def init(self): """ Loader initializations work: subscribe to required events. Routine must invoke in BWPersonality module. """ if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) if self.__storage is None: self.__storage = PrbStorageDecorator() self.__storage.init() return
class _PrbControlLoader(object): __slots__ = ('__prbDispatcher', '__invitesManager', '__autoNotifier', '__peripheriesHandler', '__storage', '__isEnabled') def __init__(self): super(_PrbControlLoader, self).__init__() self.__prbDispatcher = None self.__invitesManager = None self.__autoNotifier = None self.__peripheriesHandler = None self.__storage = None self.__isEnabled = False return def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) if self.__storage is None: self.__storage = PrbStorageDecorator() self.__storage.init() return def fini(self): self.__removeDispatcher() if self.__invitesManager is not None: self.__invitesManager.fini() self.__invitesManager = None if self.__autoNotifier is not None: self.__autoNotifier.fini() self.__autoNotifier = None if self.__peripheriesHandler is not None: self.__peripheriesHandler.fini() self.__peripheriesHandler = None if self.__storage is not None: self.__storage.fini() self.__storage = None return def getDispatcher(self): return self.__prbDispatcher def getInvitesManager(self): return self.__invitesManager def getAutoInvitesNotifier(self): return self.__autoNotifier def getPeripheriesHandler(self): return self.__peripheriesHandler def getStorage(self): return self.__storage def isEnabled(self): return self.__isEnabled def setEnabled(self, enabled): if self.__isEnabled ^ enabled: self.__isEnabled = enabled if self.__isEnabled and self.__prbDispatcher is not None: self.__doStart() return def onAccountShowGUI(self, ctx): if self.__prbDispatcher is None: self.__prbDispatcher = _PrebattleDispatcher() if self.__isEnabled: self.__doStart() return def onAvatarBecomePlayer(self): self.__isEnabled = False self.__removeDispatcher() self.__invitesManager.onAvatarBecomePlayer() def onDisconnected(self): self.__isEnabled = False self.__removeDispatcher() self.__autoNotifier.stop() if self.__invitesManager is not None: self.__invitesManager.clear() if self.__autoNotifier is not None: self.__autoNotifier.stop() if self.__storage is not None: self.__storage.clear() return def __doStart(self): self.__storage.swap() self.__prbDispatcher.start() self.__invitesManager.start() self.__autoNotifier.start() self.__peripheriesHandler.activate() def __removeDispatcher(self): if self.__prbDispatcher is not None: self.__prbDispatcher.stop() self.__prbDispatcher = None return
class _PrbControlLoader(object): __slots__ = ('__prbDispatcher', '__invitesManager', '__autoNotifier', '__isEnabled') def __init__(self): super(_PrbControlLoader, self).__init__() self.__prbDispatcher = None self.__invitesManager = None self.__autoNotifier = None self.__isEnabled = False return def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager() self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier() return def fini(self): self.__removeDispatcher() if self.__invitesManager is not None: self.__invitesManager.fini() self.__invitesManager = None if self.__autoNotifier is not None: self.__autoNotifier.stop() self.__autoNotifier = None return def getDispatcher(self): return self.__prbDispatcher def getInvitesManager(self): return self.__invitesManager def getAutoInvitesNotifier(self): return self.__autoNotifier def isEnabled(self): return self.__isEnabled def setEnabled(self, enabled): if self.__isEnabled ^ enabled: self.__isEnabled = enabled if self.__isEnabled and self.__prbDispatcher is not None: self.__prbDispatcher.start(context.StartDispatcherCtx.fetch()) self.__autoNotifier.start() return def __removeDispatcher(self): if self.__prbDispatcher is not None: self.__prbDispatcher.stop() self.__prbDispatcher = None return def onAccountShowGUI(self, ctx): if self.__prbDispatcher is None: self.__prbDispatcher = _PrebattleDispatcher() self.__invitesManager.onAccountShowGUI() if self.__isEnabled: self.__prbDispatcher.start(context.StartDispatcherCtx(**ctx)) self.__autoNotifier.start() return def onAvatarBecomePlayer(self): self.__isEnabled = False self.__removeDispatcher() self.__invitesManager.onAvatarBecomePlayer() def onDisconnected(self): self.__isEnabled = False self.__removeDispatcher() self.__autoNotifier.stop() if self.__invitesManager is not None: self.__invitesManager.clear() if self.__autoNotifier is not None: self.__autoNotifier.stop() return
class _PrbControlLoader(object): __slots__ = ('__prbDispatcher', '__invitesManager', '__autoNotifier', '__peripheriesHandler', '__isEnabled', '__prbSettings') def __init__(self): super(_PrbControlLoader, self).__init__() self.__prbSettings = ({}, {}) self.__prbDispatcher = None self.__invitesManager = None self.__autoNotifier = None self.__peripheriesHandler = None self.__isEnabled = False return def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) return def fini(self): self.__removeDispatcher() self.__clearPrbSettings() if self.__invitesManager is not None: self.__invitesManager.fini() self.__invitesManager = None if self.__autoNotifier is not None: self.__autoNotifier.fini() self.__autoNotifier = None if self.__peripheriesHandler is not None: self.__peripheriesHandler.fini() self.__peripheriesHandler = None return def getDispatcher(self): return self.__prbDispatcher def getInvitesManager(self): return self.__invitesManager def getAutoInvitesNotifier(self): return self.__autoNotifier def getPeripheriesHandler(self): return self.__peripheriesHandler def isEnabled(self): return self.__isEnabled def setEnabled(self, enabled): if self.__isEnabled ^ enabled: self.__isEnabled = enabled if self.__isEnabled and self.__prbDispatcher is not None: ctxUpdate, settings = self.__prbSettings self.__doStart(StartDispatcherCtx.fetch(prbSettings=settings, **ctxUpdate)) return def onAccountShowGUI(self, ctx): if self.__prbDispatcher is None: self.__prbDispatcher = _PrebattleDispatcher() if self.__isEnabled: ctxUpdate, settings = self.__prbSettings ctx.update(ctxUpdate) self.__doStart(StartDispatcherCtx(prbSettings=settings, **ctx)) return def onAvatarBecomePlayer(self): self.__isEnabled = False self.__savePrbSettings() self.__removeDispatcher() self.__invitesManager.onAvatarBecomePlayer() def onDisconnected(self): self.__isEnabled = False self.__removeDispatcher() self.__clearPrbSettings() self.__autoNotifier.stop() if self.__invitesManager is not None: self.__invitesManager.clear() if self.__autoNotifier is not None: self.__autoNotifier.stop() return def __doStart(self, ctx): self.__prbDispatcher.start(ctx) self.__invitesManager.start() self.__autoNotifier.start() self.__peripheriesHandler.activate() self.__clearPrbSettings() def __removeDispatcher(self): if self.__prbDispatcher is not None: self.__prbDispatcher.stop() self.__prbDispatcher = None return def __savePrbSettings(self): if self.__prbDispatcher is not None: ctx, settings = self.__prbSettings for func in self.__prbDispatcher.getFunctionalCollection().getIterator(): if functional.isStatefulFunctional(func): funcCtx, funcStates = func.getStates() ctx.update(funcCtx) settings[func.getEntityType()] = funcStates return def __clearPrbSettings(self): self.__prbSettings = ({}, {})
class _PrbControlLoader(object): __slots__ = ( "__prbDispatcher", "__invitesManager", "__autoNotifier", "__peripheriesHandler", "__storage", "__isEnabled", ) def __init__(self): super(_PrbControlLoader, self).__init__() self.__prbDispatcher = None self.__invitesManager = None self.__autoNotifier = None self.__peripheriesHandler = None self.__storage = None self.__isEnabled = False return def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) if self.__storage is None: self.__storage = PrbStorageDecorator() self.__storage.init() return def fini(self): self.__removeDispatcher() if self.__invitesManager is not None: self.__invitesManager.fini() self.__invitesManager = None if self.__autoNotifier is not None: self.__autoNotifier.fini() self.__autoNotifier = None if self.__peripheriesHandler is not None: self.__peripheriesHandler.fini() self.__peripheriesHandler = None if self.__storage is not None: self.__storage.fini() self.__storage = None return def getDispatcher(self): return self.__prbDispatcher def getInvitesManager(self): return self.__invitesManager def getAutoInvitesNotifier(self): return self.__autoNotifier def getPeripheriesHandler(self): return self.__peripheriesHandler def getStorage(self): return self.__storage def isEnabled(self): return self.__isEnabled def setEnabled(self, enabled): if self.__isEnabled ^ enabled: self.__isEnabled = enabled if self.__isEnabled and self.__prbDispatcher is not None: self.__doStart() return def onAccountShowGUI(self, ctx): if self.__prbDispatcher is None: self.__prbDispatcher = _PrebattleDispatcher() if self.__isEnabled: self.__doStart() return def onAvatarBecomePlayer(self): self.__isEnabled = False self.__removeDispatcher() self.__invitesManager.onAvatarBecomePlayer() def onDisconnected(self): self.__isEnabled = False self.__removeDispatcher() self.__autoNotifier.stop() if self.__invitesManager is not None: self.__invitesManager.clear() if self.__autoNotifier is not None: self.__autoNotifier.stop() if self.__storage is not None: self.__storage.clear() return def __doStart(self): self.__storage.swap() self.__prbDispatcher.start() self.__invitesManager.start() self.__autoNotifier.start() self.__peripheriesHandler.activate() def __removeDispatcher(self): if self.__prbDispatcher is not None: self.__prbDispatcher.stop() self.__prbDispatcher = None return
class _PrbControlLoader(object): """ Loader for for next entities: - prebattle dispatcher. When player login to server, it creates prebattle dispatcher. And when GUI says isEnabled, it starts prebattle dispatcher. When player come to battle or login page, it removes prebattle dispatcher; - invites manager for invitation to prebattle; - notifier of auto invites. """ __slots__ = ('__prbDispatcher', '__invitesManager', '__autoNotifier', '__peripheriesHandler', '__storage', '__isEnabled') def __init__(self): """ Constructor for default initialization. """ super(_PrbControlLoader, self).__init__() self.__prbDispatcher = None self.__invitesManager = None self.__autoNotifier = None self.__peripheriesHandler = None self.__storage = None self.__isEnabled = False return def init(self): """ Loader initializations work: subscribe to required events. Routine must invoke in BWPersonality module. """ if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) if self.__storage is None: self.__storage = PrbStorageDecorator() self.__storage.init() g_playerEvents.onBootcampShowGUI += self.pe_onBootcampShowGUI return def fini(self): """ Loader finalizes work: unsubscribe from events, removes prebattle dispatcher. Routine must invoke in BWPersonality module. """ self.__removeDispatcher() if self.__invitesManager is not None: self.__invitesManager.fini() self.__invitesManager = None if self.__autoNotifier is not None: self.__autoNotifier.fini() self.__autoNotifier = None if self.__peripheriesHandler is not None: self.__peripheriesHandler.fini() self.__peripheriesHandler = None if self.__storage is not None: self.__storage.fini() self.__storage = None g_playerEvents.onBootcampShowGUI -= self.pe_onBootcampShowGUI return def getDispatcher(self): """ Gets prebattle dispatcher. Returns: prebattle dispatcher or None. Returns None when player come to battle or login page. """ return self.__prbDispatcher def getInvitesManager(self): """ Gets manager for prebattle invites. Returns: invites manager """ return self.__invitesManager def getAutoInvitesNotifier(self): """ Gets notifier for auto invites. Returns: auto notifier """ return self.__autoNotifier def getPeripheriesHandler(self): """ Gets notifier for auto invites. Returns: peripheries handler """ return self.__peripheriesHandler def getStorage(self): """ Gets storage decorator to hold local client settings. Returns: storage """ return self.__storage def isEnabled(self): """ Is dispatcher enabled. Returns: obvious one - is dispatcher enabled. """ return self.__isEnabled def setEnabled(self, enabled): """ Sets dispatcher enabled. Args: enabled: new state """ if self.__isEnabled ^ enabled: self.__isEnabled = enabled if self.__isEnabled and self.__prbDispatcher is not None: self.__doStart() return def onAccountShowGUI(self, ctx): """ Listener for player event - show gui. Initializes dispatcher if needed. Args: ctx: gui init context """ if self.__prbDispatcher is None: self.__prbDispatcher = _PreBattleDispatcher() if self.__isEnabled: self.__doStart() return def onAccountBecomeNonPlayer(self): """ Listener for player event - on become non player. Deletes dispatcher. """ self.__isEnabled = False self.__removeDispatcher() def onAvatarBecomePlayer(self): """ Listener for player event - on become avatar. Deletes dispatcher. """ self.__isEnabled = False self.__removeDispatcher() self.__invitesManager.onAvatarBecomePlayer() self.__storage.onAvatarBecomePlayer() def onDisconnected(self): """ Listener for connection manager event - on disconnected. Deletes dispatcher and clears all related data. """ self.__isEnabled = False self.__removeDispatcher() self.__autoNotifier.stop() if self.__invitesManager is not None: self.__invitesManager.clear() if self.__autoNotifier is not None: self.__autoNotifier.stop() if self.__storage is not None: self.__storage.clear() return def __doStart(self): """ Do all the job related to loader statr. """ self.__storage.swap() self.__prbDispatcher.start() self.__invitesManager.start() self.__autoNotifier.start() self.__peripheriesHandler.activate() def __removeDispatcher(self): """ Removes prebattle dispatcher. """ if self.__prbDispatcher is not None: self.__prbDispatcher.stop() self.__prbDispatcher = None return def pe_onBootcampShowGUI(self, prbEnable): self.onAccountShowGUI({}) if prbEnable: self.setEnabled(True)
class _PrbControlLoader(object): __slots__ = ('__prbDispatcher', '__invitesManager', '__autoNotifier', '__peripheriesHandler', '__isEnabled', '__prbSettings') def __init__(self): super(_PrbControlLoader, self).__init__() self.__prbSettings = ({}, {}) self.__prbDispatcher = None self.__invitesManager = None self.__autoNotifier = None self.__peripheriesHandler = None self.__isEnabled = False def init(self): if self.__invitesManager is None: self.__invitesManager = InvitesManager(self) self.__invitesManager.init() if self.__autoNotifier is None: self.__autoNotifier = AutoInvitesNotifier(self) if self.__peripheriesHandler is None: self.__peripheriesHandler = _PrbPeripheriesHandler(self) def fini(self): self.__removeDispatcher() self.__clearPrbSettings() if self.__invitesManager is not None: self.__invitesManager.fini() self.__invitesManager = None if self.__autoNotifier is not None: self.__autoNotifier.fini() self.__autoNotifier = None if self.__peripheriesHandler is not None: self.__peripheriesHandler.fini() self.__peripheriesHandler = None def getDispatcher(self): return self.__prbDispatcher def getInvitesManager(self): return self.__invitesManager def getAutoInvitesNotifier(self): return self.__autoNotifier def getPeripheriesHandler(self): return self.__peripheriesHandler def isEnabled(self): return self.__isEnabled def setEnabled(self, enabled): if self.__isEnabled ^ enabled: self.__isEnabled = enabled if self.__isEnabled and self.__prbDispatcher is not None: ctxUpdate, settings = self.__prbSettings self.__doStart( StartDispatcherCtx.fetch(prbSettings=settings, **ctxUpdate)) def onAccountShowGUI(self, ctx): if self.__prbDispatcher is None: self.__prbDispatcher = _PrebattleDispatcher() if self.__isEnabled: ctxUpdate, settings = self.__prbSettings ctx.update(ctxUpdate) self.__doStart(StartDispatcherCtx(prbSettings=settings, **ctx)) def onAvatarBecomePlayer(self): self.__isEnabled = False self.__savePrbSettings() self.__removeDispatcher() self.__invitesManager.onAvatarBecomePlayer() def onDisconnected(self): self.__isEnabled = False self.__removeDispatcher() self.__clearPrbSettings() self.__autoNotifier.stop() if self.__invitesManager is not None: self.__invitesManager.clear() if self.__autoNotifier is not None: self.__autoNotifier.stop() def __doStart(self, ctx): self.__prbDispatcher.start(ctx) self.__invitesManager.start() self.__autoNotifier.start() self.__peripheriesHandler.activate() self.__clearPrbSettings() def __removeDispatcher(self): if self.__prbDispatcher is not None: self.__prbDispatcher.stop() self.__prbDispatcher = None def __savePrbSettings(self): if self.__prbDispatcher is not None: ctx, settings = self.__prbSettings for func in self.__prbDispatcher.getFunctionalCollection( ).getIterator(): if functional.isStatefulFunctional(func): funcCtx, funcStates = func.getStates() ctx.update(funcCtx) settings[func.getEntityType()] = funcStates def __clearPrbSettings(self): self.__prbSettings = ({}, {})