def __setTankmenData(self):
        modulesAll = self.itemsCache.items.getVehicles(
            self.__getRoleCriteria(self.__selectedNation,
                                   self.__selectedVehClass,
                                   self.__selectedVehicle)).values()
        roles = []
        data = [self.__getTankmanRoleEmptyRow()]
        modulesAll.sort()
        selectedIndex = 0
        counter = 0
        skillsConfig = getSkillsConfig()
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({
                    'id':
                    role[0],
                    'label':
                    convert(skillsConfig.getSkill(role[0]).userString)
                })
                if self.__selectedTmanRole == role[0]:
                    selectedIndex = counter
                counter = counter + 1

        self.as_setTankmanRoleDataS(
            self.__getSendingData(data,
                                  len(data) > 1, selectedIndex))
    def getVehicleInfo(self):
        vehicle = self._itemsCache.items.getItemByCD(self.__vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ', self.__vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            skillsConfig = tankmen.getSkillsConfig()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel)
                tankmenParams.append({'tankmanType': i18n.convert(skillsConfig.getSkill(role).userString),
                 'value': tankmanLabel})

            paramsList = formatters.getFormattedParamsList(vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {'vehicleName': vehicle.longUserName,
             'vehicleDescription': vehicle.fullDescription,
             'vehicleImage': vehicle.icon,
             'vehicleLevel': vehicle.level,
             'vehicleNation': vehicle.nationID,
             'vehicleElite': vehicle.isElite,
             'vehicleType': vehicle.type,
             'propsData': self.__packParams(paramsList),
             'baseData': params['base'],
             'crewData': tankmenParams}
            self.as_setVehicleInfoS(info)
            return
    def getVehicleInfo(self):
        vehicle = g_itemsCache.items.getItemByCD(self.vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ', self.vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel)
                tankmenParams.append({'tankmanType': i18n.convert(tankmen.getSkillsConfig()[role].get('userString', '')),
                 'value': tankmanLabel})

            info = {'vehicleName': vehicle.longUserName,
             'vehicleDiscription': vehicle.fullDescription,
             'vehicleImage': vehicle.icon,
             'vehicleLevel': vehicle.level,
             'vehicleNation': vehicle.nationID,
             'vehicleElite': vehicle.isElite,
             'vehicleType': vehicle.type,
             'VehicleInfoPropsData': [ {'name': n,
                                      'value': v} for n, v in params['parameters'] ],
             'VehicleInfoBaseData': params['base'],
             'VehicleInfoCrewData': tankmenParams}
            self.as_setVehicleInfoS(info)
            return
示例#4
0
 def getSkillIconName(self, skillName):
     """Change icon for brotherhood skill
     :return:
     """
     if skillName == 'brotherhood':
         return 'sabaton_brotherhood.png'
     return i18n.convert(tankmen.getSkillsConfig().getSkill(skillName).icon)
示例#5
0
    def _calcCrewBonuses(self, crew, proxy):
        bonuses = dict()
        bonuses['equipment'] = 0
        for eq in self.eqs:
            if eq is not None:
                bonuses['equipment'] += eq.crewLevelIncrease

        bonuses['optDevices'] = self.descriptor.miscAttrs['crewLevelIncrease']
        bonuses['commander'] = 0
        commanderEffRoleLevel = 0
        bonuses['brotherhood'] = tankmen.getSkillsConfig()['brotherhood']['crewLevelIncrease']
        femalesCount = 0
        for tankmanID in crew:
            if tankmanID is None:
                bonuses['brotherhood'] = 0
                continue
            tmanInvData = proxy.inventory.getItems(GUI_ITEM_TYPE.TANKMAN, tankmanID)
            if not tmanInvData:
                continue
            tdescr = tankmen.TankmanDescr(compactDescr=tmanInvData['compDescr'])
            if tdescr.isFemale:
                femalesCount += 1
            if 'brotherhood' not in tdescr.skills or tdescr.skills.index('brotherhood') == len(tdescr.skills) - 1 and tdescr.lastSkillLevel != tankmen.MAX_SKILL_LEVEL:
                bonuses['brotherhood'] = 0
            if tdescr.role == Tankman.ROLES.COMMANDER:
                factor, addition = tdescr.efficiencyOnVehicle(self.descriptor)
                commanderEffRoleLevel = round(tdescr.roleLevel * factor + addition)

        if femalesCount and len(crew) != femalesCount:
            bonuses['brotherhood'] = 0
        bonuses['commander'] += round((commanderEffRoleLevel + bonuses['brotherhood'] + bonuses['equipment']) / tankmen.COMMANDER_ADDITION_RATIO)
        return bonuses
示例#6
0
def packTankmanSkill(skill):
    roleIcon = 'noImage.png'
    if skill.roleType in tankmen.getSkillsConfig():
        roleIcon = tankmen.getSkillsConfig()[skill.roleType]['icon']
    return {'name': skill.name,
     'level': skill.level,
     'userName': skill.userName,
     'description': skill.description,
     'shortDescription': skill.shortDescription,
     'icon': {'big': '%s/%s' % (skill.ICON_PATH_BIG, skill.icon),
              'small': '%s/%s' % (skill.ICON_PATH_SMALL, skill.icon),
              'role': '%s/%s' % (Tankman.ROLE_ICON_PATH_SMALL, roleIcon)},
     'isActive': skill.isActive,
     'isEnable': skill.isEnable,
     'roleType': skill.roleType,
     'isPerk': skill.isPerk}
    def onVehicleChanged(self, vehID):
        Waiting.show('updating')
        self.__selectedVehicle = vehID
        modulesAll = g_itemsCache.items.getVehicles(
            self.__getRoleCriteria(self.__selectedNation,
                                   self.__selectedVehClass,
                                   self.__selectedVehicle)).values()
        roles = []
        data = [self.__getTankmanRoleEmptyRow()]
        modulesAll.sort()
        selectedIndex = 0
        counter = 0
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({
                    'id':
                    role[0],
                    'label':
                    convert(getSkillsConfig()[role[0]]['userString'])
                })
                if self.__selectedTmanRole == role[0]:
                    selectedIndex = counter
                counter = counter + 1

        self.as_setTankmanRoleDataS(
            self.__getSendingData(data,
                                  len(data) > 1, selectedIndex))
        Waiting.hide('updating')
        self.onDataChange(self.__selectedNation, self.__selectedVehClass,
                          self.__selectedVehicle, self.__selectedTmanRole)
示例#8
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, tankType, typeID)).values()
        modulesAll.sort()
        for module in modulesAll:
            typesDP.append({'id': module.innationID,
             'label': module.shortUserName})
            for role in module.descriptor.type.crewRoles:
                if role[0] == roleType:
                    rolesDP.append({'id': role[0],
                     'label': convert(getSkillsConfig()[role[0]]['userString'])})

            break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
示例#9
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, tankType, typeID)).values()
        modulesAll.sort()
        for module in modulesAll:
            typesDP.append({'id': module.innationID,
             'label': module.shortUserName})
            for role in module.descriptor.type.crewRoles:
                if role[0] == roleType:
                    rolesDP.append({'id': role[0],
                     'label': convert(getSkillsConfig()[role[0]]['userString'])})

            break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
示例#10
0
 def _successHandler(self, code, ctx=None):
     html = makeHtmlString(path='html_templates:lobby/processors/system_messages', key='recruit', ctx={'fullName': self.recruitInfo.getFullUserName(),
      'rank': Tankman.getRankUserName(self.nationID, self.recruitInfo.getRankID()),
      'role': getSkillsConfig().getSkill(self.role).userString,
      'vehicleName': self.vehicleName,
      'roleLevel': self.recruitInfo.getRoleLevel()})
     return makeSuccess(html, msgType=SM_TYPE.Information, auxData=ctx)
示例#11
0
    def _calcCrewBonuses(self, crew, proxy):
        bonuses = dict()
        bonuses['equipment'] = 0
        for eq in self.eqs:
            if eq is not None:
                bonuses['equipment'] += eq.crewLevelIncrease

        bonuses['optDevices'] = self.descriptor.miscAttrs['crewLevelIncrease']
        bonuses['commander'] = 0
        commanderEffRoleLevel = 0
        bonuses['brotherhood'] = tankmen.getSkillsConfig()['brotherhood']['crewLevelIncrease']
        femalesCount = 0
        for tankmanID in crew:
            if tankmanID is None:
                bonuses['brotherhood'] = 0
                continue
            tmanInvData = proxy.inventory.getItems(GUI_ITEM_TYPE.TANKMAN, tankmanID)
            if not tmanInvData:
                continue
            tdescr = tankmen.TankmanDescr(compactDescr=tmanInvData['compDescr'])
            if tdescr.isFemale:
                femalesCount += 1
            if 'brotherhood' not in tdescr.skills or tdescr.skills.index('brotherhood') == len(tdescr.skills) - 1 and tdescr.lastSkillLevel != tankmen.MAX_SKILL_LEVEL:
                bonuses['brotherhood'] = 0
            if tdescr.role == Tankman.ROLES.COMMANDER:
                factor, addition = tdescr.efficiencyOnVehicle(self.descriptor)
                commanderEffRoleLevel = round(tdescr.roleLevel * factor + addition)

        if femalesCount and len(crew) != femalesCount:
            bonuses['brotherhood'] = 0
        bonuses['commander'] += round((commanderEffRoleLevel + bonuses['brotherhood'] + bonuses['equipment']) / tankmen.COMMANDER_ADDITION_RATIO)
        return bonuses
示例#12
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[0] == nationID and module.descriptor.type.id[1] == typeID:
                typesDP.append({'id': module.descriptor.type.id[1],
                 'label': module.descriptor.type.shortUserString})
                for role in module.descriptor.type.crewRoles:
                    if role[0] == roleType:
                        rolesDP.append({'id': role[0],
                         'label': convert(getSkillsConfig()[role[0]]['userString'])})

                break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
示例#13
0
 def __getCurrentSkillIcon(self, tankman):
     if self.__isNewSkillReady(tankman):
         return ('new_skill', 'new_skill.png')
     return (
         'role', '%s.png' % self.tmanDescr.role
     ) if self.tmanDescr.roleLevel != tankmen.MAX_SKILL_LEVEL or not self.tmanDescr.skills else (
         'skill',
         tankmen.getSkillsConfig().getSkill(self.tmanDescr.skills[-1]).icon)
示例#14
0
 def getSkillUserName(self, skillName):
     """Change description for brotherhood skill
     :param skillName:
     :return:
     """
     if skillName == 'brotherhood':
         return i18n.makeString(
             ITEM_TYPES.TANKMAN_SKILLS_BROTHERHOOD_SABATON)
     return tankmen.getSkillsConfig().getSkill(skillName).userString
示例#15
0
 def toDict(self):
     result = GUIItem.toDict(self)
     roleIcon = 'noImage.png'
     if self.roleType in tankmen.getSkillsConfig():
         roleIcon = tankmen.getSkillsConfig()[self.roleType]['icon']
     result.update({'name': self.name,
      'level': self.level,
      'userName': self.userName,
      'description': self.description,
      'shortDescription': self.shortDescription,
      'icon': {'big': '%s/%s' % (self.ICON_PATH_BIG, self.icon),
               'small': '%s/%s' % (self.ICON_PATH_SMALL, self.icon),
               'role': '%s/%s' % (Tankman.ROLE_ICON_PATH_SMALL, roleIcon)},
      'isActive': self.isActive,
      'isEnable': self.isEnable,
      'roleType': self.roleType,
      'isPerk': self.isPerk})
     return result
示例#16
0
 def __getCurrentSkillIcon(self):
     """
     Returns current studying skill type and icon filename
     (icon type, icon filename)
     """
     if self.__isNewSkillReady():
         return ('new_skill', 'new_skill.png')
     if self.tmanDescr.roleLevel != tankmen.MAX_SKILL_LEVEL or not len(self.tmanDescr.skills):
         return ('role', '%s.png' % self.tmanDescr.role)
     return ('skill', tankmen.getSkillsConfig()[self.tmanDescr.skills[-1]]['icon'])
示例#17
0
def getCrewNotFullTooltip():
    crew_list = ''
    vehicle = g_currentVehicle.item
    crewRoles = vehicle.descriptor.type.crewRoles
    skillsConfig = getSkillsConfig()
    for slotIdx, tman in vehicle.crew:
        if tman is None:
            userString = i18n.makeString(skillsConfig[crewRoles[slotIdx][0]]['userString']).lower()
            crew_list += (', ' if len(crew_list) != 0 else '') + userString

    return makeTooltip('#tooltips:redButton/disabled/crew/notFull/header', i18n.makeString('#tooltips:redButton/disabled/crew/notFull/body') % crew_list)
示例#18
0
def getCrewNotFullTooltip():
    crew_list = ''
    vehicle = g_currentVehicle.item
    crewRoles = vehicle.descriptor.type.crewRoles
    skillsConfig = getSkillsConfig()
    for slotIdx, tman in vehicle.crew:
        if tman is None:
            userString = i18n.makeString(skillsConfig[crewRoles[slotIdx][0]]['userString']).lower()
            crew_list += (', ' if len(crew_list) != 0 else '') + userString

    return makeTooltip('#tooltips:redButton/disabled/crew/notFull/header', i18n.makeString('#tooltips:redButton/disabled/crew/notFull/body') % crew_list)
示例#19
0
    def getVehicleInfo(self):
        Waiting.show('updating')
        items = yield ItemsRequester().request()
        vehicle = items.getItemByCD(self.vehicleDescr.type.compactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ',
                      self.vehicleDescr.type.compactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName,
                                                     tankman.lastUserName,
                                                     tankman.roleLevel)
                tankmenParams.append({
                    'tankmanType':
                    i18n.convert(tankmen.getSkillsConfig()[role].get(
                        'userString', '')),
                    'value':
                    tankmanLabel
                })

            info = {
                'vehicleName':
                vehicle.longUserName,
                'vehicleDiscription':
                vehicle.fullDescription,
                'vehicleImage':
                vehicle.icon,
                'vehicleLevel':
                vehicle.level,
                'vehicleNation':
                vehicle.nationID,
                'vehicleElite':
                vehicle.isElite,
                'vehicleType':
                vehicle.type,
                'VehicleInfoPropsData': [{
                    'name': n,
                    'value': v
                } for n, v in params['parameters']],
                'VehicleInfoBaseData':
                params['base'],
                'VehicleInfoCrewData':
                tankmenParams
            }
            self.as_setVehicleInfoS(info)
            Waiting.hide('updating')
            return
示例#20
0
 def __getCurrentSkillIcon(self):
     """
     Returns current studying skill type and icon filename
     (icon type, icon filename)
     """
     if self.__isNewSkillReady():
         return ('new_skill', 'new_skill.png')
     if self.tmanDescr.roleLevel != tankmen.MAX_SKILL_LEVEL or not len(
             self.tmanDescr.skills):
         return ('role', '%s.png' % self.tmanDescr.role)
     return ('skill',
             tankmen.getSkillsConfig()[self.tmanDescr.skills[-1]]['icon'])
示例#21
0
 def toDict(self):
     result = GUIItem.toDict(self)
     roleIcon = 'noImage.png'
     if self.roleType in tankmen.getSkillsConfig():
         roleIcon = tankmen.getSkillsConfig()[self.roleType]['icon']
     result.update({
         'name': self.name,
         'level': self.level,
         'userName': self.userName,
         'description': self.description,
         'shortDescription': self.shortDescription,
         'icon': {
             'big': '%s/%s' % (self.ICON_PATH_BIG, self.icon),
             'small': '%s/%s' % (self.ICON_PATH_SMALL, self.icon),
             'role': '%s/%s' % (Tankman.ROLE_ICON_PATH_SMALL, roleIcon)
         },
         'isActive': self.isActive,
         'isEnable': self.isEnable,
         'roleType': self.roleType,
         'isPerk': self.isPerk
     })
     return result
    def vehicleEnemySpottingTime(self):
        kpiFactor = self.__kpi.getFactor('vehicleEnemySpottingTime')
        skillName = 'gunner_rancorous'
        skillDuration = 0.0
        skillBattleBoosters = None
        for battleBoosters in self.__vehicle.battleBoosters.installed:
            if battleBoosters is not None and battleBoosters.getAffectedSkillName() == skillName:
                skillBattleBoosters = battleBoosters

        skillLearnt = isSkillLearnt(skillName, self.__vehicle)
        if skillLearnt and skillBattleBoosters is not None:
            skillDuration = skillBattleBoosters.descriptor.duration
        elif skillLearnt or skillBattleBoosters is not None:
            skillDuration = tankmen.getSkillsConfig().getSkill(skillName).duration
        return kpiFactor + skillDuration
示例#23
0
    def getVehicleInfo(self):
        vehicle = self._itemsCache.items.getItemByCD(
            self.__vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ',
                      self.__vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            skillsConfig = tankmen.getSkillsConfig()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    lastUserName = tankman.lastUserName
                    if tankman.skinID != NO_CREW_SKIN_ID and self._lobbyContext.getServerSettings(
                    ).isCrewSkinsEnabled():
                        skinItem = self._itemsCache.items.getCrewSkin(
                            tankman.skinID)
                        lastUserName = i18n.makeString(skinItem.getLastName())
                    tankmanLabel = '%s %s (%d%%)' % (
                        tankman.rankUserName, lastUserName, tankman.roleLevel)
                tankmenParams.append({
                    'tankmanType':
                    i18n.convert(skillsConfig.getSkill(role).userString),
                    'value':
                    tankmanLabel
                })

            roleStr = getRoleTextWithLabel(vehicle.role, vehicle.roleLabel)
            paramsList = formatters.getFormattedParamsList(
                vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {
                'vehicleName': vehicle.longUserName,
                'vehicleDescription': vehicle.fullDescription,
                'vehicleImage': vehicle.icon,
                'vehicleLevel': vehicle.level,
                'vehicleNation': vehicle.nationID,
                'vehicleElite': vehicle.isElite,
                'vehicleType': vehicle.type,
                'propsData': self.__packParams(paramsList),
                'baseData': params['base'],
                'crewData': tankmenParams,
                'roleStr': roleStr
            }
            self.as_setVehicleInfoS(info)
            return
示例#24
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show("updating")
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, vclass, typeID)).values()
        roles = []
        data = [{"id": None, "label": DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({"id": role[0], "label": convert(getSkillsConfig()[role[0]]["userString"])})

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide("updating")
        return
示例#25
0
    def __setCrewViewModelData(self, tankSlotVM, guiVh):
        crewListVM = tankSlotVM.getCrewList()
        roles = guiVh.descriptor.type.crewRoles
        crew = sortCrew(guiVh.crew, roles)
        skillsConfig = getSkillsConfig()
        isDogInCrew = 'dog' in guiVh.tags
        iconsSmall = self.__icons.tankmen.icons.small
        for slotIdx, tankman in crew:
            tankmanVM = NationChangeTankmanModel()
            if tankman is not None:
                if tankman.skinID != NO_CREW_SKIN_ID and self.__lobbyContext.getServerSettings(
                ).isCrewSkinsEnabled():
                    skinItem = self.__itemsCache.items.getCrewSkin(
                        tankman.skinID)
                    tankmanVM.setImage(
                        iconsSmall.crewSkins.dyn(skinItem.getIconName())())
                else:
                    tankmanVM.setImage(
                        iconsSmall.dyn(
                            getIconResourceName(tankman.extensionLessIcon))())
                tankmanVM.setInvID(tankman.invID)
            else:
                role = roles[slotIdx][0]
                tankmanVM.setImage(
                    self.__icons.tankmen.icons.small.silhouette_mask())
                tankmanVM.setIsSimpleTooltip(True)
                tankmanVM.setSimpleTooltipHeader(
                    convert(skillsConfig.getSkill(role).userString))
                tankmanVM.setSimpleTooltipBody(guiVh.longUserName)
            R.strings.multinational_vehicles.changeScreen.title.header()
            crewListVM.addViewModel(tankmanVM)

        if isDogInCrew:
            tankmanVM = NationChangeTankmanModel()
            dogTooltip = R.strings.tooltips.hangar.crew.rudy.dog.dyn(
                guiVh.nationName)
            tankmanVM.setImage(self.__icons.tankmen.icons.small.ussr_dog_1())
            tankmanVM.setIsSimpleTooltip(True)
            tankmanVM.setSimpleTooltipHeader(backport.text(
                dogTooltip.header()))
            tankmanVM.setSimpleTooltipBody(backport.text(dogTooltip.body()))
            tankmanVM.setIsDog(True)
            crewListVM.addViewModel(tankmanVM)
        if any(
            (tankman[1] is not None for tankman in guiVh.crew)) or isDogInCrew:
            tankSlotVM.setNoCrew(False)
        return
示例#26
0
    def __setData(self, *args):
        items = self.itemsCache.items
        tankman = items.getTankman(self.tmanInvID)
        if tankman is None:
            self.onWindowClose()
            return
        else:
            dropSkillsCost = []
            for k in sorted(items.shop.dropSkillsCost.keys()):
                skillCost = items.shop.dropSkillsCost[k]
                defaultSkillCots = items.shop.defaults.dropSkillsCost[k]
                price = Money(**skillCost)
                defaultPrice = Money(**defaultSkillCots)
                action = None
                if price != defaultPrice:
                    key = '{}DropSkillsCost'.format(
                        price.getCurrency(byWeight=True))
                    action = packActionTooltipData(
                        ACTION_TOOLTIPS_TYPE.ECONOMICS, key, True, price,
                        defaultPrice)
                skillCost['action'] = action
                dropSkillsCost.append(skillCost)

            skills_count = tankmen.getSkillsConfig().getNumberOfActiveSkills()
            lenSkills = len(tankman.skills)
            availableSkillsCount = skills_count - lenSkills
            hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (
                tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL
                or not lenSkills)
            self.as_setDataS({
                'money':
                items.stats.money.toMoneyTuple(),
                'tankman':
                packTankman(tankman, isCountPermanentSkills=False),
                'dropSkillsCost':
                dropSkillsCost,
                'hasNewSkills':
                hasNewSkills,
                'newSkills':
                tankman.newSkillCount,
                'defaultSavingMode':
                0,
                'texts':
                self.__getTexts()
            })
            return
示例#27
0
def packTankmanSkill(skill):
    if skill.roleType in tankmen.getSkillsConfig():
        roleIconPath = Tankman.getRoleSmallIconPath(skill.roleType)
    else:
        roleIconPath = ''
    return {'name': skill.name,
     'level': skill.level,
     'userName': skill.userName,
     'description': skill.description,
     'shortDescription': skill.shortDescription,
     'icon': {'big': Tankman.getSkillBigIconPath(skill.name),
              'small': Tankman.getSkillSmallIconPath(skill.name),
              'role': roleIconPath},
     'isActive': skill.isActive,
     'isEnable': skill.isEnable,
     'roleType': skill.roleType,
     'isPerk': skill.isPerk}
示例#28
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show('updating')
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, vclass, typeID)).values()
        roles = []
        data = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({'id': role[0],
                 'label': convert(getSkillsConfig()[role[0]]['userString'])})

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide('updating')
        return
示例#29
0
    def onShowRecruitWindow(self, callbackID):
        credits, gold = g_itemsCache.items.stats.money
        upgradeParams = yield DeprecatedStatsRequester().getTankmanCost()
        data = [credits, gold, round(upgradeParams[1]["credits"]), upgradeParams[2]["gold"], len(ROLES)]
        for role in ROLES:
            data.append(role)
            data.append(convert(getSkillsConfig()[role]["userString"]))

        unlocks = yield DeprecatedStatsRequester().getUnlocks()
        modulesAll = yield Requester("vehicle").getFromShop()
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks:
                data.append(module.type)
                data.append(module.descriptor.type.id[0])
                data.append(module.descriptor.type.id[1])
                data.append(module.descriptor.type.shortUserString)
示例#30
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{
            'id': None,
            'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW
        }, {
            'id': nationID,
            'label': MENU.nations(nations.NAMES[int(nationID)])
        }]
        classesDP = [{
            'id': None,
            'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW
        }, {
            'id':
            tankType,
            'label':
            DIALOGS.recruitwindow_vehicleclassdropdown(tankType)
        }]
        typesDP = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[
                    0] == nationID and module.descriptor.type.id[1] == typeID:
                typesDP.append({
                    'id': module.descriptor.type.id[1],
                    'label': module.descriptor.type.shortUserString
                })
                for role in module.descriptor.type.crewRoles:
                    if role[0] == roleType:
                        rolesDP.append({
                            'id':
                            role[0],
                            'label':
                            convert(getSkillsConfig()[role[0]]['userString'])
                        })

                break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP,
                                            rolesDP)
        return
    def __setTankmenData(self):
        skillsConfig = getSkillsConfig()
        hasRoles = self.__hasPredefinedTmanRoles()
        if hasRoles and len(self.__predefinedTmanRoles) == 1:
            data = []
            for roleName in self.__predefinedTmanRoles:
                data.append(
                    _packItemVO(
                        roleName,
                        convert(skillsConfig.getSkill(roleName).userString)))

            selectedIndex = 0
        else:
            modulesAll = self.itemsCache.items.getVehicles(
                self.__getRoleCriteria(self.__selectedNationIdx,
                                       self.__selectedVehClass,
                                       self.__selectedVehicle)).values()
            roles = []
            data = [self.__getTankmanRoleEmptyRow()]
            modulesAll.sort()
            selectedIndex = 0
            counter = 0
            for module in modulesAll:
                for role in module.descriptor.type.crewRoles:
                    roleName = role[0]
                    if roleName in roles:
                        continue
                    if not hasRoles or roleName in self.__predefinedTmanRoles:
                        roles.append(roleName)
                        data.append(
                            _packItemVO(
                                roleName,
                                convert(
                                    skillsConfig.getSkill(
                                        roleName).userString)))
                        if self.__selectedTmanRole == roleName:
                            selectedIndex = counter
                    counter += 1

        self.as_setTankmanRoleDataS(
            self.__getSendingData(data,
                                  len(data) > 1, selectedIndex))
示例#32
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show('updating')
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        roles = []
        data = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[0] == nationID and module.descriptor.type.id[1] == typeID:
                for role in module.descriptor.type.crewRoles:
                    if role[0] not in roles:
                        roles.append(role[0])
                        data.append({'id': role[0],
                         'label': convert(getSkillsConfig()[role[0]]['userString'])})

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide('updating')
        return
示例#33
0
def packTankmanSkill(skill, isPermanent=False):
    if skill.roleType in tankmen.getSkillsConfig():
        roleIconPath = Tankman.getRoleSmallIconPath(skill.roleType)
    else:
        roleIconPath = ""
    return {
        "name": skill.name,
        "level": skill.level,
        "userName": skill.userName,
        "description": skill.description,
        "shortDescription": skill.shortDescription,
        "icon": {
            "big": Tankman.getSkillBigIconPath(skill.name),
            "small": Tankman.getSkillSmallIconPath(skill.name),
            "role": roleIconPath,
        },
        "isActive": skill.isActive,
        "isEnable": skill.isEnable,
        "roleType": skill.roleType,
        "isPerk": skill.isPerk,
        "isPermanent": isPermanent,
    }
示例#34
0
    def onShowRecruitWindow(self, callbackID):
        credits, gold = g_itemsCache.items.stats.money
        upgradeParams = yield StatsRequester().getTankmanCost()
        data = [
            credits, gold,
            round(upgradeParams[1]['credits']), upgradeParams[2]['gold'],
            len(ROLES)
        ]
        for role in ROLES:
            data.append(role)
            data.append(convert(getSkillsConfig()[role]['userString']))

        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks:
                data.append(module.type)
                data.append(module.descriptor.type.id[0])
                data.append(module.descriptor.type.id[1])
                data.append(module.descriptor.type.shortUserString)
示例#35
0
def packTankmanSkill(skill, isPermanent=False):
    if skill.roleType in tankmen.getSkillsConfig():
        roleIconPath = Tankman.getRoleSmallIconPath(skill.roleType)
    else:
        roleIconPath = ''
    return {
        'name': skill.name,
        'level': skill.level,
        'userName': skill.userName,
        'description': skill.description,
        'shortDescription': skill.shortDescription,
        'icon': {
            'big': Tankman.getSkillBigIconPath(skill.name),
            'small': Tankman.getSkillSmallIconPath(skill.name),
            'role': roleIconPath
        },
        'isActive': skill.isActive,
        'isEnable': skill.isEnable,
        'roleType': skill.roleType,
        'isPerk': skill.isPerk,
        'isPermanent': isPermanent
    }
    def onVehicleChanged(self, vehID):
        Waiting.show('updating')
        self.__selectedVehicle = vehID
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(self.__selectedNation, self.__selectedVehClass, self.__selectedVehicle)).values()
        roles = []
        data = [self.__getTankmanRoleEmptyRow()]
        modulesAll.sort()
        selectedIndex = 0
        counter = 0
        for module in modulesAll:
            for role in module.descriptor.type.crewRoles:
                if role[0] in roles:
                    continue
                roles.append(role[0])
                data.append({'id': role[0],
                 'label': convert(getSkillsConfig()[role[0]]['userString'])})
                if self.__selectedTmanRole == role[0]:
                    selectedIndex = counter
                counter = counter + 1

        self.as_setTankmanRoleDataS(self.__getSendingData(data, len(data) > 1, selectedIndex))
        Waiting.hide('updating')
        self.onDataChange(self.__selectedNation, self.__selectedVehClass, self.__selectedVehicle, self.__selectedTmanRole)
示例#37
0
    def updateRoleDropdown(self, nationID, vclass, typeID):
        Waiting.show('updating')
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        roles = []
        data = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll.sort()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[
                    0] == nationID and module.descriptor.type.id[1] == typeID:
                for role in module.descriptor.type.crewRoles:
                    if role[0] not in roles:
                        roles.append(role[0])
                        data.append({
                            'id':
                            role[0],
                            'label':
                            convert(getSkillsConfig()[role[0]]['userString'])
                        })

        self.flashObject.as_setRoleDropdown(data)
        Waiting.hide('updating')
        return
示例#38
0
def getSkillUserName(skillName):
    return tankmen.getSkillsConfig()[skillName]["userString"]
    def updateTankmen(self, diff=None):
        Waiting.show('updateTankmen')
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            allTankmen = self.itemsCache.items.getTankmen()
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            skillsConfig = getSkillsConfig()
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (
                        tankmenDescrs[lessMastered] is None or
                        compareMastery(tankmenDescrs[lessMastered].descriptor,
                                       tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({
                    'tankmanID':
                    tman.invID if tman is not None else None,
                    'roleType':
                    role,
                    'role':
                    convert(skillsConfig.getSkill(role).userString),
                    'roleIcon':
                    Tankman.getRoleBigIconPath(role),
                    'nationID':
                    vehicle.nationID,
                    'typeID':
                    vehicle.innationID,
                    'slot':
                    slotIdx,
                    'vehicleType':
                    vehicle.shortUserName,
                    'tankType':
                    vehicle.type,
                    'vehicleElite':
                    vehicle.isPremium or vehicle.isPremiumIGR,
                    'roles':
                    list(vehicle.descriptor.type.crewRoles[slotIdx])
                })

            tankmenData = []
            for tankman in allTankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = self.itemsCache.items.getItemByCD(
                    tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                skills_count = skillsConfig.getNumberOfActiveSkills()
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append({
                        'tankmanID':
                        tankman.invID,
                        'id':
                        str(tankman.skills.index(skill)),
                        'name':
                        skill.userName,
                        'desc':
                        skill.description,
                        'icon':
                        skill.icon,
                        'level':
                        skill.level,
                        'active':
                        skill.isEnable and skill.isActive
                    })

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({
                        'buy': True,
                        'buyCount': newSkillsCount - 1,
                        'tankmanID': tankman.invID,
                        'level': lastNewSkillLvl
                    })
                tankmanData = {
                    'fullName':
                    tankman.fullUserName,
                    'lastName':
                    tankman.lastUserName or tankman.firstUserName,
                    'rank':
                    tankman.rankUserName,
                    'specializationLevel':
                    tankman.realRoleLevel[0],
                    'role':
                    tankman.roleUserName,
                    'vehicleType':
                    tankmanVehicle.shortUserName,
                    'iconFile':
                    tankman.icon,
                    'rankIconFile':
                    tankman.iconRank,
                    'roleIconFile':
                    Tankman.getRoleBigIconPath(tankman.descriptor.role),
                    'contourIconFile':
                    tankmanVehicle.iconContour,
                    'tankmanID':
                    tankman.invID,
                    'nationID':
                    tankman.nationID,
                    'typeID':
                    tankmanVehicle.innationID,
                    'inTank':
                    tankman.isInTank,
                    'roleType':
                    tankman.descriptor.role,
                    'tankType':
                    tankmanVehicle.type,
                    'efficiencyLevel':
                    tankman.efficiencyRoleLevel,
                    'bonus':
                    bonus_role_level,
                    'lastSkillLevel':
                    tankman.descriptor.lastSkillLevel,
                    'isLessMastered':
                    vehicle.crewIndices.get(tankman.invID) == lessMastered
                    and vehicle.isXPToTman,
                    'compact':
                    tankman.strCD,
                    'availableSkillsCount':
                    skills_count,
                    'skills':
                    skillsList
                }
                self.__updateTankmanDataByCrewSkin(tankman, tankmanData)
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({
                'showRecruit': self._showRecruit,
                'roles': roles,
                'tankmen': tankmenData
            })
            dogName = ''
            if 'dog' in self.itemsCache.items.getItemByCD(
                    g_currentVehicle.item.intCD).tags:
                dogName = backport.text(
                    R.strings.menu.hangar.crew.rody.dog.dyn(
                        vehicle.nationName).name())
            self.as_dogResponseS(dogName)
            tooltipId = TOOLTIPS.HANGAR_CREW_RUDY_DOG + vehicle.nationName
            self.as_setDogTooltipS(tooltipId)
        Waiting.hide('updateTankmen')
        return
示例#40
0
def getSkillUserDescription(skillName):
    return tankmen.getSkillsConfig()[skillName]['description']
示例#41
0
def getSkillUserName(skillName):
    return tankmen.getSkillsConfig()[skillName]['userString']
示例#42
0
def getRoleIconName(role):
    return tankmen.getSkillsConfig()[role]["icon"]
示例#43
0
 def iconRole(self):
     """ Tankman's role icon filename. """
     return tankmen.getSkillsConfig()[self.descriptor.role]['icon']
示例#44
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        if g_currentVehicle.isPresent():
            tankmen = g_itemsCache.items.getTankmen()
            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (
                        tankmenDescrs[lessMastered] is None or
                        compareMastery(tankmenDescrs[lessMastered].descriptor,
                                       tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({
                    'tankmanID':
                    tman.invID if tman is not None else None,
                    'roleType':
                    role,
                    'role':
                    convert(getSkillsConfig()[role]['userString']),
                    'roleIcon':
                    Tankman.getRoleBigIconPath(role),
                    'nationID':
                    vehicle.nationID,
                    'typeID':
                    vehicle.innationID,
                    'slot':
                    slotIdx,
                    'vehicleType':
                    vehicle.shortUserName,
                    'tankType':
                    vehicle.type,
                    'vehicleElite':
                    vehicle.isPremium or vehicle.isPremiumIGR,
                    'roles':
                    list(vehicle.descriptor.type.crewRoles[slotIdx])
                })

            tankmenData = []
            for tankman in tankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = g_itemsCache.items.getItemByCD(
                    tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                skills_count = len(list(ACTIVE_SKILLS))
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append({
                        'tankmanID':
                        tankman.invID,
                        'id':
                        str(tankman.skills.index(skill)),
                        'name':
                        skill.userName,
                        'desc':
                        skill.description,
                        'icon':
                        skill.icon,
                        'level':
                        skill.level,
                        'active':
                        skill.isEnable and skill.isActive
                    })

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({
                        'buy': True,
                        'buyCount': newSkillsCount - 1,
                        'tankmanID': tankman.invID,
                        'level': lastNewSkillLvl
                    })
                tankmanData = {
                    'firstName':
                    tankman.firstUserName,
                    'lastName':
                    tankman.lastUserName,
                    'rank':
                    tankman.rankUserName,
                    'specializationLevel':
                    tankman.realRoleLevel[0],
                    'role':
                    tankman.roleUserName,
                    'vehicleType':
                    tankmanVehicle.shortUserName,
                    'iconFile':
                    tankman.icon,
                    'rankIconFile':
                    tankman.iconRank,
                    'roleIconFile':
                    Tankman.getRoleBigIconPath(tankman.descriptor.role),
                    'contourIconFile':
                    tankmanVehicle.iconContour,
                    'tankmanID':
                    tankman.invID,
                    'nationID':
                    tankman.nationID,
                    'typeID':
                    tankmanVehicle.innationID,
                    'inTank':
                    tankman.isInTank,
                    'roleType':
                    tankman.descriptor.role,
                    'tankType':
                    tankmanVehicle.type,
                    'efficiencyLevel':
                    tankman.efficiencyRoleLevel,
                    'bonus':
                    bonus_role_level,
                    'lastSkillLevel':
                    tankman.descriptor.lastSkillLevel,
                    'isLessMastered':
                    vehicle.crewIndices.get(tankman.invID) == lessMastered
                    and vehicle.isXPToTman,
                    'compact':
                    tankman.strCD,
                    'availableSkillsCount':
                    skills_count,
                    'skills':
                    skillsList
                }
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({'roles': roles, 'tankmen': tankmenData})
            dogName = ''
            if 'dog' in g_itemsCache.items.getItemByCD(
                    g_currentVehicle.item.intCD).tags:
                dogName = MENU.HANGAR_CREW_RODY_DOG_NAME
            self.as_dogResponseS(dogName)
        Waiting.hide('updateTankmen')
        return
示例#45
0
 def userName(self):
     """ Returns skill name represented as user-friendly string. """
     return tankmen.getSkillsConfig()[self.name]['userString']
示例#46
0
 def icon(self):
     """ Returns skill icon filename. """
     return convert(tankmen.getSkillsConfig()[self.name]['icon'])
示例#47
0
    def updateTankmen(self):
        Waiting.show("updateTankmen")
        if g_currentVehicle.isPresent():
            tankmen = g_itemsCache.items.getTankmen()
            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses["commander"]
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if (
                    slotIdx > 0
                    and tman is not None
                    and (
                        tankmenDescrs[lessMastered] is None
                        or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0
                    )
                ):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append(
                    {
                        "tankmanID": tman.invID if tman is not None else None,
                        "roleType": role,
                        "role": convert(getSkillsConfig()[role]["userString"]),
                        "roleIcon": Tankman.getRoleBigIconPath(role),
                        "nationID": vehicle.nationID,
                        "typeID": vehicle.innationID,
                        "slot": slotIdx,
                        "vehicleType": vehicle.shortUserName,
                        "tankType": vehicle.type,
                        "vehicleElite": vehicle.isPremium or vehicle.isPremiumIGR,
                        "roles": list(vehicle.descriptor.type.crewRoles[slotIdx]),
                    }
                )

            tankmenData = []
            for tankman in tankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != "commander" else 0.0
                skills_count = len(list(ACTIVE_SKILLS))
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append(
                        {
                            "tankmanID": tankman.invID,
                            "id": str(tankman.skills.index(skill)),
                            "name": skill.userName,
                            "desc": skill.description,
                            "icon": skill.icon,
                            "level": skill.level,
                            "active": skill.isEnable and skill.isActive,
                        }
                    )

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({"buy": True, "tankmanID": tankman.invID, "level": lastNewSkillLvl})
                tankmanData = {
                    "firstName": tankman.firstUserName,
                    "lastName": tankman.lastUserName,
                    "rank": tankman.rankUserName,
                    "specializationLevel": tankman.realRoleLevel[0],
                    "role": tankman.roleUserName,
                    "vehicleType": tankmanVehicle.shortUserName,
                    "iconFile": tankman.icon,
                    "rankIconFile": tankman.iconRank,
                    "roleIconFile": Tankman.getRoleBigIconPath(tankman.descriptor.role),
                    "contourIconFile": tankmanVehicle.iconContour,
                    "tankmanID": tankman.invID,
                    "nationID": tankman.nationID,
                    "typeID": tankmanVehicle.innationID,
                    "inTank": tankman.isInTank,
                    "roleType": tankman.descriptor.role,
                    "tankType": tankmanVehicle.type,
                    "efficiencyLevel": tankman.efficiencyRoleLevel,
                    "bonus": bonus_role_level,
                    "lastSkillLevel": tankman.descriptor.lastSkillLevel,
                    "isLessMastered": vehicle.crewIndices.get(tankman.invID) == lessMastered and vehicle.isXPToTman,
                    "compact": tankman.strCD,
                    "availableSkillsCount": skills_count,
                    "skills": skillsList,
                }
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({"roles": roles, "tankmen": tankmenData})
            dogName = ""
            if "dog" in g_itemsCache.items.getItemByCD(g_currentVehicle.item.intCD).tags:
                dogName = MENU.HANGAR_CREW_RODY_DOG_NAME
            self.as_dogResponseS(dogName)
        Waiting.hide("updateTankmen")
        return
示例#48
0
def getSkillIconName(skillName):
    return i18n.convert(tankmen.getSkillsConfig()[skillName]["icon"])
示例#49
0
def getRoleUserName(role):
    return i18n.convert(tankmen.getSkillsConfig()[role]["userString"])
示例#50
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        tankmen = yield Requester('tankman').getFromInventory()
        vehicles = yield Requester('vehicle').getFromInventory()
        vehicle = None
        if g_currentVehicle.isPresent():
            for veh in vehicles:
                if veh.inventoryId == g_currentVehicle.invID:
                    vehicle = veh
                    break

            if vehicle is None:
                LOG_ERROR('Vehicle not found', g_currentVehicle.invID)
                Waiting.hide('updateTankmen')
                return
            crew = []
            for tId in vehicle.crew:
                if tId is None:
                    crew.append(None)
                    continue
                for tankman in tankmen:
                    if tankman.inventoryId == tId:
                        crew.append(tankman)

            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            brotherhood_bonus = getSkillsConfig(
            )['brotherhood']['crewLevelIncrease']
            for t in crew:
                if t is None or 'brotherhood' not in t.skills or t.skills.index(
                        'brotherhood') == len(
                            t.skills) - 1 and t.lastSkillLevel != 100:
                    brotherhood_bonus = 0
                    break

            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (
                        tankmenDescrs[lessMastered] is None or
                        compareMastery(tankmenDescrs[lessMastered].descriptor,
                                       tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({
                    'tankmanID':
                    tman.invID if tman is not None else None,
                    'roleType':
                    role,
                    'role':
                    convert(getSkillsConfig()[role]['userString']),
                    'roleIcon':
                    '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG,
                               getSkillsConfig()[role]['icon']),
                    'nationID':
                    vehicle.nationID,
                    'typeID':
                    vehicle.innationID,
                    'slot':
                    slotIdx,
                    'vehicleType':
                    vehicle.shortUserName,
                    'tankType':
                    vehicle.type,
                    'vehicleElite':
                    vehicle.isPremium,
                    'roles':
                    list(vehicle.descriptor.type.crewRoles[slotIdx])
                })

            tankmenData = []
            crewIDs = vehicle.crewIndices.keys()
            for tankman in tankmen:
                if not tankman.isInTank or tankman.inventoryId in crewIDs:
                    bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                    skills_count = len(list(ACTIVE_SKILLS))
                    skillsList = []
                    for skill in tankman.skills:
                        skillLevel = tankman.lastSkillLevel if tankman.skills.index(
                            skill) == len(tankman.skills) - 1 else 100
                        skillsList.append({
                            'tankmanID':
                            tankman.inventoryId,
                            'id':
                            skill,
                            'name':
                            getSkillsConfig()[skill]['userString'],
                            'desc':
                            getSkillsConfig()[skill]['description'],
                            'icon':
                            getSkillsConfig()[skill]['icon'],
                            'level':
                            tankman.lastSkillLevel,
                            'active':
                            skill not in PERKS or skill == 'brotherhood'
                            and brotherhood_bonus != 0
                            or skill != 'brotherhood' and skillLevel == 100
                        })

                    newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                    if newSkillsCount > 0:
                        skillsList.append({
                            'buy': True,
                            'tankmanID': tankman.inventoryId,
                            'level': lastNewSkillLvl
                        })
                    tankmanData = {
                        'firstname':
                        tankman.firstname,
                        'lastname':
                        tankman.lastname,
                        'rank':
                        tankman.rank,
                        'specializationLevel':
                        tankman.roleLevel,
                        'role':
                        tankman.role,
                        'vehicleType':
                        tankman.vehicle.type.shortUserString,
                        'iconFile':
                        tankman.icon,
                        'rankIconFile':
                        tankman.iconRank,
                        'roleIconFile':
                        '%s/%s' %
                        (Tankman.ROLE_ICON_PATH_BIG, tankman.iconRole),
                        'contourIconFile':
                        tankman.vehicleIconContour,
                        'tankmanID':
                        tankman.inventoryId,
                        'nationID':
                        tankman.nation,
                        'typeID':
                        tankman.vehicle.type.id[1],
                        'inTank':
                        tankman.isInTank,
                        'roleType':
                        tankman.descriptor.role,
                        'tankType':
                        tankman.vehicleType,
                        'efficiencyLevel':
                        tankman.efficiencyRoleLevel(vehicle.descriptor),
                        'bonus':
                        bonus_role_level,
                        'lastSkillLevel':
                        tankman.lastSkillLevel,
                        'isLessMastered':
                        vehicle.crewIndices.get(tankman.inventoryId)
                        == lessMastered and vehicle.isXPToTman,
                        'compact':
                        tankman.pack(),
                        'availableSkillsCount':
                        skills_count,
                        'skills':
                        skillsList
                    }
                    tankmenData.append(tankmanData)

            self.as_tankmenResponseS(roles, tankmenData)
        Waiting.hide('updateTankmen')
        return
示例#51
0
 def roleFormat(role):
     return makeString(statusTemplate % 'inactiveSkillsRoleFormat') % makeString(getSkillsConfig()[role]['userString'])
示例#52
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        tankmen = yield Requester('tankman').getFromInventory()
        vehicles = yield Requester('vehicle').getFromInventory()
        vehicle = None
        if g_currentVehicle.isPresent():
            for veh in vehicles:
                if veh.inventoryId == g_currentVehicle.invID:
                    vehicle = veh
                    break

            if vehicle is None:
                LOG_ERROR('Vehicle not found', g_currentVehicle.invID)
                Waiting.hide('updateTankmen')
                return
            crew = []
            for tId in vehicle.crew:
                if tId is None:
                    crew.append(None)
                    continue
                for tankman in tankmen:
                    if tankman.inventoryId == tId:
                        crew.append(tankman)

            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            brotherhood_bonus = getSkillsConfig()['brotherhood']['crewLevelIncrease']
            for t in crew:
                if t is None or 'brotherhood' not in t.skills or t.skills.index('brotherhood') == len(t.skills) - 1 and t.lastSkillLevel != 100:
                    brotherhood_bonus = 0
                    break

            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (tankmenDescrs[lessMastered] is None or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({'tankmanID': tman.invID if tman is not None else None,
                 'roleType': role,
                 'role': convert(getSkillsConfig()[role]['userString']),
                 'roleIcon': '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG, getSkillsConfig()[role]['icon']),
                 'nationID': vehicle.nationID,
                 'typeID': vehicle.innationID,
                 'slot': slotIdx,
                 'vehicleType': vehicle.shortUserName,
                 'tankType': vehicle.type,
                 'vehicleElite': vehicle.isPremium,
                 'roles': list(vehicle.descriptor.type.crewRoles[slotIdx])})

            tankmenData = []
            crewIDs = vehicle.crewIndices.keys()
            for tankman in tankmen:
                if not tankman.isInTank or tankman.inventoryId in crewIDs:
                    bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                    skills_count = len(list(ACTIVE_SKILLS))
                    skillsList = []
                    for skill in tankman.skills:
                        skillLevel = tankman.lastSkillLevel if tankman.skills.index(skill) == len(tankman.skills) - 1 else 100
                        skillsList.append({'tankmanID': tankman.inventoryId,
                         'id': skill,
                         'name': getSkillsConfig()[skill]['userString'],
                         'desc': getSkillsConfig()[skill]['description'],
                         'icon': getSkillsConfig()[skill]['icon'],
                         'level': tankman.lastSkillLevel,
                         'active': skill not in PERKS or skill == 'brotherhood' and brotherhood_bonus != 0 or skill != 'brotherhood' and skillLevel == 100})

                    newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                    if newSkillsCount > 0:
                        skillsList.append({'buy': True,
                         'tankmanID': tankman.inventoryId,
                         'level': lastNewSkillLvl})
                    tankmanData = {'firstname': tankman.firstname,
                     'lastname': tankman.lastname,
                     'rank': tankman.rank,
                     'specializationLevel': tankman.roleLevel,
                     'role': tankman.role,
                     'vehicleType': tankman.vehicle.type.shortUserString,
                     'iconFile': tankman.icon,
                     'rankIconFile': tankman.iconRank,
                     'roleIconFile': '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG, tankman.iconRole),
                     'contourIconFile': tankman.vehicleIconContour,
                     'tankmanID': tankman.inventoryId,
                     'nationID': tankman.nation,
                     'typeID': tankman.vehicle.type.id[1],
                     'inTank': tankman.isInTank,
                     'roleType': tankman.descriptor.role,
                     'tankType': tankman.vehicleType,
                     'efficiencyLevel': tankman.efficiencyRoleLevel(vehicle.descriptor),
                     'bonus': bonus_role_level,
                     'lastSkillLevel': tankman.lastSkillLevel,
                     'isLessMastered': vehicle.crewIndices.get(tankman.inventoryId) == lessMastered and vehicle.isXPToTman,
                     'compact': tankman.pack(),
                     'availableSkillsCount': skills_count,
                     'skills': skillsList}
                    tankmenData.append(tankmanData)

            self.as_tankmenResponseS(roles, tankmenData)
        Waiting.hide('updateTankmen')
        return
示例#53
0
def getRoleIconName(role):
    return tankmen.getSkillsConfig()[role]['icon']
示例#54
0
 def roleUserName(self):
     """ Tankman's role represented as user-friendly string. """
     return convert(tankmen.getSkillsConfig()[self.descriptor.role]['userString'])
示例#55
0
def getSkillIconName(skillName):
    return i18n.convert(tankmen.getSkillsConfig()[skillName]['icon'])
示例#56
0
 def description(self):
     """ Returns skill description represented as user-friendly string. """
     return convert(tankmen.getSkillsConfig()[self.name]['description'])
示例#57
0
def getSkillUserDescription(skillName):
    return tankmen.getSkillsConfig()[skillName]["description"]
示例#58
0
    def updateTankmen(self):
        Waiting.show('updateTankmen')
        if g_currentVehicle.isPresent():
            tankmen = g_itemsCache.items.getTankmen()
            vehicle = g_currentVehicle.item
            commander_bonus = vehicle.bonuses['commander']
            roles = []
            lessMastered = 0
            tankmenDescrs = dict(vehicle.crew)
            for slotIdx, tman in vehicle.crew:
                if slotIdx > 0 and tman is not None and (tankmenDescrs[lessMastered] is None or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0):
                    lessMastered = slotIdx
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                roles.append({'tankmanID': tman.invID if tman is not None else None,
                 'roleType': role,
                 'role': convert(getSkillsConfig()[role]['userString']),
                 'roleIcon': Tankman.getRoleBigIconPath(role),
                 'nationID': vehicle.nationID,
                 'typeID': vehicle.innationID,
                 'slot': slotIdx,
                 'vehicleType': vehicle.shortUserName,
                 'tankType': vehicle.type,
                 'vehicleElite': vehicle.isPremium or vehicle.isPremiumIGR,
                 'roles': list(vehicle.descriptor.type.crewRoles[slotIdx])})

            tankmenData = []
            for tankman in tankmen.itervalues():
                if tankman.isInTank and tankman.vehicleInvID != vehicle.invID:
                    continue
                tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
                bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0
                skills_count = len(list(ACTIVE_SKILLS))
                skillsList = []
                for skill in tankman.skills:
                    skillsList.append({'tankmanID': tankman.invID,
                     'id': str(tankman.skills.index(skill)),
                     'name': skill.userName,
                     'desc': skill.description,
                     'icon': skill.icon,
                     'level': skill.level,
                     'active': skill.isEnable and skill.isActive})

                newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
                if newSkillsCount > 0:
                    skillsList.append({'buy': True,
                     'tankmanID': tankman.invID,
                     'level': lastNewSkillLvl})
                tankmanData = {'firstName': tankman.firstUserName,
                 'lastName': tankman.lastUserName,
                 'rank': tankman.rankUserName,
                 'specializationLevel': tankman.realRoleLevel[0],
                 'role': tankman.roleUserName,
                 'vehicleType': tankmanVehicle.shortUserName,
                 'iconFile': tankman.icon,
                 'rankIconFile': tankman.iconRank,
                 'roleIconFile': Tankman.getRoleBigIconPath(tankman.descriptor.role),
                 'contourIconFile': tankmanVehicle.iconContour,
                 'tankmanID': tankman.invID,
                 'nationID': tankman.nationID,
                 'typeID': tankmanVehicle.innationID,
                 'inTank': tankman.isInTank,
                 'roleType': tankman.descriptor.role,
                 'tankType': tankmanVehicle.type,
                 'efficiencyLevel': tankman.efficiencyRoleLevel,
                 'bonus': bonus_role_level,
                 'lastSkillLevel': tankman.descriptor.lastSkillLevel,
                 'isLessMastered': vehicle.crewIndices.get(tankman.invID) == lessMastered and vehicle.isXPToTman,
                 'compact': tankman.strCD,
                 'availableSkillsCount': skills_count,
                 'skills': skillsList}
                tankmenData.append(tankmanData)

            self.as_tankmenResponseS({'roles': roles,
             'tankmen': tankmenData})
            dogName = ''
            if 'dog' in g_itemsCache.items.getItemByCD(g_currentVehicle.item.intCD).tags:
                dogName = MENU.HANGAR_CREW_RODY_DOG_NAME
            self.as_dogResponseS(dogName)
        Waiting.hide('updateTankmen')
        return
示例#59
0
 def __getCurrentSkillIcon(self):
     if self.__isNewSkillReady():
         return ('new_skill', 'new_skill.png')
     if self.tmanDescr.roleLevel != tankmen.MAX_SKILL_LEVEL or not len(self.tmanDescr.skills):
         return ('role', '%s.png' % self.tmanDescr.role)
     return ('skill', tankmen.getSkillsConfig()[self.tmanDescr.skills[-1]]['icon'])