예제 #1
0
    def setCrewData(self, crewLvl, skills):
        """
        Updates crew information
        :param crewLvl: int, one of gui.game_control.veh_comparison_basket.CREW_TYPES
        :param skills: set, [skillName, ...]
        :return: bool, True if new incoming data is not similar as existed, otherwise - False
        """
        if self.__crewLvl != crewLvl or self.__skills != skills:
            self.__crewLvl = crewLvl
            self.__skills = skills
            skillsDict = {}
            skillsByRoles = cmp_helpers.getVehicleCrewSkills(self.__vehicle)
            for idx, (role, skillsSet) in enumerate(skillsByRoles):
                sameSkills = skillsSet.intersection(self.__skills)
                if sameSkills:
                    skillsDict[idx] = sameSkills

            if crewLvl == CREW_TYPES.CURRENT:
                levelsByIndexes, nativeVehiclesByIndexes = cmp_helpers.getVehCrewInfo(
                    self.__vehicle.intCD)
                defRoleLevel = None
            else:
                levelsByIndexes = {}
                defRoleLevel = self.__crewLvl
                nativeVehiclesByIndexes = None
            self.__vehicle.crew = self.__vehicle.getCrewBySkillLevels(
                defRoleLevel, skillsDict, levelsByIndexes,
                nativeVehiclesByIndexes)
            self.__isCrewInvalid = True
            self.__isCurrVehParamsInvalid = True
        return self.__isCrewInvalid
    def setCrewData(self, crewLvl, skills):
        if self.__crewLvl != crewLvl or self.__skills != skills:
            self.__crewLvl = crewLvl
            self.__skills = skills
            skillsDict = {}
            skillsByRoles = cmp_helpers.getVehicleCrewSkills(self.__vehicle)
            for idx, (_, skillsSet) in enumerate(skillsByRoles):
                sameSkills = skillsSet.intersection(self.__skills)
                if sameSkills:
                    skillsDict[idx] = sameSkills

            if crewLvl == CrewTypes.CURRENT:
                levelsByIndexes, nativeVehiclesByIndexes = cmp_helpers.getVehCrewInfo(
                    self.__vehicle.intCD)
                defRoleLevel = None
            else:
                levelsByIndexes = {}
                defRoleLevel = self.__crewLvl
                nativeVehiclesByIndexes = None
            self.__vehicle.crew = self.__vehicle.getCrewBySkillLevels(
                defRoleLevel, skillsDict, levelsByIndexes,
                nativeVehiclesByIndexes)
            self.__isCrewInvalid = True
            self.__isCurrVehParamsInvalid = True
        return self.__isCrewInvalid
    def __packSkillsBlock():
        def __packSkill(crewRole, skills):
            skills = cmp_helpers.sortSkills(skills)
            skillsStr = ' '.join(
                (icons.makeImageTag(getSkillSmallIconPath(skillType), 14, 14,
                                    0, 0) for skillType in skills))
            return formatters.packCrewSkillsBlockData(
                text_styles.main(ITEM_TYPES.tankman_roles(crewRole)),
                skillsStr,
                getRoleWhiteIconPath(crewRole),
                padding={'left': -10})

        blocks = [
            formatters.packImageTextBlockData(title=text_styles.middleTitle(
                VEH_COMPARE.VEHCONF_TOOLTIPS_SKILLS_SKILLSLIST),
                                              padding={'bottom': 10})
        ]
        configurator_view = cmp_helpers.getCmpConfiguratorMainView()
        configured_vehicle = configurator_view.getCurrentVehicle()
        skills_by_roles = cmp_helpers.getVehicleCrewSkills(configured_vehicle)
        skills_by_roles.sort(
            key=lambda (role, skillsSet): Tankman.TANKMEN_ROLES_ORDER[role])
        blocks.extend((__packSkill(*data) for data in skills_by_roles))
        return formatters.packBuildUpBlockData(blocks,
                                               gap=0,
                                               padding={'bottom': -10})
예제 #4
0
    def __init__(self, vehicle, crewSkillLevel, selectedSkills):
        super(_CrewSkillsManager, self).__init__()
        self.__vehicle = vehicle
        self.__crewSkillLevel = None
        self.__selectedSkills = selectedSkills
        crewSkills = cmp_helpers.getVehicleCrewSkills(self.__vehicle)
        self.__rolesBySkills = defaultdict(set)
        self.__skillsByRoles = {}
        for idx, (role, skillsSet) in enumerate(crewSkills):
            for skill in skillsSet:
                self.__rolesBySkills[skill].add((idx, role))
                self.__skillsByRoles[role] = skillsSet

        self.changeCrewSkillLevel(crewSkillLevel)
        return