Ejemplo n.º 1
0
 def __init__(self):
     handlers = {
         REQUEST_TYPE.PREBATTLES_LIST: self.requestList,
         REQUEST_TYPE.GET_ROSTER: self.requestRoster
     }
     super(CompanyIntroFunctional, self).__init__(PREBATTLE_TYPE.COMPANY,
                                                  _CompanyListRequester(),
                                                  handlers)
     self._rosterReq = PrbRosterRequester()
Ejemplo n.º 2
0
class CompanyIntroFunctional(IntroPrbFunctional):

    def __init__(self):
        handlers = {REQUEST_TYPE.PREBATTLES_LIST: self.requestList,
         REQUEST_TYPE.GET_ROSTER: self.requestRoster}
        super(CompanyIntroFunctional, self).__init__(PREBATTLE_TYPE.COMPANY, _CompanyListRequester(), handlers)
        self._rosterReq = PrbRosterRequester()

    def init(self, clientPrb = None, ctx = None):
        result = super(CompanyIntroFunctional, self).init()
        self._rosterReq.start(self._onPrbRosterReceived)
        g_eventDispatcher.loadCompany()
        result = FUNCTIONAL_INIT_RESULT.addIfNot(result, FUNCTIONAL_INIT_RESULT.LOAD_WINDOW)
        g_eventDispatcher.updateUI()
        return result

    def fini(self, clientPrb = None, woEvents = False):
        super(CompanyIntroFunctional, self).fini()
        if self._exit != FUNCTIONAL_EXIT.PREBATTLE:
            if not woEvents:
                g_eventDispatcher.unloadCompany()
            else:
                g_eventDispatcher.removeCompanyFromCarousel()
            g_eventDispatcher.updateUI()

    def canPlayerDoAction(self):
        return (not self._hasEntity, '')

    def doSelectAction(self, action):
        result = False
        if action.actionName == PREBATTLE_ACTION_NAME.COMPANY:
            g_eventDispatcher.showCompanyWindow()
            result = True
        return result

    def requestList(self, ctx, callback = None):
        if self._listReq.isInCooldown():
            self._listReq.fireCooldownEvent()
            if callback:
                callback(True)
        else:
            ctx.startProcessing(callback)
            self._listReq.request(ctx)

    def requestRoster(self, ctx, callback = None):
        ctx.startProcessing(callback)
        self._rosterReq.request(ctx)

    def _onPrbRosterReceived(self, prbID, roster):
        self._invokeListeners('onPrbRosterReceived', prbID, roster)
Ejemplo n.º 3
0
 def __init__(self, ctx = None):
     super(CompaniesWindow, self).__init__(LAZY_CHANNEL.COMPANIES)
     self.__rosterRequester = PrbRosterRequester()
     self.__listDP = None
Ejemplo n.º 4
0
class CompaniesWindow(PrebattlesListWindow, CompaniesWindowMeta):

    def __init__(self, ctx = None):
        super(CompaniesWindow, self).__init__(LAZY_CHANNEL.COMPANIES)
        self.__rosterRequester = PrbRosterRequester()
        self.__listDP = None



    def getDivisionsList(self):
        return companies_dps.getDivisionsList()



    @process
    def createCompany(self):
        yield self.prbDispatcher.create(prb_ctx.CompanySettingsCtx(waitingID='prebattle/create'))



    @process
    def joinCompany(self, prbID):
        yield self.prbDispatcher.join(prb_ctx.JoinCompanyCtx(prbID, waitingID='prebattle/join'))



    def refreshCompaniesList(self, owner, isNotInBattle, division):
        self.__getCompaniesList(isNotInBattle, division, owner)



    def requestPlayersList(self, prbID):
        self.__rosterRequester.request(prbID)



    def showFAQWindow(self):
        self.fireEvent(events.LoadViewEvent(MESSENGER_VIEW_ALIAS.FAQ_WINDOW), scope=EVENT_BUS_SCOPE.LOBBY)



    def getClientID(self):
        return channel_num_gen.getClientID4LazyChannel(LAZY_CHANNEL.COMPANIES)



    def onFocusIn(self, alias):
        self.fireEvent(FocusEvent(FocusEvent.COMPONENT_FOCUSED, {'clientID': self.getClientID()}))



    def onPrbListReceived(self, prebattles):
        if self.__listDP is not None:
            self.__listDP.buildList(prebattles)
            self.__listDP.refresh()



    def onPrbRosterReceived(self, prbID, roster):
        if self.__listDP is not None:
            idx = self.__listDP.setPlayers(prbID, roster)
            self.__listDP.refresh()
            self.as_showPlayersListS(idx)



    def _populate(self):
        super(CompaniesWindow, self)._populate()
        self.addListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY)
        self.__listDP = companies_dps.CompaniesDataProvider()
        self.__listDP.setFlashObject(self.as_getCompaniesListDPS())
        self.as_disableCreateButtonS(False)
        self.startGlobalListening()
        self.__rosterRequester.start(self.__onRosterReceived)
        self.as_setDefaultFilterS('', False, 0)
        self.__getCompaniesList()



    def _dispose(self):
        self.removeListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY)
        self.stopGlobalListening()
        self.__rosterRequester.stop()
        if self.__listDP is not None:
            self.__listDP._dispose()
            self.__listDP = None
        super(CompaniesWindow, self)._dispose()



    @process
    def __getCompaniesList(self, isNotInBattle = False, division = 0, owner = ''):
        yield self.prbDispatcher.sendPrbRequest(prb_ctx.RequestCompaniesCtx(isNotInBattle, division, owner))



    def __handleSetPrebattleCoolDown(self, event):
        if event.requestID is REQUEST_TYPE.PREBATTLES_LIST:
            self.as_setRefreshCoolDownS(event.coolDown)
Ejemplo n.º 5
0
class CompanyIntroFunctional(IntroPrbFunctional):
    def __init__(self):
        handlers = {
            REQUEST_TYPE.PREBATTLES_LIST: self.requestList,
            REQUEST_TYPE.GET_ROSTER: self.requestRoster
        }
        super(CompanyIntroFunctional, self).__init__(PREBATTLE_TYPE.COMPANY,
                                                     _CompanyListRequester(),
                                                     handlers)
        self._rosterReq = PrbRosterRequester()

    def init(self, clientPrb=None, ctx=None):
        result = super(CompanyIntroFunctional, self).init()
        self._rosterReq.start(self._onPrbRosterReceived)
        g_eventDispatcher.loadCompany()
        result = FUNCTIONAL_INIT_RESULT.addIfNot(
            result, FUNCTIONAL_INIT_RESULT.LOAD_WINDOW)
        g_eventDispatcher.updateUI()
        g_eventsCache.companies.onCompanyStateChanged += self.onCompanyStateChanged
        return result

    def fini(self, clientPrb=None, woEvents=False):
        super(CompanyIntroFunctional, self).fini()
        if self._exit != FUNCTIONAL_EXIT.PREBATTLE:
            if not woEvents:
                g_eventDispatcher.unloadCompany()
            else:
                g_eventDispatcher.removeCompanyFromCarousel()
            g_eventDispatcher.updateUI()
        g_eventsCache.companies.onCompanyStateChanged -= self.onCompanyStateChanged

    @prbDispatcherProperty
    def prbDispatcher(self):
        return None

    def onCompanyStateChanged(self, state):
        if not state:
            DialogsInterface.showDialog(
                self.getConfirmDialogMeta(FUNCTIONAL_EXIT.COMPANY_EXPIRED),
                self.__companyExpiredCallback)

    def canPlayerDoAction(self):
        return (not self._hasEntity, '')

    def doSelectAction(self, action):
        result = False
        if action.actionName == PREBATTLE_ACTION_NAME.COMPANY:
            g_eventDispatcher.showCompanyWindow()
            result = True
        return result

    def requestList(self, ctx, callback=None):
        if self._listReq.isInCooldown():
            self._listReq.fireCooldownEvent()
            if callback:
                callback(True)
        else:
            ctx.startProcessing(callback)
            self._listReq.request(ctx)

    def requestRoster(self, ctx, callback=None):
        ctx.startProcessing(callback)
        self._rosterReq.request(ctx)

    def _onPrbRosterReceived(self, prbID, roster):
        self._invokeListeners('onPrbRosterReceived', prbID, roster)

    def __companyExpiredCallback(self, _):
        ctx = LeavePrbCtx(waitingID='prebattle/leave')
        if self.prbDispatcher._setRequestCtx(ctx):
            self.leave(ctx)
Ejemplo n.º 6
0
 def __init__(self):
     handlers = {REQUEST_TYPE.PREBATTLES_LIST: self.requestList,
      REQUEST_TYPE.GET_ROSTER: self.requestRoster}
     super(CompanyIntroFunctional, self).__init__(PREBATTLE_TYPE.COMPANY, _CompanyListRequester(), handlers)
     self._rosterReq = PrbRosterRequester()
Ejemplo n.º 7
0
class CompanyIntroFunctional(IntroPrbFunctional):

    def __init__(self):
        handlers = {REQUEST_TYPE.PREBATTLES_LIST: self.requestList,
         REQUEST_TYPE.GET_ROSTER: self.requestRoster}
        super(CompanyIntroFunctional, self).__init__(PREBATTLE_TYPE.COMPANY, _CompanyListRequester(), handlers)
        self._rosterReq = PrbRosterRequester()

    def init(self, clientPrb = None, ctx = None):
        result = super(CompanyIntroFunctional, self).init()
        self._rosterReq.start(self._onPrbRosterReceived)
        g_eventDispatcher.loadCompany()
        result = FUNCTIONAL_FLAG.addIfNot(result, FUNCTIONAL_FLAG.LOAD_WINDOW)
        g_eventDispatcher.updateUI()
        g_eventsCache.companies.onCompanyStateChanged += self.onCompanyStateChanged
        return result

    def fini(self, clientPrb = None, woEvents = False):
        super(CompanyIntroFunctional, self).fini()
        if self._flags & FUNCTIONAL_FLAG.SWITCH == 0:
            if not woEvents:
                g_eventDispatcher.unloadCompany()
            else:
                g_eventDispatcher.removeCompanyFromCarousel()
            g_eventDispatcher.updateUI()
        g_eventsCache.companies.onCompanyStateChanged -= self.onCompanyStateChanged

    @prbDispatcherProperty
    def prbDispatcher(self):
        return None

    def onCompanyStateChanged(self, state):
        if not state:
            DialogsInterface.showDialog(rally_dialog_meta.createCompanyExpariedMeta(), self.__companyExpiredCallback)

    def canPlayerDoAction(self):
        return (not self._hasEntity, '')

    def doSelectAction(self, action):
        result = False
        if action.actionName == PREBATTLE_ACTION_NAME.COMPANY:
            g_eventDispatcher.showCompanyWindow()
            result = True
        return SelectResult(result, None)

    def requestList(self, ctx, callback = None):
        if self._listReq.isInCooldown():
            self._listReq.fireCooldownEvent()
            if callback:
                callback(True)
        else:
            ctx.startProcessing(callback)
            self._listReq.request(ctx)

    def requestRoster(self, ctx, callback = None):
        ctx.startProcessing(callback)
        self._rosterReq.request(ctx)

    def _onPrbRosterReceived(self, prbID, roster):
        self._invokeListeners('onPrbRosterReceived', prbID, roster)

    def __companyExpiredCallback(self, _):
        ctx = LeavePrbCtx(waitingID='prebattle/leave')
        if self.prbDispatcher.setRequestCtx(ctx):
            self.leave(ctx)
Ejemplo n.º 8
0
 def __init__(self, ctx=None):
     super(CompaniesWindow, self).__init__(LAZY_CHANNEL.COMPANIES)
     self.__rosterRequester = PrbRosterRequester()
     self.__listDP = None
     return
Ejemplo n.º 9
0
class CompaniesWindow(PrebattlesListWindow, CompaniesWindowMeta):
    def __init__(self, ctx=None):
        super(CompaniesWindow, self).__init__(LAZY_CHANNEL.COMPANIES)
        self.__rosterRequester = PrbRosterRequester()
        self.__listDP = None
        return

    def getDivisionsList(self):
        return companies_dps.getDivisionsList()

    @process
    def createCompany(self):
        yield self.prbDispatcher.create(
            prb_ctx.CompanySettingsCtx(waitingID='prebattle/create',
                                       flags=FUNCTIONAL_FLAG.SWITCH))

    @process
    def joinCompany(self, prbID):
        yield self.prbDispatcher.join(
            prb_ctx.JoinCompanyCtx(prbID,
                                   waitingID='prebattle/join',
                                   flags=FUNCTIONAL_FLAG.SWITCH))

    def refreshCompaniesList(self, owner, isNotInBattle, division):
        self.__getCompaniesList(isNotInBattle, division, owner)

    def requestPlayersList(self, prbID):
        self.__rosterRequester.request(prbID)

    def showFAQWindow(self):
        self.fireEvent(events.LoadViewEvent(MESSENGER_VIEW_ALIAS.FAQ_WINDOW),
                       scope=EVENT_BUS_SCOPE.LOBBY)

    def getClientID(self):
        return channel_num_gen.getClientID4LazyChannel(LAZY_CHANNEL.COMPANIES)

    def onFocusIn(self, alias):
        self.fireEvent(
            FocusEvent(FocusEvent.COMPONENT_FOCUSED,
                       {'clientID': self.getClientID()}))

    def onPrbListReceived(self, prebattles):
        if self.__listDP is not None:
            self.__listDP.buildList(prebattles)
            self.__listDP.refresh()
        return

    def onPrbRosterReceived(self, prbID, roster):
        if self.__listDP is not None:
            idx = self.__listDP.setPlayers(prbID, roster)
            self.__listDP.refresh()
            self.as_showPlayersListS(idx)
        return

    def _populate(self):
        super(CompaniesWindow, self)._populate()
        self.addListener(events.CoolDownEvent.PREBATTLE,
                         self.__handleSetPrebattleCoolDown,
                         scope=EVENT_BUS_SCOPE.LOBBY)
        self.__listDP = companies_dps.CompaniesDataProvider()
        self.__listDP.setFlashObject(self.as_getCompaniesListDPS())
        self.as_disableCreateButtonS(False)
        self.startGlobalListening()
        self.__rosterRequester.start(self.__onRosterReceived)
        self.as_setDefaultFilterS('', False, 0)
        self.__getCompaniesList()

    def _dispose(self):
        self.removeListener(events.CoolDownEvent.PREBATTLE,
                            self.__handleSetPrebattleCoolDown,
                            scope=EVENT_BUS_SCOPE.LOBBY)
        self.stopGlobalListening()
        self.__rosterRequester.stop()
        if self.__listDP is not None:
            self.__listDP._dispose()
            self.__listDP = None
        super(CompaniesWindow, self)._dispose()
        return

    @process
    def __getCompaniesList(self, isNotInBattle=False, division=0, owner=''):
        yield self.prbDispatcher.sendPrbRequest(
            prb_ctx.RequestCompaniesCtx(isNotInBattle, division, owner))

    def __handleSetPrebattleCoolDown(self, event):
        if event.requestID is REQUEST_TYPE.PREBATTLES_LIST:
            self.as_setRefreshCoolDownS(event.coolDown)
Ejemplo n.º 10
0
class CompaniesWindow(PrebattlesListWindow, CompaniesWindowMeta):

    def __init__(self):
        super(CompaniesWindow, self).__init__(LAZY_CHANNEL.COMPANIES)
        self.__listRequester = CompanyListRequester()
        self.__rosterRequester = PrbRosterRequester()
        self.__listDP = None
        return

    def getDivisionsList(self):
        return companies_dps.getDivisionsList()

    @process
    def createCompany(self):
        yield self.prbDispatcher.create(context.CompanySettingsCtx(waitingID='prebattle/create'))

    @process
    def joinCompany(self, prbID):
        yield self.prbDispatcher.join(context.JoinCompanyCtx(prbID, waitingID='prebattle/join'))

    def refreshCompaniesList(self, owner, isNotInBattle, division):
        self.__listRequester.request(context.RequestCompaniesCtx(isNotInBattle, division, owner))

    def requestPlayersList(self, prbID):
        self.__rosterRequester.request(prbID)

    def showFAQWindow(self):
        self.fireEvent(events.ShowWindowEvent(events.ShowWindowEvent.SHOW_FAQ_WINDOW), scope=EVENT_BUS_SCOPE.LOBBY)

    def getClientID(self):
        return channel_num_gen.getClientID4LazyChannel(LAZY_CHANNEL.COMPANIES)

    def onPrbFunctionalInited(self):
        self.as_disableCreateButtonS(True)

    def onPrbFunctionalFinished(self):
        self.as_disableCreateButtonS(False)

    def onIntroUnitFunctionalInited(self):
        self.as_disableCreateButtonS(True)

    def onIntroUnitFunctionalFinished(self):
        self.as_disableCreateButtonS(False)

    def onUnitFunctionalInited(self):
        self.as_disableCreateButtonS(True)

    def onUnitFunctionalFinished(self):
        self.as_disableCreateButtonS(False)

    def _populate(self):
        super(CompaniesWindow, self)._populate()
        self.addListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY)
        self.__listDP = companies_dps.CompaniesDataProvider()
        self.__listDP.setFlashObject(self.as_getCompaniesListDPS())
        self.as_disableCreateButtonS(self.prbDispatcher.hasModalEntity())
        self.startGlobalListening()
        self.__listRequester.start(self.__onCompaniesListReceived)
        self.__rosterRequester.start(self.__onRosterReceived)
        self.as_setDefaultFilterS('', False, 0)
        if not isRequestInCoolDown(REQUEST_TYPE.PREBATTLES_LIST):
            self.__listRequester.request(context.RequestCompaniesCtx(False, 0, ''))
        else:
            self.as_setRefreshCoolDownS(DEFAULT_PREBATTLE_COOLDOWN)

    def _dispose(self):
        self.removeListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY)
        self.stopGlobalListening()
        self.__listRequester.stop()
        self.__rosterRequester.stop()
        if self.__listDP is not None:
            self.__listDP._dispose()
            self.__listDP = None
        super(CompaniesWindow, self)._dispose()
        return

    def __onCompaniesListReceived(self, prebattles):
        if self.__listDP is not None:
            self.__listDP.buildList(prebattles)
            self.__listDP.refresh()
        return

    def __onRosterReceived(self, prbID, roster):
        if self.__listDP is not None:
            idx = self.__listDP.setPlayers(prbID, roster)
            self.__listDP.refresh()
            self.as_showPlayersListS(idx)
        return

    def __handleSetPrebattleCoolDown(self, event):
        if event.requestID is REQUEST_TYPE.PREBATTLES_LIST:
            self.as_setRefreshCoolDownS(event.coolDown)