def _validate(self): if g_currentPreviewVehicle.isPresent(): return ValidationResult( False, PREBATTLE_RESTRICTION.PREVIEW_VEHICLE_IS_PRESENT) if not g_currentVehicle.isReadyToFight(): if not g_currentVehicle.isPresent(): return ValidationResult( False, PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT) if g_currentVehicle.isInBattle(): return ValidationResult( False, PREBATTLE_RESTRICTION.VEHICLE_IN_BATTLE) if not g_currentVehicle.isCrewFull(): return ValidationResult(False, PREBATTLE_RESTRICTION.CREW_NOT_FULL) if g_currentVehicle.isBroken(): return ValidationResult(False, PREBATTLE_RESTRICTION.VEHICLE_BROKEN) if g_currentVehicle.isDisabledInRoaming(): return ValidationResult(False, PREBATTLE_RESTRICTION.VEHICLE_ROAMING) if g_currentVehicle.isDisabledInPremIGR(): return ValidationResult( False, PREBATTLE_RESTRICTION.VEHICLE_IN_PREMIUM_IGR_ONLY) if g_currentVehicle.isDisabledInRent(): if g_currentVehicle.isPremiumIGR(): return ValidationResult( False, PREBATTLE_RESTRICTION.VEHICLE_IGR_RENTALS_IS_OVER) return ValidationResult( False, PREBATTLE_RESTRICTION.VEHICLE_RENTALS_IS_OVER) if g_currentVehicle.isRotationGroupLocked(): return ValidationResult( False, PREBATTLE_RESTRICTION.VEHICLE_ROTATION_GROUP_LOCKED) return super(CurrentVehicleActionsValidator, self)._validate()
def _validate(self): from bootcamp.BootcampGarage import g_bootcampGarage if not g_bootcampGarage.isLessonFinished: return ValidationResult(False, 'bootcamp/lessonNotFinished') if not g_bootcampGarage.isSecondVehicleSelected(): return ValidationResult(False, 'bootcamp/wrongVehicleSelected') return super(BootcampActionsValidator, self)._validate()
def _validate(self): if g_playerEvents.isPlayerEntityChanging: return ValidationResult(False, PREBATTLE_RESTRICTION.TEAM_IS_IN_QUEUE) _, assigned = decodeRoster(self._entity.getRosterKey()) if self._entity.getTeamState().isInQueue() and assigned: return ValidationResult(False, PREBATTLE_RESTRICTION.TEAM_IS_IN_QUEUE) return super(InQueueValidator, self)._validate()
def _validate(self): flags = self._entity.getFlags() if flags.isInArena(): return ValidationResult(False, UNIT_RESTRICTION.IS_IN_ARENA) return ValidationResult( False, UNIT_RESTRICTION.IS_IN_IDLE) if flags.isInIdle() else super( UnitStateValidator, self)._validate()
def _validate(self): roster = self._entity.getRosterSettings() stats = self._entity.getStats() if roster.getMinSlots() > stats.occupiedSlotsCount: return ValidationResult(False, UNIT_RESTRICTION.MIN_SLOTS) if stats.readyCount != stats.occupiedSlotsCount: return ValidationResult(False, UNIT_RESTRICTION.NOT_READY_IN_SLOTS) return super(UnitSlotsValidator, self)._validate()
def _validate(self): roster = self._entity.getRosterSettings() stats = self._entity.getStats() if stats.freeSlotsCount > roster.getMaxEmptySlots(): return ValidationResult(False, UNIT_RESTRICTION.FALLOUT_NOT_ENOUGH_PLAYERS) if stats.readyCount != stats.occupiedSlotsCount: return ValidationResult(False, UNIT_RESTRICTION.FALLOUT_NOT_ENOUGH_PLAYERS) return super(FalloutSlotsValidator, self)._validate()
def _validate(self): stats = self._entity.getStats() if not stats.curTotalLevel: return ValidationResult(False, UNIT_RESTRICTION.ZERO_TOTAL_LEVEL) roster = self._entity.getRosterSettings() if self._areVehiclesSelected(stats) and stats.curTotalLevel < roster.getMinTotalLevel(): return ValidationResult(False, UNIT_RESTRICTION.MIN_TOTAL_LEVEL, {'level': roster.getMinTotalLevel()}) return ValidationResult(False, UNIT_RESTRICTION.MAX_TOTAL_LEVEL, {'level': roster.getMaxTotalLevel()}) if stats.curTotalLevel > roster.getMaxTotalLevel() else super(UnitLevelsValidator, self)._validate()
def _validate(self): pInfo = self._entity.getPlayerInfo() if not pInfo.isInSlot: flags = self._entity.getFlags() if flags.isLocked(): return ValidationResult(False, UNIT_RESTRICTION.UNIT_IS_LOCKED) return ValidationResult(False, UNIT_RESTRICTION.NOT_IN_SLOT) return super(UnitPlayerValidator, self)._validate()
def _validate(self): pInfo = self._entity.getPlayerInfo() if not pInfo.isReady and g_currentVehicle.isPresent( ) and g_currentVehicle.item.type == VEHICLE_CLASS_NAME.SPG: if self._entity.getMaxSPGCount() <= 0: return ValidationResult(False, UNIT_RESTRICTION.SPG_IS_FORBIDDEN) if not self._entity.hasSlotForSPG(): return ValidationResult(False, UNIT_RESTRICTION.SPG_IS_FULL) return super(SPGForbiddenSquadVehiclesValidator, self)._validate()
def _validate(self): vInfos = self._getVehiclesInfo() if not findFirst(lambda v: not v.isEmpty(), vInfos, False): return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_NOT_SELECTED) else: for vInfo in vInfos: vehicle = vInfo.getVehicle() if vehicle is not None: vehicleIsNotSuitableForMode = self._isVehicleSuitableForMode(vehicle) if vehicleIsNotSuitableForMode is not None: return vehicleIsNotSuitableForMode if not vehicle.isReadyToPrebattle(checkForRent=self._isCheckForRent()): if vehicle.isBroken: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_BROKEN) if vehicle.isTooHeavy: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_TOO_HEAVY) if not vehicle.isCrewFull: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_CREW_NOT_FULL) if vehicle.rentalIsOver: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_RENT_IS_OVER) if vehicle.isInBattle: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_IS_IN_BATTLE) return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_NOT_VALID) state, _ = vehicle.getState() if state == Vehicle.VEHICLE_STATE.UNSUITABLE_TO_QUEUE: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_WRONG_MODE) return super(UnitVehiclesValidator, self)._validate()
def validateForMapbox(vehicle): lobbyContext = dependency.instance(ILobbyContext) config = lobbyContext.getServerSettings().mapbox if vehicle.level not in config.levels: return ValidationResult(False, PRE_QUEUE_RESTRICTION.LIMIT_LEVEL, {'levels': config.levels}) elif vehicle.intCD in config.forbiddenVehTypes: return ValidationResult(False, PRE_QUEUE_RESTRICTION.LIMIT_VEHICLE_TYPE, {'forbiddenType': vehicle.shortUserName}) else: return ValidationResult( False, PRE_QUEUE_RESTRICTION.LIMIT_VEHICLE_CLASS, {'forbiddenClass': vehicle.type }) if vehicle.type in config.forbiddenClassTags else None
def _validate(self): if not self._controller.isBattlesPossible(): return ValidationResult(False, PRE_QUEUE_RESTRICTION.MODE_NO_BATTLES, None) else: status, _, _ = self._controller.getPrimeTimeStatus() if status == PrimeTimeStatus.NOT_SET: return ValidationResult(False, PRE_QUEUE_RESTRICTION.MODE_NOT_SET, None) return ValidationResult( False, PRE_QUEUE_RESTRICTION.MODE_NOT_AVAILABLE, None) if status != PrimeTimeStatus.AVAILABLE else super( PrimeTimeValidator, self)._validate()
def _validate(self): stats = self._entity.getStats() levels = self._getInvalidLevels(stats) return ValidationResult( False, UNIT_RESTRICTION.INVALID_TOTAL_LEVEL, {'vehLevels': levels} ) if stats.occupiedSlotsCount > 1 and stats.freeSlotsCount > 0 and levels else super( ESportLevelsValidator, self)._validate()
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)
def _validate(self): mapboxCtrl = dependency.instance(IMapboxController) status, _, _ = mapboxCtrl.getPrimeTimeStatus() return ValidationResult( False, UNIT_RESTRICTION.CURFEW ) if status != PrimeTimeStatus.AVAILABLE else super( _MapboxStateValidator, self)._validate()
def _validate(self): vehicle = g_currentVehicle.item if vehicle.level > SANDBOX_MAX_VEHICLE_LEVEL or vehicle.isOnlyForEventBattles: return ValidationResult( False, PRE_QUEUE_RESTRICTION.LIMIT_LEVEL, {'levels': range(1, SANDBOX_MAX_VEHICLE_LEVEL + 1)}) return super(SandboxVehicleValidator, self)._validate()
def _validate(self): rankedController = dependency.instance(IRankedBattlesController) status, _, _ = rankedController.getPrimeTimeStatus() return ValidationResult( False, PRE_QUEUE_RESTRICTION.MODE_DISABLED ) if status != PRIME_TIME_STATUS.AVAILABLE else super( RankedPrimeTimeValidator, self)._validate()
def _validate(self): from gui.shared.ClanCache import g_clanCache from gui.LobbyContext import g_lobbyContext if not g_lobbyContext.getServerSettings().isFortsEnabled(): return ValidationResult(False, UNIT_RESTRICTION.FORT_DISABLED) provider = g_clanCache.fortProvider if provider: controller = provider.getController() if controller: sortiesHoursCtrl = controller.getSortiesCurfewCtrl() if sortiesHoursCtrl: availableAtThisTime, availableAtCurrServer = sortiesHoursCtrl.getStatus( ) if not availableAtThisTime or not availableAtCurrServer: return ValidationResult(False, UNIT_RESTRICTION.CURFEW) return super(SortiePlayerValidator, self)._validate()
def _validate(self): brController = dependency.instance(IBattleRoyaleController) status, _, _ = brController.getPrimeTimeStatus() return ValidationResult( False, UNIT_RESTRICTION.CURFEW ) if status != PrimeTimeStatus.AVAILABLE else super( _BattleRoyaleValidator, self)._validate()
def _setPlayerReady(self, ctx, callback=None): if g_currentVehicle.isObserver(): if not self._processValidationResult(ctx, ValidationResult(False, PREBATTLE_RESTRICTION.VEHICLE_NOT_SUPPORTED)): if callback: callback(False) return super(TrainingEntity, self)._setPlayerReady(ctx, callback)
def isVehicleValid(self): settings = self.__entity.getSettings() teamLimits = settings.getTeamLimits(self.__entity.getPlayerTeam()) for limit in self.__vehicleLimits: result, errorCode = limit.check(teamLimits) if not result: return ValidationResult(result, errorCode)
def _validate(self): levelsRange = self._entity.getRosterSettings().getLevelsRange() if g_currentVehicle.isPresent( ) and g_currentVehicle.item.level not in levelsRange: return ValidationResult(False, UNIT_RESTRICTION.VEHICLE_INVALID_LEVEL) return super(BalancedSquadVehiclesValidator, self)._validate()
def _validate(self): mapboxController = dependency.instance(IMapboxController) return ValidationResult( False, PRE_QUEUE_RESTRICTION.MODE_NOT_AVAILABLE ) if not mapboxController.isActive( ) or not mapboxController.isInPrimeTime() else super( MapboxStateValidator, self)._validate()
def _validate(self): if tutorialLoader.g_loader is not None: tutorial = tutorialLoader.g_loader.tutorial if tutorial is not None and not tutorial.isAllowedToFight(): return ValidationResult( False, PREBATTLE_RESTRICTION.TUTORIAL_NOT_FINISHED) return super(TutorialActionsValidator, self)._validate()
def _validate(self): epc = dependency.instance(IEventProgressionController) status, _, _ = epc.getPrimeTimeStatus() return ValidationResult( False, PRE_QUEUE_RESTRICTION.MODE_DISABLED ) if g_currentVehicle.isOnlyForBattleRoyaleBattles( ) and status != PrimeTimeStatus.AVAILABLE else super( BattleRoyaleValidator, self)._validate()
def _validate(self): lobbyContext = dependency.instance(ILobbyContext) vehicle = g_currentVehicle.item config = lobbyContext.getServerSettings().epicBattles return ValidationResult(False, PRE_QUEUE_RESTRICTION.LIMIT_LEVEL, { 'levels': config.validVehicleLevels }) if vehicle.level not in config.validVehicleLevels else super( EpicVehicleValidator, self)._validate()
def _validate(self): leaderEventEnqueueData = self._entity.getLeaderEventEnqueueData() if leaderEventEnqueueData is not None: result = True if not result: return ValidationResult(False, UNIT_RESTRICTION.UNIT_WRONG_DATA) return super(_EventBattleVehiclesValidator, self)._validate()
def _validate(self): stats = self._entity.getStats() roster = self._entity.getRoster() pInfo = self._entity.getPlayerInfo() hasEmptySlots = roster.MAX_SLOTS > stats.readyCount + roster.MAX_EMPTY_SLOTS return ValidationResult( False, UNIT_RESTRICTION.COMMANDER_VEHICLE_NOT_SELECTED ) if hasEmptySlots or not pInfo.isReady else None
def _validate(self): brController = dependency.instance(IBattleRoyaleController) status, _, _ = brController.getPrimeTimeStatus() return ValidationResult( False, PRE_QUEUE_RESTRICTION.MODE_NOT_AVAILABLE ) if g_currentVehicle.isOnlyForBattleRoyaleBattles( ) and status != PrimeTimeStatus.AVAILABLE else super( BattleRoyaleValidator, self)._validate()
def canPlayerDoAction(self): """ Can current player set ready state or go into battle. Validates it with actions validators. Returns: validation result object """ return self._actionsValidator.canPlayerDoAction() or ValidationResult()