Esempio n. 1
0
    def createFunctional(self, dispatcher, ctx):
        clientPrb = prb_control.getClientPrebattle()
        if clientPrb is not None:
            if prb_control.isPrebattleSettingsReceived(prebattle=clientPrb):
                prbSettings = prb_control.getPrebattleSettings(prebattle=clientPrb)
                prbType = prb_control.getPrebattleType(settings=prbSettings)
                clazz = None
                if prbType in _SUPPORTED_FUNCTIONAL:
                    clazz = _SUPPORTED_FUNCTIONAL[prbType]
                if clazz:
                    prbFunctional = clazz(prbSettings)
                    for listener in dispatcher._globalListeners:
                        prbFunctional.addListener(listener())

                    createParams = ctx.getCreateParams()
                    if 'settings' in createParams and isStatefulFunctional(prbFunctional):
                        guiSettings = createParams['settings']
                        if guiSettings:
                            prbFunctional.applyStates(guiSettings.get(CTRL_ENTITY_TYPE.PREBATTLE))
                else:
                    LOG_ERROR('Prebattle with given type is not supported', prbType)
                    prbFunctional = PrbNotSupportedFunctional(prbSettings)
            else:
                prbFunctional = PrbInitFunctional()
        else:
            prbType = ctx.getPrbType()
            clazz = None
            if prbType in _SUPPORTED_INTRO:
                clazz = _SUPPORTED_INTRO[prbType]
            if clazz is None:
                clazz = NoPrbFunctional
            prbFunctional = clazz()
        return prbFunctional
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
    def createFunctional(self, dispatcher, ctx):
        clientPrb = prb_control.getClientPrebattle()
        if clientPrb is not None:
            if prb_control.isPrebattleSettingsReceived(prebattle=clientPrb):
                prbSettings = prb_control.getPrebattleSettings(
                    prebattle=clientPrb)
                prbType = prb_control.getPrebattleType(settings=prbSettings)
                clazz = None
                if prbType in _SUPPORTED_FUNCTIONAL:
                    clazz = _SUPPORTED_FUNCTIONAL[prbType]
                if clazz:
                    prbFunctional = clazz(prbSettings)
                    for listener in dispatcher._globalListeners:
                        prbFunctional.addListener(listener())

                    createParams = ctx.getCreateParams()
                    if 'settings' in createParams and isStatefulFunctional(
                            prbFunctional):
                        guiSettings = createParams['settings']
                        if guiSettings:
                            prbFunctional.applyStates(
                                guiSettings.get(CTRL_ENTITY_TYPE.PREBATTLE))
                else:
                    LOG_ERROR('Prebattle with given type is not supported',
                              prbType)
                    prbFunctional = PrbNotSupportedFunctional(prbSettings)
            else:
                prbFunctional = PrbInitFunctional()
        else:
            prbType = ctx.getPrbType()
            clazz = None
            if prbType in _SUPPORTED_INTRO:
                clazz = _SUPPORTED_INTRO[prbType]
            if clazz is None:
                clazz = NoPrbFunctional
            prbFunctional = clazz()
        return prbFunctional