Пример #1
0
    def __setLimits(self, rosters, teamLimits):
        settings = self.prbFunctional.getSettings()
        self.__selectedDivision = settings[PREBATTLE_SETTING_NAME.DIVISION]
        totalLimit = prb_getters.getTotalLevelLimits(teamLimits)
        totalLevel = 0
        playersCount = 0
        classesLimit = dict(map(lambda vehClass: (vehClass, [0, prb_getters.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 = prb_getters.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)
Пример #2
0
    def __setLimits(self, rosters, teamLimits):
        totalLimit = prb_getters.getTotalLevelLimits(teamLimits)
        totalLevel = 0
        playersCount = 0
        classesLimit = dict(
            map(
                lambda vehClass:
                (vehClass,
                 [0, prb_getters.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,
                prb_getters.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)
Пример #3
0
    def __setLimits(self, rosters, teamLimits):
        settings = self.prbEntity.getSettings()
        self.__selectedDivision = settings[PREBATTLE_SETTING_NAME.DIVISION]
        totalLimit = prb_getters.getTotalLevelLimits(teamLimits)
        totalLevel = 0
        playersCount = 0
        classesLimit = dict(
            map(
                lambda vehClass:
                (vehClass,
                 [0, prb_getters.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 = prb_getters.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)
Пример #4
0
    def __updateLimits(self, teamLimits, rosters):
        levelLimits = {}
        for className in constants.VEHICLE_CLASSES:
            classLvlLimits = prb_getters.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_getters.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
Пример #5
0
    def __updateLimits(self, teamLimits, rosters):
        levelLimits = {}
        for className in constants.VEHICLE_CLASSES:
            classLvlLimits = prb_getters.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_getters.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
Пример #6
0
def getVehicleClassInvalidTooltip(teamsLimit, restriction):
    classTag = PREBATTLE_RESTRICTION.getVehClassRestrictions().get(restriction)
    minLevel, maxLevel = prb_getters.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))
Пример #7
0
    def __setLimits(self, rosters, teamLimits):
        totalLimit = prb_getters.getTotalLevelLimits(teamLimits)
        totalLevel = 0
        playersCount = 0
        classesLimit = dict(map(lambda vehClass: (vehClass, [0, prb_getters.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, prb_getters.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)
Пример #8
0
    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 = prb_getters.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 = prb_getters.getTotalLevelLimits(teamLimits)
            if not minLevel <= totalLevel <= maxLevel:
                isValid = False
                notValidReason = PREBATTLE_RESTRICTION.LIMIT_TOTAL_LEVEL
        return (isValid, notValidReason)
Пример #9
0
    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 = prb_getters.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 = prb_getters.getTotalLevelLimits(teamLimits)
            if not minLevel <= totalLevel <= maxLevel:
                isValid = False
                notValidReason = PREBATTLE_RESTRICTION.LIMIT_TOTAL_LEVEL
        return (isValid, notValidReason)
Пример #10
0
def getClassLevelLimitMessage4Vehicle(teamLimits):
    minLevel, maxLevel = prb_getters.getClassLevelLimits(teamLimits, g_currentVehicle.item.type)
    return i18n.makeString('#system_messages:prebattle/vehicleInvalid/limits/level', minLevel, maxLevel)
Пример #11
0
def getVehicleClassInvalidTooltip(teamsLimit, restriction):
    classTag = PREBATTLE_RESTRICTION.getVehClassRestrictions().get(restriction)
    minLevel, maxLevel = prb_getters.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))
Пример #12
0
def getClassLevelLimitMessage4Vehicle(teamLimits):
    minLevel, maxLevel = prb_getters.getClassLevelLimits(
        teamLimits, g_currentVehicle.item.type)
    return i18n.makeString(
        '#system_messages:prebattle/vehicleInvalid/limits/level', minLevel,
        maxLevel)