Пример #1
0
def getActionDisabledTooltip(restriction, entity=None):
    if not len(restriction):
        return
    else:
        tooltip = None
        if restriction == PREBATTLE_RESTRICTION.CREW_NOT_FULL:
            tooltip = getCrewNotFullTooltip()
        elif restriction in PREBATTLE_RESTRICTION.VEHICLE_INVALID_STATES:
            tooltip = getVehicleStateInvalidTooltip(restriction)
        else:
            if entity:
                teamLimits = entity.getSettings().getTeamLimits(
                    entity.getPlayerTeam())
            else:
                LOG_ERROR('Entity is not defined')
                teamLimits = LIMIT_DEFAULTS
            if PREBATTLE_RESTRICTION.inVehClassLimit(restriction):
                tooltip = getVehicleClassInvalidTooltip(
                    teamLimits, restriction)
            elif restriction == PREBATTLE_RESTRICTION.LIMIT_TOTAL_LEVEL:
                tooltip = getTotalLevelInvalidTooltip(teamLimits, restriction)
            elif restriction == PREBATTLE_RESTRICTION.LIMIT_LEVEL:
                tooltip = getLevelInvalidTooltip(teamLimits, restriction)
            else:
                LOG_ERROR('Formatter not found', restriction)
        return tooltip
Пример #2
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))
Пример #3
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 = 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)
Пример #4
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)
Пример #5
0
def getActionDisabledTooltip(restriction, functional = None):
    if not len(restriction):
        return
    else:
        tooltip = None
        if restriction == PREBATTLE_RESTRICTION.CREW_NOT_FULL:
            tooltip = getCrewNotFullTooltip()
        elif restriction in PREBATTLE_RESTRICTION.VEHICLE_INVALID_STATES:
            tooltip = getVehicleStateInvalidTooltip(restriction)
        else:
            if functional:
                teamLimits = functional.getSettings().getTeamLimits(functional.getPlayerTeam())
            else:
                LOG_ERROR('Functional is not defined')
                teamLimits = LIMIT_DEFAULTS
            if PREBATTLE_RESTRICTION.inVehClassLimit(restriction):
                tooltip = getVehicleClassInvalidTooltip(teamLimits, restriction)
            elif restriction == PREBATTLE_RESTRICTION.LIMIT_TOTAL_LEVEL:
                tooltip = getTotalLevelInvalidTooltip(teamLimits, restriction)
            elif restriction == PREBATTLE_RESTRICTION.LIMIT_LEVEL:
                tooltip = getLevelInvalidTooltip(teamLimits, restriction)
            else:
                LOG_ERROR('Formatter not found', restriction)
        return tooltip
Пример #6
0
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))