def _processValidationResult(self, ctx, result):
     if result is not None and not result.isValid:
         if not (ctx.isInitial() and result.restriction == PREBATTLE_RESTRICTION.VEHICLE_NOT_READY):
             SystemMessages.pushMessage(messages.getInvalidVehicleMessage(result.restriction, self), type=SystemMessages.SM_TYPE.Error)
         return False
     else:
         return True
Exemplo n.º 2
0
    def doAction(self, action):
        if not g_currentVehicle.isPresent():
            SystemMessages.pushMessage(messages.getInvalidVehicleMessage(PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT), type=SystemMessages.SM_TYPE.Error)
            return False
        LOG_DEBUG('Do prebattle action', action)
        actionName = action.actionName
        if actionName == PREBATTLE_ACTION_NAME.LEAVE_RANDOM_QUEUE:
            self.exitFromRandomQueue()
            result = True
        elif actionName == PREBATTLE_ACTION_NAME.PREBATTLE_LEAVE:
            self.__prbFunctional.doLeaveAction(self)
            result = True
        elif actionName == PREBATTLE_ACTION_NAME.UNIT_LEAVE:
            self.__unitFunctional.doLeaveAction(self)
            result = True
        elif actionName in self.OPEN_PRB_LIST_BY_ACTION:
            entry = functional.createPrbEntry(self.OPEN_PRB_LIST_BY_ACTION[actionName])
            entry.doAction(action, dispatcher=self)
            result = True
        else:
            result = False
            for func in (self.__unitFunctional, self.__prbFunctional, self.__queueFunctional):
                if func.doAction(action=action, dispatcher=self):
                    result = True
                    break

        return result
Exemplo n.º 3
0
 def _processValidationResult(self, ctx, result):
     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)
         return False
     else:
         return True
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 doAction(self, action):
        if not g_currentVehicle.isPresent():
            SystemMessages.pushMessage(messages.getInvalidVehicleMessage(
                PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT),
                                       type=SystemMessages.SM_TYPE.Error)
            return False
        LOG_DEBUG('Do prebattle action', action)
        actionName = action.actionName
        if actionName == PREBATTLE_ACTION_NAME.LEAVE_RANDOM_QUEUE:
            self.exitFromRandomQueue()
            result = True
        elif actionName == PREBATTLE_ACTION_NAME.PREBATTLE_LEAVE:
            self.__prbFunctional.doLeaveAction(self)
            result = True
        elif actionName == PREBATTLE_ACTION_NAME.UNIT_LEAVE:
            self.__unitFunctional.doLeaveAction(self)
            result = True
        elif actionName in self.OPEN_PRB_LIST_BY_ACTION:
            entry = functional.createPrbEntry(
                self.OPEN_PRB_LIST_BY_ACTION[actionName])
            entry.doAction(action, dispatcher=self)
            result = True
        else:
            result = False
            for func in (self.__unitFunctional, self.__prbFunctional,
                         self.__queueFunctional):
                if func.doAction(action=action, dispatcher=self):
                    result = True
                    break

        return result
Exemplo n.º 6
0
 def doAction(self, action=None):
     if not g_currentVehicle.isPresent():
         SystemMessages.pushMessage(messages.getInvalidVehicleMessage(
             PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT),
                                    type=SystemMessages.SM_TYPE.Error)
         return False
     LOG_DEBUG('Do GUI action', action)
     return self.__collection.doAction(self.__factories, action)
Exemplo n.º 7
0
 def doAction(self, action=None):
     if not g_currentVehicle.isPresent():
         SystemMessages.pushMessage(
             messages.getInvalidVehicleMessage(PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT),
             type=SystemMessages.SM_TYPE.Error,
         )
         return False
     LOG_DEBUG("Do GUI action", action)
     return self.__collection.doAction(self.__factories, action)
Exemplo n.º 8
0
 def doAction(self, action=None):
     """
     Processes action that comes from GUI by current entity.
     Args:
         action: given player's action
     Returns:
         was this action successful
     """
     if not g_currentVehicle.isPresent():
         SystemMessages.pushMessage(messages.getInvalidVehicleMessage(
             PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT),
                                    type=SystemMessages.SM_TYPE.Error)
         return False
     LOG_DEBUG('Do GUI action', action)
     return self.__entity.doAction(action)
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 isParentControlActivated():
         events_dispatcher.showParentControlNotification()
         if callback:
             callback(False)
         return
     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)