def __updateLimits(self, teamLimits, rosters): levelLimits = {} for className in constants.VEHICLE_CLASSES: classLvlLimits = prb_control.getClassLevelLimits(teamLimits, className) levelLimits[className] = {'minLevel': classLvlLimits[0], 'maxLevel': classLvlLimits[1], 'maxCurLevel': 0} for roster, players in rosters.iteritems(): if roster & PREBATTLE_ROSTER.ASSIGNED: for player in players: vehicle = player.getVehicle() levelLimits[vehicle.type]['maxCurLevel'] = max(levelLimits[vehicle.type]['maxCurLevel'], vehicle.level) strlevelLimits = dict(((t, '') for t in constants.VEHICLE_CLASSES)) classesLimitsAreIdentical, commonInfo = self.__compareVehicleLimits(levelLimits) if classesLimitsAreIdentical: strlevelLimits['lightTank'] = self.__makeMinMaxString(commonInfo) else: for className in constants.VEHICLE_CLASSES: strlevelLimits[className] = self.__makeMinMaxString(levelLimits[className]) self.as_setClassesLimitsS(strlevelLimits, classesLimitsAreIdentical) nationsLimits = prb_control.getNationsLimits(teamLimits) nationsLimitsResult = None if nationsLimits is not None and len(nationsLimits) != len(nations.AVAILABLE_NAMES): nationsLimitsResult = [] for nation in nationsLimits: nationsLimitsResult.append({'icon': self.NATION_ICON_PATH % {'nation': nation}, 'tooltip': MENU.nations(nation)}) self.as_setNationsLimitsS(nationsLimitsResult)
def __setLimits(self, rosters, teamLimits): settings = self.prbFunctional.getSettings() self.__selectedDivision = settings[PREBATTLE_SETTING_NAME.DIVISION] totalLimit = getTotalLevelLimits(teamLimits) totalLevel = 0 playersCount = 0 classesLimit = dict(map(lambda vehClass: (vehClass, [0, getClassLevelLimits(teamLimits, vehClass)]), VEHICLE_CLASS_TAGS)) invalidVehs = [] if PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1]: totalLevel += self.__validateVehicle(playerInfo, classesLimit, invalidVehs) if playerInfo.isReady(): playersCount += 1 maxPlayerCount = getMaxSizeLimits(teamLimits)[0] classesLimits = map(self.__makeClassLimitItem, classesLimit.iteritems()) mixMax = self.__makeMinMaxString(totalLevel, totalLimit) self.__makeHeaderData(classesLimits, mixMax, maxPlayerCount) self.as_setTotalLimitLabelsS(self.__makeTotalLevelString(totalLevel, totalLimit)) self.as_setMaxCountLimitLabelS(self.__makeMaxCountLimitLabel(playersCount, maxPlayerCount)) if PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1]: self.__validateVehicle(playerInfo, classesLimit, invalidVehs) self.as_setInvalidVehiclesS(invalidVehs)
def __setLimits(self, rosters, teamLimits): totalLimit = getTotalLevelLimits(teamLimits) totalLevel = 0 playersCount = 0 classesLimit = dict( map( lambda vehClass: (vehClass, [0, getClassLevelLimits(teamLimits, vehClass)]), VEHICLE_CLASS_TAGS)) invalidVehs = [] if PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1]: totalLevel += self.__validateVehicle(playerInfo, classesLimit, invalidVehs) if playerInfo.isReady(): playersCount += 1 self.as_setClassesLimitsS( map(self.__makeClassLimitItem, classesLimit.iteritems())) self.as_setTotalLimitLabelsS( self.__makeTotalLevelString(totalLevel, totalLimit), self.__makeMinMaxString(totalLevel, totalLimit)) self.as_setMaxCountLimitLabelS( self.__makeMaxCountLimitLabel(playersCount, getMaxSizeLimits(teamLimits)[0])) if PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1]: self.__validateVehicle(playerInfo, classesLimit, invalidVehs) self.as_setInvalidVehiclesS(invalidVehs)
def __setLimits(self, rosters, teamLimits): settings = self.prbFunctional.getSettings() self.__selectedDivision = settings[PREBATTLE_SETTING_NAME.DIVISION] totalLimit = getTotalLevelLimits(teamLimits) totalLevel = 0 playersCount = 0 classesLimit = dict( map( lambda vehClass: (vehClass, [0, getClassLevelLimits(teamLimits, vehClass)]), VEHICLE_CLASS_TAGS)) invalidVehs = [] if PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1]: totalLevel += self.__validateVehicle(playerInfo, classesLimit, invalidVehs) if playerInfo.isReady(): playersCount += 1 maxPlayerCount = getMaxSizeLimits(teamLimits)[0] classesLimits = map(self.__makeClassLimitItem, classesLimit.iteritems()) mixMax = self.__makeMinMaxString(totalLevel, totalLimit) self.__makeHeaderData(classesLimits, mixMax, maxPlayerCount) self.as_setTotalLimitLabelsS( self.__makeTotalLevelString(totalLevel, totalLimit)) self.as_setMaxCountLimitLabelS( self.__makeMaxCountLimitLabel(playersCount, maxPlayerCount)) if PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1]: self.__validateVehicle(playerInfo, classesLimit, invalidVehs) self.as_setInvalidVehiclesS(invalidVehs)
def getVehicleClassInvalidTooltip(teamsLimit, restriction): classTag = PREBATTLE_RESTRICTION.getVehClassRestrictions().get(restriction) minLevel, maxLevel = getClassLevelLimits(teamsLimit, classTag) return makeTooltip( i18n.makeString( '#tooltips:redButton/disabled/{0:>s}/header'.format(restriction)), i18n.makeString( '#tooltips:redButton/disabled/{0:>s}/body'.format(restriction), minLevel, maxLevel))
def __updateLimits(self, teamLimits, rosters): levelLimits = {} for className in constants.VEHICLE_CLASSES: classLvlLimits = prb_control.getClassLevelLimits( teamLimits, className) levelLimits[className] = { 'minLevel': classLvlLimits[0], 'maxLevel': classLvlLimits[1], 'maxCurLevel': 0 } for roster, players in rosters.iteritems(): if roster & PREBATTLE_ROSTER.ASSIGNED: for player in players: vehicle = player.getVehicle() levelLimits[vehicle.type]['maxCurLevel'] = max( levelLimits[vehicle.type]['maxCurLevel'], vehicle.level) strlevelLimits = dict(((t, '') for t in constants.VEHICLE_CLASSES)) classesLimitsAreIdentical, commonInfo = self.__compareVehicleLimits( levelLimits) if classesLimitsAreIdentical: strlevelLimits['lightTank'] = self.__makeMinMaxString(commonInfo) else: for className in constants.VEHICLE_CLASSES: strlevelLimits[className] = self.__makeMinMaxString( levelLimits[className]) self.as_setClassesLimitsS(strlevelLimits, classesLimitsAreIdentical) nationsLimits = prb_control.getNationsLimits(teamLimits) nationsLimitsResult = None if nationsLimits is not None and len(nationsLimits) != len( nations.AVAILABLE_NAMES): nationsLimitsResult = [] for nation in nationsLimits: nationsLimitsResult.append({ 'icon': self.NATION_ICON_PATH % { 'nation': nation }, 'tooltip': MENU.nations(nation) }) self.as_setNationsLimitsS(nationsLimitsResult) return
def __setLimits(self, rosters, teamLimits): totalLimit = getTotalLevelLimits(teamLimits) totalLevel = 0 playersCount = 0 classesLimit = dict(map(lambda vehClass: (vehClass, [0, getClassLevelLimits(teamLimits, vehClass)]), VEHICLE_CLASS_TAGS)) invalidVehs = [] if PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1]: totalLevel += self.__validateVehicle(playerInfo, classesLimit, invalidVehs) if playerInfo.isReady(): playersCount += 1 self.as_setClassesLimitsS(map(self.__makeClassLimitItem, classesLimit.iteritems())) self.as_setTotalLimitLabelsS(self.__makeTotalLevelString(totalLevel, totalLimit), self.__makeMinMaxString(totalLevel, totalLimit)) self.as_setMaxCountLimitLabelS(self.__makeMaxCountLimitLabel(playersCount, getMaxSizeLimits(teamLimits)[0])) if PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1 in rosters: for playerInfo in rosters[PREBATTLE_ROSTER.UNASSIGNED_IN_TEAM1]: self.__validateVehicle(playerInfo, classesLimit, invalidVehs) self.as_setInvalidVehiclesS(invalidVehs)
def check(self, rosters, team, teamLimits): isValid, notValidReason = True, '' assignedRosters = rosters.get(team, {}) totalLevel, classLevels = self.__calculate(assignedRosters) for classTag in VEHICLE_CLASS_TAGS: minLevel, maxLevel = getClassLevelLimits(teamLimits, classTag) currentLevel = classLevels[classTag] vClassTags = PREBATTLE_RESTRICTION.getVehClassTags() if not (minLevel <= currentLevel <= maxLevel or currentLevel == 0): isValid = False if classTag in vClassTags: notValidReason = vClassTags[classTag] else: notValidReason = PREBATTLE_RESTRICTION.LIMIT_CLASSES if isValid: minLevel, maxLevel = getTotalLevelLimits(teamLimits) if not minLevel <= totalLevel <= maxLevel: isValid = False notValidReason = PREBATTLE_RESTRICTION.LIMIT_TOTAL_LEVEL return (isValid, notValidReason)
def getClassLevelLimitMessage4Vehicle(teamLimits): minLevel, maxLevel = getClassLevelLimits(teamLimits, g_currentVehicle.item.type) return i18n.makeString('#system_messages:prebattle/vehicleInvalid/limits/level', minLevel, maxLevel)
def getVehicleClassInvalidTooltip(teamsLimit, restriction): classTag = PREBATTLE_RESTRICTION.getVehClassRestrictions().get(restriction) minLevel, maxLevel = getClassLevelLimits(teamsLimit, classTag) return makeTooltip(i18n.makeString('#tooltips:redButton/disabled/{0:>s}/header'.format(restriction)), i18n.makeString('#tooltips:redButton/disabled/{0:>s}/body'.format(restriction), minLevel, maxLevel))
def getClassLevelLimitMessage4Vehicle(teamLimits): minLevel, maxLevel = getClassLevelLimits(teamLimits, g_currentVehicle.item.type) return i18n.makeString( '#system_messages:prebattle/vehicleInvalid/limits/level', minLevel, maxLevel)