def _setTeamReady(self, ctx, callback=None):
        if prb_getters.isParentControlActivated():
            g_eventDispatcher.showParentControlNotification()
            if callback:
                callback(False)
            return
        else:
            result = self._limits.isTeamValid()

            def _requestResponse(code, errStr):
                msg = messages.getInvalidTeamServerMessage(errStr, entity=self)
                if msg is not None:
                    SystemMessages.pushMessage(msg, type=SystemMessages.SM_TYPE.Error)
                ctx.onResponseReceived(code)
                return

            if result is None or result.isValid:
                ctx.startProcessing(callback)
                BigWorld.player().prb_teamReady(ctx.getTeam(), ctx.isForced(), ctx.getGamePlayMask(), _requestResponse)
            else:
                notValidReason = result.restriction
                LOG_ERROR('Team is invalid', notValidReason)
                if callback:
                    callback(False)
                SystemMessages.pushMessage(messages.getInvalidTeamMessage(notValidReason, entity=self), type=SystemMessages.SM_TYPE.Error)
            return
Exemplo n.º 2
0
 def _setPlayerReady(self, ctx, callback = None):
     """
     Sets player state to ready.
     Args:
         ctx: set player state request context
         callback: operation callback
     """
     if prb_getters.isParentControlActivated():
         g_eventDispatcher.showParentControlNotification()
         if callback:
             callback(False)
         return
     if g_currentVehicle.isObserver():
         if not self._processValidationResult(ctx, ValidationResult(False, PREBATTLE_RESTRICTION.VEHICLE_NOT_SUPPORTED)):
             if callback:
                 callback(False)
             return
     if ctx.doVehicleValidation():
         result = self._limits.isVehicleValid()
         if not self._processValidationResult(ctx, result):
             if callback:
                 callback(False)
             return
     rosterKey = self.getRosterKey()
     team, assigned = decodeRoster(rosterKey)
     if assigned and self.getTeamState(team=team).isInQueue():
         LOG_ERROR('Account assigned and team is ready or locked')
         if callback:
             callback(False)
         return
     ctx.startProcessing(callback)
     BigWorld.player().prb_ready(ctx.getVehicleInventoryID(), ctx.onResponseReceived)
Exemplo n.º 3
0
    def _setTeamReady(self, ctx, callback=None):
        if prb_getters.isParentControlActivated():
            g_eventDispatcher.showParentControlNotification()
            if callback:
                callback(False)
            return
        isValid, notValidReason = self._limits.isTeamValid()

        def _requestResponse(code, errStr):
            msg = messages.getInvalidTeamServerMessage(errStr, functional=self)
            if msg is not None:
                SystemMessages.pushMessage(msg, type=SystemMessages.SM_TYPE.Error)
            ctx.onResponseReceived(code)
            return

        if isValid:
            ctx.startProcessing(callback)
            BigWorld.player().prb_teamReady(ctx.getTeam(), ctx.isForced(), ctx.getGamePlayMask(), _requestResponse)
        else:
            LOG_ERROR("Team is invalid", notValidReason)
            if callback:
                callback(False)
            SystemMessages.pushMessage(
                messages.getInvalidTeamMessage(notValidReason, functional=self), type=SystemMessages.SM_TYPE.Error
            )
Exemplo n.º 4
0
 def _setPlayerReady(self, ctx, callback=None):
     if prb_getters.isParentControlActivated():
         g_eventDispatcher.showParentControlNotification()
         if callback:
             callback(False)
         return
     if ctx.doVehicleValidation():
         isValid, notValidReason = self._limits.isVehicleValid()
         if not isValid:
             SystemMessages.pushMessage(messages.getInvalidVehicleMessage(
                 notValidReason, self),
                                        type=SystemMessages.SM_TYPE.Error)
             if callback:
                 callback(False)
             return
     rosterKey = self.getRosterKey()
     team, assigned = decodeRoster(rosterKey)
     if assigned and self.getTeamState(team=team).isInQueue():
         LOG_ERROR('Account assigned and team is ready or locked')
         if callback:
             callback(False)
         return
     ctx.startProcessing(callback)
     BigWorld.player().prb_ready(ctx.getVehicleInventoryID(),
                                 ctx.onResponseReceived)
Exemplo n.º 5
0
 def _validateParentControl(self):
     """
     Validates parent control restrictions.
     Returns:
         has pre queue any restrictions
     """
     result = prb_getters.isParentControlActivated()
     if result:
         g_eventDispatcher.showParentControlNotification()
     return result
Exemplo n.º 6
0
 def gs_onTillBanNotification(self, isPlayTimeBan, timeTillBlock):
     if prb_getters.isParentControlActivated():
         self.__entity.resetPlayerState()
         key = '#system_messages:gameSessionControl/korea/{0:>s}'
         if isPlayTimeBan:
             SystemMessages.pushI18nMessage(key.format('playTimeNotification'), timeTillBlock, type=SystemMessages.SM_TYPE.Warning)
         else:
             _, blockTime = self.gameSession.getCurfewBlockTime()
             formatter = lambda t: time.strftime('%H:%M', time.localtime(t))
             SystemMessages.pushI18nMessage(key.format('midnightNotification'), type=SystemMessages.SM_TYPE.Warning, blockTime=formatter(blockTime))
Exemplo n.º 7
0
 def gs_onTillBanNotification(self, isPlayTimeBan, timeTillBlock):
     if prb_getters.isParentControlActivated():
         self.__collection.reset()
         key = '#system_messages:gameSessionControl/korea/{0:>s}'
         if isPlayTimeBan:
             SystemMessages.g_instance.pushI18nMessage(key.format('playTimeNotification'), timeTillBlock, type=SystemMessages.SM_TYPE.Warning)
         else:
             gameSession = game_control.g_instance.gameSession
             notifyStartTime, blockTime = gameSession.getCurfewBlockTime()
             formatter = lambda t: time.strftime('%H:%M', time.localtime(t))
             SystemMessages.g_instance.pushI18nMessage(key.format('midnightNotification'), type=SystemMessages.SM_TYPE.Warning, preBlockTime=formatter(notifyStartTime), blockTime=formatter(blockTime))
Exemplo n.º 8
0
 def gs_onTillBanNotification(self, isPlayTimeBan, timeTillBlock):
     if prb_getters.isParentControlActivated():
         self.__collection.reset()
         key = '#system_messages:gameSessionControl/korea/{0:>s}'
         if isPlayTimeBan:
             SystemMessages.g_instance.pushI18nMessage(
                 key.format('playTimeNotification'),
                 timeTillBlock,
                 type=SystemMessages.SM_TYPE.Warning)
         else:
             gameSession = game_control.g_instance.gameSession
             notifyStartTime, blockTime = gameSession.getCurfewBlockTime()
             formatter = lambda t: time.strftime('%H:%M', time.localtime(t))
             SystemMessages.g_instance.pushI18nMessage(
                 key.format('midnightNotification'),
                 type=SystemMessages.SM_TYPE.Warning,
                 preBlockTime=formatter(notifyStartTime),
                 blockTime=formatter(blockTime))
Exemplo n.º 9
0
 def _setPlayerReady(self, ctx, callback=None):
     """
     Sets player state to ready.
     Args:
         ctx: set player state request context
         callback: operation callback
     """
     if prb_getters.isParentControlActivated():
         g_eventDispatcher.showParentControlNotification()
         if callback:
             callback(False)
         return
     elif self._cooldown.validate(REQUEST_TYPE.SET_PLAYER_STATE,
                                  REQUEST_COOLDOWN.PREBATTLE_NOT_READY):
         if callback:
             callback(False)
         return
     else:
         if ctx.doVehicleValidation():
             result = self._limits.isVehicleValid()
             if result is not None and not result.isValid:
                 if not ctx.isInitial():
                     SystemMessages.pushMessage(
                         messages.getInvalidVehicleMessage(
                             result.restriction, self),
                         type=SystemMessages.SM_TYPE.Error)
                 if callback:
                     callback(False)
                 return
         rosterKey = self.getRosterKey()
         team, assigned = decodeRoster(rosterKey)
         if assigned and self.getTeamState(team=team).isInQueue():
             LOG_ERROR('Account assigned and team is ready or locked')
             if callback:
                 callback(False)
             return
         ctx.startProcessing(callback)
         BigWorld.player().prb_ready(ctx.getVehicleInventoryID(),
                                     ctx.onResponseReceived)
         self._cooldown.process(
             REQUEST_TYPE.SET_PLAYER_STATE,
             coolDown=REQUEST_COOLDOWN.PREBATTLE_NOT_READY)
         return
Exemplo n.º 10
0
 def _setPlayerReady(self, ctx, callback=None):
     if prb_getters.isParentControlActivated():
         g_eventDispatcher.showParentControlNotification()
         if callback:
             callback(False)
         return
     if ctx.doVehicleValidation():
         result = self._limits.isVehicleValid()
         if not self._processValidationResult(ctx, result):
             if callback:
                 callback(False)
             return
     rosterKey = self.getRosterKey()
     team, assigned = decodeRoster(rosterKey)
     if assigned and self.getTeamState(team=team).isInQueue():
         LOG_ERROR('Account assigned and team is ready or locked')
         if callback:
             callback(False)
         return
     ctx.startProcessing(callback)
     BigWorld.player().prb_ready(ctx.getVehicleInventoryID(), ctx.onResponseReceived)
Exemplo n.º 11
0
 def _setPlayerReady(self, ctx, callback = None):
     if prb_getters.isParentControlActivated():
         g_eventDispatcher.showParentControlNotification()
         if callback:
             callback(False)
         return
     if ctx.doVehicleValidation():
         isValid, notValidReason = self._limits.isVehicleValid()
         if not isValid:
             SystemMessages.pushMessage(messages.getInvalidVehicleMessage(notValidReason, self), type=SystemMessages.SM_TYPE.Error)
             if callback:
                 callback(False)
             return
     rosterKey = self.getRosterKey()
     team, assigned = decodeRoster(rosterKey)
     if assigned and self.getTeamState(team=team).isInQueue():
         LOG_ERROR('Account assigned and team is ready or locked')
         if callback:
             callback(False)
         return
     ctx.startProcessing(callback)
     BigWorld.player().prb_ready(ctx.getVehicleInventoryID(), ctx.onResponseReceived)
Exemplo n.º 12
0
 def gs_onTillBanNotification(self, isPlayTimeBan, timeTillBlock):
     """
     Game session listener for ban notification. Resets current entity to default.
     Args:
         isPlayTimeBan: is ban for play time
         timeTillBlock: time when block will be activated
     """
     if prb_getters.isParentControlActivated():
         self.__entity.resetPlayerState()
         key = '#system_messages:gameSessionControl/korea/{0:>s}'
         if isPlayTimeBan:
             SystemMessages.pushI18nMessage(
                 key.format('playTimeNotification'),
                 timeTillBlock,
                 type=SystemMessages.SM_TYPE.Warning)
         else:
             notifyStartTime, blockTime = self.gameSession.getCurfewBlockTime(
             )
             formatter = lambda t: time.strftime('%H:%M', time.localtime(t))
             SystemMessages.pushI18nMessage(
                 key.format('midnightNotification'),
                 type=SystemMessages.SM_TYPE.Warning,
                 preBlockTime=formatter(notifyStartTime),
                 blockTime=formatter(blockTime))
Exemplo n.º 13
0
 def _validateParentControl(self):
     result = prb_getters.isParentControlActivated()
     if result:
         g_eventDispatcher.showParentControlNotification()
     return result
Exemplo n.º 14
0
 def _validateParentControl(self):
     result = prb_getters.isParentControlActivated()
     if result:
         g_eventDispatcher.showParentControlNotification()
     return result