Пример #1
0
    def onVehicleSelected(self, vehTypeCompDescr):
        self.__selectedVehicleCD = int(vehTypeCompDescr)
        selectedVehicle = self.__items.getItemByCD(self.__selectedVehicleCD)
        data = []
        mainRoles = []
        for slotIdx, tman in selectedVehicle.crew:
            mainRole = selectedVehicle.descriptor.type.crewRoles[slotIdx][0]
            if mainRole not in mainRoles:
                mainRoles.append(mainRole)
                criteria = REQ_CRITERIA.TANKMAN.NATIVE_TANKS(
                    [self.__selectedVehicleCD]) | REQ_CRITERIA.TANKMAN.ROLES(
                        [mainRole]) | REQ_CRITERIA.TANKMAN.ACTIVE
                roleTankmen = self.__items.getTankmen(criteria).values()
                sameTankmen = len(roleTankmen)
                roleSlotIsTaken = _isRoleSlotTaken(roleTankmen,
                                                   selectedVehicle, mainRole)
                roleStr = Tankman.getRoleUserName(mainRole)
                isAvailable = self.__tankman.descriptor.role != mainRole
                data.append({
                    'id':
                    mainRole,
                    'name':
                    roleStr,
                    'icon':
                    Tankman.getRoleMediumIconPath(mainRole),
                    'available':
                    isAvailable,
                    'warningHeader':
                    _getTooltipHeader(sameTankmen, isAvailable),
                    'warningBody':
                    _getTooltipBody(sameTankmen, isAvailable, roleSlotIsTaken,
                                    roleStr, selectedVehicle)
                })

        self.as_setRolesS(data)
 def __updateSkillsData(self):
     skills = [ {'icon': Tankman.getSkillBigIconPath(skillType),
      'label': Tankman.getSkillUserName(skillType),
      'skillType': skillType,
      'isForAll': skillType in tankmen.COMMON_SKILLS,
      'selected': skillType in self._container.getCurrentCrewSkills()} for skillType in PARAMS_AFFECTED_TANKMEN_SKILLS ]
     self.as_setSkillsS(skills)
Пример #3
0
 def __paramsChangeHandler(self, selectedNationID, selectedVehClass,
                           selectedVehicle, selectedTmanRole):
     selectedNationID = int(selectedNationID)
     nationName = nations.NAMES[selectedNationID]
     if self.__currentSelectedNationID != selectedNationID:
         firstNameID, lastNameID, iconID = g_eventsCache.potapov.getNextTankwomanIDs(
             selectedNationID, self.__isPremium, int(self.__fnGroup),
             int(self.__lnGroup), int(self.__iGroupID))
         rankID = Tankman.calculateRankID(tankmen.MAX_SKILL_LEVEL,
                                          self.__freeXpValue)
         self.as_setInitDataS({
             'name':
             Tankman.getFullUserName(selectedNationID, firstNameID,
                                     lastNameID),
             'nation':
             nationName,
             'rank':
             Tankman.getRankUserName(selectedNationID, rankID),
             'vehicle':
             '',
             'faceIcon':
             Tankman.getBigIconPath(selectedNationID, iconID),
             'rankIcon':
             Tankman.getRankBigIconPath(selectedNationID, rankID)
         })
     self.__currentSelectedNationID = selectedNationID
Пример #4
0
 def __paramsChangeHandler(self, selectedNationID, selectedVehClass,
                           selectedVehicle, selectedTmanRole):
     selectedNationID = int(selectedNationID)
     nationName = nations.NAMES[selectedNationID]
     if self.__currentSelectedNationID != selectedNationID:
         firstNameID, lastNameID, iconID = self.eventsCache.personalMissions.getNextTankwomanIDs(
             selectedNationID, self.__isPremium, int(self.__fnGroup),
             int(self.__lnGroup), int(self.__iGroupID))
         rankID = Tankman.calculateRankID(tankmen.MAX_SKILL_LEVEL,
                                          self.__freeXpValue)
         faceIcon = Tankman.getBigIconPath(selectedNationID, iconID)
         self.as_setInitDataS({
             'windowTitle':
             _ms(DIALOGS.RECRUITWINDOW_TITLE),
             'applyButtonLabel':
             _ms(DIALOGS.RECRUITWINDOW_SUBMIT),
             'cancelButtonLabel':
             _ms(DIALOGS.RECRUITWINDOW_CANCEL),
             'name':
             Tankman.getFullUserName(selectedNationID, firstNameID,
                                     lastNameID),
             'nation':
             nationName,
             'rank':
             Tankman.getRankUserName(selectedNationID, rankID),
             'backAnimationData':
             self.__getBackAnimationData(faceIcon)
         })
     self.__currentSelectedNationID = selectedNationID
Пример #5
0
 def __paramsChangeHandler(self, selectedNationID, selectedVehClass, selectedVehicle, selectedTmanRole):
     selectedNationID = int(selectedNationID)
     nationName = nations.NAMES[selectedNationID]
     if self.__currentSelectedNationID != selectedNationID:
         firstNameID, lastNameID, iconID = g_eventsCache.potapov.getNextTankwomanIDs(selectedNationID, self.__isPremium, int(self.__fnGroup), int(self.__lnGroup), int(self.__iGroupID))
         rankID = Tankman.calculateRankID(tankmen.MAX_SKILL_LEVEL, self.__freeXpValue)
         self.as_setInitDataS({'name': Tankman.getFullUserName(selectedNationID, firstNameID, lastNameID),
          'nation': nationName,
          'rank': Tankman.getRankUserName(selectedNationID, rankID),
          'vehicle': '',
          'faceIcon': Tankman.getBigIconPath(selectedNationID, iconID),
          'rankIcon': Tankman.getRankBigIconPath(selectedNationID, rankID)})
     self.__currentSelectedNationID = selectedNationID
Пример #6
0
def packTankman(tankman, isCountPermanentSkills=True):
    def vehicleIcon(vDescr, subtype=""):
        return _ICONS_MASK % {"type": "vehicle", "subtype": subtype, "unicName": vDescr.name.replace(":", "-")}

    nativeVehicleData = {
        "typeCompDescr": tankman.vehicleNativeDescr.type.compactDescr,
        "userName": Vehicle.getShortUserName(tankman.vehicleNativeDescr.type),
        "icon": vehicleIcon(tankman.vehicleNativeDescr),
        "iconContour": vehicleIcon(tankman.vehicleNativeDescr, "contour/"),
    }
    currentVehicleData = None
    if tankman.isInTank:
        currentVehicleData = {
            "inventoryID": tankman.vehicleInvID,
            "typeCompDescr": tankman.vehicleDescr.type.compactDescr,
            "userName": Vehicle.getShortUserName(tankman.vehicleDescr.type),
            "icon": vehicleIcon(tankman.vehicleDescr),
            "iconContour": vehicleIcon(tankman.vehicleDescr, "contour/"),
        }
    skills = []
    tManFreeSkillsNum = tankman.descriptor.freeSkillsNumber
    startSkillNumber = 0 if isCountPermanentSkills else tManFreeSkillsNum
    tManSkills = tankman.skills
    for i in range(startSkillNumber, len(tManSkills)):
        skills.append(packTankmanSkill(tManSkills[i], isPermanent=True if i < tManFreeSkillsNum else False))

    return {
        "strCD": cPickle.dumps(tankman.strCD),
        "inventoryID": tankman.invID,
        "nationID": tankman.nationID,
        "firstUserName": tankman.firstUserName,
        "lastUserName": tankman.lastUserName,
        "roleName": tankman.descriptor.role,
        "rankUserName": tankman.rankUserName,
        "roleUserName": tankman.roleUserName,
        "skills": skills,
        "efficiencyRoleLevel": tankman.efficiencyRoleLevel,
        "realRoleLevel": tankman.realRoleLevel,
        "roleLevel": tankman.roleLevel,
        "icon": {
            "big": Tankman.getBigIconPath(tankman.nationID, tankman.descriptor.iconID),
            "small": Tankman.getSmallIconPath(tankman.nationID, tankman.descriptor.iconID),
            "barracks": Tankman.getBarracksIconPath(tankman.nationID, tankman.descriptor.iconID),
        },
        "iconRole": {
            "big": Tankman.getRoleBigIconPath(tankman.descriptor.role),
            "medium": Tankman.getRoleMediumIconPath(tankman.descriptor.role),
            "small": Tankman.getRoleSmallIconPath(tankman.descriptor.role),
        },
        "iconRank": {
            "big": Tankman.getRankBigIconPath(tankman.nationID, tankman.descriptor.rankID),
            "small": Tankman.getRankSmallIconPath(tankman.nationID, tankman.descriptor.rankID),
        },
        "isInTank": tankman.isInTank,
        "newSkillsCount": tankman.newSkillCount,
        "nativeVehicle": nativeVehicleData,
        "currentVehicle": currentVehicleData,
    }
Пример #7
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)
Пример #8
0
 def __paramsChangeHandler(self, selectedNationID, selectedVehClass,
                           selectedVehicle, selectedTmanRole):
     selectedNationID = int(selectedNationID)
     nationName = nations.NAMES[selectedNationID]
     if self.__currentSelectedNationID != selectedNationID:
         faceIcon = self.__tokenData.getBigIcon()
         bgImage = self.__getBgImage(self.__tokenData.getSourceID())
         self.as_setInitDataS({
             'windowTitle':
             _ms(DIALOGS.RECRUITWINDOW_TITLE),
             'applyButtonLabel':
             _ms(DIALOGS.RECRUITWINDOW_SUBMIT),
             'cancelButtonLabel':
             _ms(DIALOGS.RECRUITWINDOW_CANCEL),
             'name':
             self.__tokenData.getFullUserNameByNation(selectedNationID),
             'nation':
             nationName,
             'rank':
             Tankman.getRankUserName(selectedNationID,
                                     self.__tokenData.getRankID()),
             'backAnimationData':
             None if bgImage else self.__getBackAnimationData(faceIcon),
             'bgImage':
             bgImage,
             'tankmanIcon':
             faceIcon
         })
     self.__currentSelectedNationID = selectedNationID
     return
Пример #9
0
 def __paramsChangeHandler(self, selectedNationID, selectedVehClass,
                           selectedVehicle, selectedTmanRole):
     selectedNationID = int(selectedNationID)
     nationName = nations.NAMES[selectedNationID]
     if self.__currentSelectedNationID != selectedNationID:
         faceIcon = self.__tokenData.getBigIcon()
         bgImage = self.__getBgImage(self.__tokenData.getSourceID())
         self.as_setInitDataS({
             'windowTitle':
             backport.text(R.strings.dialogs.recruitWindow.title()),
             'applyButtonLabel':
             backport.text(R.strings.dialogs.recruitWindow.submit()),
             'cancelButtonLabel':
             backport.text(R.strings.dialogs.recruitWindow.cancel()),
             'name':
             self.__tokenData.getFullUserNameByNation(selectedNationID),
             'nation':
             nationName,
             'rank':
             Tankman.getRankUserName(selectedNationID,
                                     self.__tokenData.getRankID()),
             'backAnimationData':
             None if bgImage else self.__getBackAnimationData(faceIcon),
             'bgImage':
             bgImage,
             'tankmanIcon':
             faceIcon
         })
     self.__currentSelectedNationID = selectedNationID
     return
Пример #10
0
 def getRankID(self):
     return Tankman.calculateRankID(
         tankmen.MAX_SKILL_LEVEL,
         self._freeXP,
         skills=self._getSkillsForDescr(),
         freeSkills=self._getFreeSkillsForDescr(),
         lastSkillLevel=self._lastSkillLevel)
Пример #11
0
 def _packBlocks(self, *args, **kwargs):
     items = super(NotRecruitedTooltipData, self)._packBlocks()
     item = self.context.buildItem(*args)
     self.item = item
     blocks = list()
     blocks.append(
         formatters.packImageTextBlockData(
             title=text_styles.highTitle(item.getFullUserName()),
             desc=text_styles.main(item.getLabel())))
     blocks.append(
         formatters.packImageBlockData(
             img=item.getBigIcon(),
             align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER))
     blocks.append(formatters.packSeparatorBlockData())
     blocks.append(
         formatters.packTextBlockData(
             text_styles.main(item.getDescription()),
             useHtml=True,
             padding=formatters.packPadding(top=20, bottom=7)))
     if item.getLearntSkills():
         blocks.append(
             formatters.packTextBlockData(text_styles.middleTitle(
                 TOOLTIPS.NOTRECRUITEDTANKMAN_SKILLSTITLE),
                                          useHtml=True,
                                          padding=formatters.packPadding(
                                              top=10, bottom=10)))
         skills = item.getLearntSkills()
         blocks.append(
             formatters.packImageListParameterBlockData(
                 listIconSrc=[
                     Tankman.getSkillIconPath(skillName=skillName,
                                              size='big')
                     for skillName in skills
                 ],
                 columnWidth=52,
                 rowHeight=52,
                 verticalGap=10,
                 horizontalGap=10,
                 padding=formatters.packPadding(bottom=10)))
     expiryTime = item.getExpiryTime()
     if expiryTime:
         blocks.append(
             formatters.packTextBlockData(text_styles.middleTitle(
                 TOOLTIPS.NOTRECRUITEDTANKMAN_EXPIRETITLE),
                                          useHtml=True,
                                          padding=formatters.packPadding(
                                              top=10, bottom=2)))
         expireDateStr = makeString(TOOLTIPS.NOTRECRUITEDTANKMAN_USEBEFORE,
                                    date=expiryTime)
         blocks.append(
             formatters.packTextParameterWithIconBlockData(
                 name=text_styles.premiumVehicleName(expireDateStr),
                 value='',
                 icon=ICON_TEXT_FRAMES.RENTALS,
                 padding=formatters.packPadding(left=-60, bottom=-18),
                 iconYOffset=3))
     items.append(
         formatters.packBuildUpBlockData(
             blocks, padding=formatters.packPadding(bottom=-10)))
     return items
Пример #12
0
 def _successHandler(self, code, ctx=None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = self.itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     additionalMsgs = []
     if self.__compensationRequired:
         additionalMsgs.append(
             makeCrewSkinCompensationMessage(
                 self.__compensationPriceObject))
     if ctx == EQUIP_TMAN_CODE.OK:
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/installed',
                             vehicle=vehicle.shortUserName))
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/slot_is_taken',
                             vehicle=vehicle.shortUserName,
                             role=roleStr))
     else:
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/no_vehicle'))
     return makeI18nSuccess('change_tankman_role/success',
                            money=formatPrice(
                                Money(gold=self.__changeRoleCost)),
                            type=msgType,
                            auxData=additionalMsgs)
Пример #13
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}
 def getNewSkillCount(self, onlyFull=False):
     if self._hasNewSkill:
         tankman = Tankman.Tankman(self.__makeFakeDescriptor().makeCompactDescr())
         count, lastSkillLevel = tankman.newSkillCount
         if onlyFull and lastSkillLevel != MAX_SKILL_LEVEL:
             count = max(count - 1, 0)
             lastSkillLevel = MAX_SKILL_LEVEL
         return (count, lastSkillLevel)
Пример #15
0
def _packTankmanData(tankman, itemsCache=None):
    tankmanVehicle = itemsCache.items.getItemByCD(
        tankman.vehicleNativeDescr.type.compactDescr)
    if tankman.isInTank:
        vehicle = itemsCache.items.getVehicle(tankman.vehicleInvID)
        if vehicle is None:
            _logger.error('Cannot find vehicle for tankman: %r %r %r %r %r',
                          tankman, tankman.descriptor.role,
                          tankman.vehicle.name, tankman.firstname,
                          tankman.lastname)
            return
        vehicleID = vehicle.invID
        slot = tankman.vehicleSlotIdx
        isLocked, msg = _getTankmanLockMessage(vehicle)
        actionBtnEnabled = not isLocked
        isInCurrentTank = g_currentVehicle.isPresent(
        ) and tankmanVehicle.invID == g_currentVehicle.invID
        isInSelfVehicle = vehicle.shortUserName == tankmanVehicle.shortUserName
        isInSelfVehicleType = vehicle.type == tankmanVehicle.type
    else:
        isLocked, msg = False, ''
        actionBtnEnabled = True
        isInCurrentTank = False
        vehicleID = None
        slot = None
        isInSelfVehicle = True
        isInSelfVehicleType = True
    data = {
        '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,
        'roleType': tankman.descriptor.role,
        'tankType': tankmanVehicle.type,
        'inTank': tankman.isInTank,
        'compact': str(tankman.invID),
        'lastSkillLevel': tankman.descriptor.lastSkillLevel,
        'actionBtnEnabled': actionBtnEnabled,
        'inCurrentTank': isInCurrentTank,
        'vehicleID': vehicleID,
        'slot': slot,
        'locked': isLocked,
        'lockMessage': msg,
        'isInSelfVehicleClass': isInSelfVehicleType,
        'isInSelfVehicleType': isInSelfVehicle,
        'notRecruited': False
    }
    return data
def _packTankmanData(tankman, itemsCache=None, lobbyContext=None):
    tankmanVehicle = itemsCache.items.getItemByCD(
        tankman.vehicleNativeDescr.type.compactDescr)
    if tankman.isInTank:
        vehicle = itemsCache.items.getVehicle(tankman.vehicleInvID)
        vehicleID = vehicle.invID
        slot = tankman.vehicleSlotIdx
        isLocked, msg = _getTankmanLockMessage(vehicle)
        actionBtnEnabled = not isLocked
        isInCurrentTank = g_currentVehicle.isPresent(
        ) and tankmanVehicle.invID == g_currentVehicle.invID
        isInSelfVehicle = vehicle.shortUserName == tankmanVehicle.shortUserName
        isInSelfVehicleType = vehicle.type == tankmanVehicle.type
    else:
        isLocked, msg = False, ''
        actionBtnEnabled = True
        isInCurrentTank = False
        vehicleID = None
        slot = None
        isInSelfVehicle = True
        isInSelfVehicleType = True
    data = {
        'fullName': tankman.fullUserName,
        '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,
        'roleType': tankman.descriptor.role,
        'tankType': tankmanVehicle.type,
        'inTank': tankman.isInTank,
        'compact': str(tankman.invID),
        'lastSkillLevel': tankman.descriptor.lastSkillLevel,
        'actionBtnEnabled': actionBtnEnabled,
        'inCurrentTank': isInCurrentTank,
        'vehicleID': vehicleID,
        'slot': slot,
        'locked': isLocked,
        'lockMessage': msg,
        'isInSelfVehicleClass': isInSelfVehicleType,
        'isInSelfVehicleType': isInSelfVehicle,
        'notRecruited': False
    }
    if tankman.skinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings(
    ).isCrewSkinsEnabled():
        skinItem = itemsCache.items.getCrewSkin(tankman.skinID)
        iconFile = getCrewSkinIconSmallWithoutPath(skinItem.getIconID())
        data['iconFile'] = iconFile
        data['fullName'] = localizedFullName(skinItem)
    return data
Пример #17
0
 def __makeTankmanVO(self, tman, avgBattles2NewSkill):
     prediction = ''
     if avgBattles2NewSkill > 0:
         prediction = _ms(BATTLE_RESULTS.COMMON_NEWSKILLPREDICTION, battles=BigWorld.wg_getIntegralFormat(avgBattles2NewSkill))
     return {'title': _ms(BATTLE_RESULTS.COMMON_CREWMEMBER_NEWSKILL),
      'description': self.__makeTankmanDescription(tman),
      'tankmenIcon': Tankman.getSmallIconPath(tman.nationID, tman.descriptor.iconID),
      'prediction': prediction,
      'linkEvent': PROGRESS_ACTION.NEW_SKILL_UNLOCK_TYPE,
      'linkId': tman.invID}
Пример #18
0
def repackTankmanWithSkinData(item, data, itemsCache=None, lobbyContext=None):
    if item.skinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings(
    ).isCrewSkinsEnabled():
        skinItem = itemsCache.items.getCrewSkin(item.skinID)
        data['icon']['big'] = Tankman.getCrewSkinIconBig(skinItem.getIconID())
        data['firstUserName'] = i18n.makeString(skinItem.getFirstName())
        data['lastUserName'] = i18n.makeString(skinItem.getLastName())
        data['fullName'] = localizedFullName(skinItem)
    else:
        data['fullName'] = item.fullUserName
 def __makeTankmanVO(self, tman, avgBattles2NewSkill):
     prediction = ''
     if avgBattles2NewSkill > 0:
         prediction = _ms(BATTLE_RESULTS.COMMON_NEWSKILLPREDICTION, battles=BigWorld.wg_getIntegralFormat(avgBattles2NewSkill))
     return {'title': _ms(BATTLE_RESULTS.COMMON_CREWMEMBER_NEWSKILL),
      'description': self.__makeTankmanDescription(tman),
      'tankmenIcon': Tankman.getSmallIconPath(tman.nationID, tman.descriptor.iconID),
      'prediction': prediction,
      'linkEvent': PROGRESS_ACTION.NEW_SKILL_UNLOCK_TYPE,
      'linkId': tman.invID}
Пример #20
0
    def onVehicleSelected(self, vehTypeCompDescr):
        self.__selectedVehicleCD = int(vehTypeCompDescr)
        selectedVehicle = self.__items.getItemByCD(self.__selectedVehicleCD)
        data = []
        for role in selectedVehicle.descriptor.type.crewRoles:
            mainRole = role[0]
            criteria = REQ_CRITERIA.TANKMAN.NATIVE_TANKS([self.__selectedVehicleCD]) | REQ_CRITERIA.TANKMAN.ROLES([mainRole])
            roleTankmen = self.__items.getTankmen(criteria).values()
            sameTankmen = len(roleTankmen)
            roleSlotIsTaken = _isRoleSlotTaken(roleTankmen, selectedVehicle, mainRole)
            roleStr = Tankman.getRoleUserName(mainRole)
            isAvailable = self.__tankman.descriptor.role != mainRole
            data.append({'id': mainRole,
             'name': roleStr,
             'icon': Tankman.getRoleMediumIconPath(mainRole),
             'available': isAvailable,
             'warningHeader': _getTooltipHeader(sameTankmen, isAvailable),
             'warningBody': _getTooltipBody(sameTankmen, isAvailable, roleSlotIsTaken, roleStr, selectedVehicle)})

        self.as_setRolesS(data)
Пример #21
0
 def _successHandler(self, code, ctx = None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     if ctx == EQUIP_TMAN_CODE.OK:
         auxData = makeI18nSuccess('change_tankman_role/installed', vehicle=vehicle.shortUserName)
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         auxData = makeI18nSuccess('change_tankman_role/slot_is_taken', vehicle=vehicle.shortUserName, role=roleStr)
     else:
         auxData = makeI18nSuccess('change_tankman_role/no_vehicle')
     return makeI18nSuccess('change_tankman_role/success', money=formatPrice(Money(gold=self.__changeRoleCost)), type=msgType, auxData=auxData)
Пример #22
0
 def _successHandler(self, code, ctx = None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     if ctx == EQUIP_TMAN_CODE.OK:
         auxData = makeI18nSuccess('change_tankman_role/installed', vehicle=vehicle.shortUserName)
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         auxData = makeI18nSuccess('change_tankman_role/slot_is_taken', vehicle=vehicle.shortUserName, role=roleStr)
     else:
         auxData = makeI18nSuccess('change_tankman_role/no_vehicle')
     return makeI18nSuccess('change_tankman_role/success', money=formatPrice((0, self.__changeRoleCost)), type=msgType, auxData=auxData)
Пример #23
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
    }
Пример #24
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,
    }
Пример #25
0
def packTankman(tankman, isCountPermanentSkills = True):

    def vehicleIcon(vDescr, subtype = ''):
        return _ICONS_MASK % {'type': 'vehicle',
         'subtype': subtype,
         'unicName': vDescr.name.replace(':', '-')}

    nativeVehicleData = {'typeCompDescr': tankman.vehicleNativeDescr.type.compactDescr,
     'userName': Vehicle.getShortUserName(tankman.vehicleNativeDescr.type),
     'icon': vehicleIcon(tankman.vehicleNativeDescr),
     'iconContour': vehicleIcon(tankman.vehicleNativeDescr, 'contour/')}
    currentVehicleData = None
    if tankman.isInTank:
        currentVehicleData = {'inventoryID': tankman.vehicleInvID,
         'typeCompDescr': tankman.vehicleDescr.type.compactDescr,
         'userName': Vehicle.getShortUserName(tankman.vehicleDescr.type),
         'icon': vehicleIcon(tankman.vehicleDescr),
         'iconContour': vehicleIcon(tankman.vehicleDescr, 'contour/')}
    skills = []
    tManFreeSkillsNum = tankman.descriptor.freeSkillsNumber
    startSkillNumber = 0 if isCountPermanentSkills else tManFreeSkillsNum
    tManSkills = tankman.skills
    for i in range(startSkillNumber, len(tManSkills)):
        skills.append(packTankmanSkill(tManSkills[i], isPermanent=True if i < tManFreeSkillsNum else False))

    return {'strCD': cPickle.dumps(tankman.strCD),
     'inventoryID': tankman.invID,
     'nationID': tankman.nationID,
     'firstUserName': tankman.firstUserName,
     'lastUserName': tankman.lastUserName,
     'roleName': tankman.descriptor.role,
     'rankUserName': tankman.rankUserName,
     'roleUserName': tankman.roleUserName,
     'skills': skills,
     'efficiencyRoleLevel': tankman.efficiencyRoleLevel,
     'realRoleLevel': tankman.realRoleLevel,
     'roleLevel': tankman.roleLevel,
     'icon': {'big': Tankman.getBigIconPath(tankman.nationID, tankman.descriptor.iconID),
              'small': Tankman.getSmallIconPath(tankman.nationID, tankman.descriptor.iconID),
              'barracks': Tankman.getBarracksIconPath(tankman.nationID, tankman.descriptor.iconID)},
     'iconRole': {'big': Tankman.getRoleBigIconPath(tankman.descriptor.role),
                  'medium': Tankman.getRoleMediumIconPath(tankman.descriptor.role),
                  'small': Tankman.getRoleSmallIconPath(tankman.descriptor.role)},
     'iconRank': {'big': Tankman.getRankBigIconPath(tankman.nationID, tankman.descriptor.rankID),
                  'small': Tankman.getRankSmallIconPath(tankman.nationID, tankman.descriptor.rankID)},
     'isInTank': tankman.isInTank,
     'newSkillsCount': tankman.newSkillCount,
     'nativeVehicle': nativeVehicleData,
     'currentVehicle': currentVehicleData}
Пример #26
0
def packTankman(tankman, isCountPermanentSkills = True):

    def vehicleIcon(vDescr, subtype = ''):
        return _ICONS_MASK % {'type': 'vehicle',
         'subtype': subtype,
         'unicName': vDescr.name.replace(':', '-')}

    nativeVehicleData = {'typeCompDescr': tankman.vehicleNativeDescr.type.compactDescr,
     'userName': tankman.vehicleNativeDescr.type.shortUserString,
     'icon': vehicleIcon(tankman.vehicleNativeDescr),
     'iconContour': vehicleIcon(tankman.vehicleNativeDescr, 'contour/')}
    currentVehicleData = None
    if tankman.isInTank:
        currentVehicleData = {'inventoryID': tankman.vehicleInvID,
         'typeCompDescr': tankman.vehicleDescr.type.compactDescr,
         'userName': tankman.vehicleDescr.type.shortUserString,
         'icon': vehicleIcon(tankman.vehicleDescr),
         'iconContour': vehicleIcon(tankman.vehicleDescr, 'contour/')}
    skills = []
    for skill in tankman.skills:
        if not (skill.name == 'brotherhood' and tankman.descriptor.isFemale and not isCountPermanentSkills):
            skills.append(packTankmanSkill(skill))

    return {'strCD': cPickle.dumps(tankman.strCD),
     'inventoryID': tankman.invID,
     'nationID': tankman.nationID,
     'firstUserName': tankman.firstUserName,
     'lastUserName': tankman.lastUserName,
     'roleName': tankman.descriptor.role,
     'rankUserName': tankman.rankUserName,
     'roleUserName': tankman.roleUserName,
     'skills': skills,
     'efficiencyRoleLevel': tankman.efficiencyRoleLevel,
     'realRoleLevel': tankman.realRoleLevel,
     'roleLevel': tankman.roleLevel,
     'icon': {'big': Tankman.getBigIconPath(tankman.nationID, tankman.descriptor.iconID),
              'small': Tankman.getSmallIconPath(tankman.nationID, tankman.descriptor.iconID),
              'barracks': Tankman.getBarracksIconPath(tankman.nationID, tankman.descriptor.iconID)},
     'iconRole': {'big': Tankman.getRoleBigIconPath(tankman.descriptor.role),
                  'medium': Tankman.getRoleMediumIconPath(tankman.descriptor.role),
                  'small': Tankman.getRoleSmallIconPath(tankman.descriptor.role)},
     'iconRank': {'big': Tankman.getRankBigIconPath(tankman.nationID, tankman.descriptor.rankID),
                  'small': Tankman.getRankSmallIconPath(tankman.nationID, tankman.descriptor.rankID)},
     'isInTank': tankman.isInTank,
     'newSkillsCount': tankman.newSkillCount,
     'nativeVehicle': nativeVehicleData,
     'currentVehicle': currentVehicleData}
Пример #27
0
def _packTankmanData(tankman):
    tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
    if tankman.isInTank:
        vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
        if vehicle is None:
            LOG_ERROR('Cannot find vehicle for tankman: ', tankman, tankman.descriptor.role, tankman.vehicle.name, tankman.firstname, tankman.lastname)
            return
        vehicleID = vehicle.invID
        slot = tankman.vehicleSlotIdx
        isLocked, msg = _getTankmanLockMessage(vehicle)
        actionBtnEnabled = not isLocked
        isInCurrentTank = g_currentVehicle.isPresent() and tankmanVehicle.invID == g_currentVehicle.invID
        isInSelfVehicle = vehicle.shortUserName == tankmanVehicle.shortUserName
        isInSelfVehicleType = vehicle.type == tankmanVehicle.type
    else:
        isLocked, msg = False, ''
        actionBtnEnabled = True
        isInCurrentTank = False
        vehicleID = None
        slot = None
        isInSelfVehicle = True
        isInSelfVehicleType = True
    data = {'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,
     'roleType': tankman.descriptor.role,
     'tankType': tankmanVehicle.type,
     'inTank': tankman.isInTank,
     'compact': str(tankman.invID),
     'lastSkillLevel': tankman.descriptor.lastSkillLevel,
     'actionBtnEnabled': actionBtnEnabled,
     'inCurrentTank': isInCurrentTank,
     'vehicleID': vehicleID,
     'slot': slot,
     'locked': isLocked,
     'lockMessage': msg,
     'isInSelfVehicleClass': isInSelfVehicleType,
     'isInSelfVehicleType': isInSelfVehicle}
    return data
Пример #28
0
 def __makeTankmanVO(self, tman, avgBattles2NewSkill):
     prediction = ''
     if avgBattles2NewSkill > 0:
         prediction = _ms(BATTLE_RESULTS.COMMON_NEWSKILLPREDICTION, battles=backport.getIntegralFormat(avgBattles2NewSkill))
     data = {'title': _ms(BATTLE_RESULTS.COMMON_CREWMEMBER_NEWSKILL),
      'prediction': prediction,
      'linkEvent': PROGRESS_ACTION.NEW_SKILL_UNLOCK_TYPE,
      'linkId': tman.invID}
     if tman.skinID != NO_CREW_SKIN_ID and self.lobbyContext.getServerSettings().isCrewSkinsEnabled():
         skinItem = self.itemsCache.items.getCrewSkin(tman.skinID)
         data['tankmenIcon'] = getCrewSkinIconSmall(skinItem.getIconID())
         fullTankmanName = localizedFullName(skinItem)
     else:
         data['tankmenIcon'] = Tankman.getSmallIconPath(tman.nationID, tman.descriptor.iconID)
         fullTankmanName = tman.fullUserName
     data['description'] = self.__makeTankmanDescription(tman.roleUserName, fullTankmanName)
     return data
Пример #29
0
def _packNotRecruitedTankman(recruitInfo):
    expiryTime = recruitInfo.getExpiryTime()
    recruitBeforeStr = _ms(MENU.BARRACKS_NOTRECRUITEDACTIVATEBEFORE,
                           date=expiryTime) if expiryTime else ''
    availableRoles = recruitInfo.getRoles()
    roleType = availableRoles[0] if len(availableRoles) == 1 else ''
    result = {
        'firstName': i18n.convert(recruitInfo.getFirstName()),
        'lastName': i18n.convert(recruitInfo.getLastName()),
        'rank': recruitBeforeStr,
        'specializationLevel': recruitInfo.getRoleLevel(),
        'role': text_styles.counter(recruitInfo.getLabel()),
        'vehicleType': '',
        'iconFile': recruitInfo.getBarracksIcon(),
        'roleIconFile':
        Tankman.getRoleBigIconPath(roleType) if roleType else '',
        'rankIconFile': '',
        'contourIconFile': '',
        'tankmanID': -1,
        'nationID': -1,
        'typeID': -1,
        'roleType': roleType,
        'tankType': '',
        'inTank': False,
        'compact': '',
        'lastSkillLevel': recruitInfo.getLastSkillLevel(),
        'actionBtnEnabled': True,
        'inCurrentTank': False,
        'vehicleID': None,
        'slot': None,
        'locked': False,
        'lockMessage': '',
        'isInSelfVehicleClass': True,
        'isInSelfVehicleType': True,
        'notRecruited': True,
        'isRankNameVisible': True,
        'recoveryPeriodText': None,
        'actionBtnLabel': MENU.BARRACKS_BTNRECRUITNOTRECRUITED,
        'actionBtnTooltip': TOOLTIPS.BARRACKS_TANKMEN_RECRUIT,
        'skills': [],
        'isSkillsVisible': False,
        'recruitID': str(recruitInfo.getRecruitID())
    }
    return result
Пример #30
0
def packTankmanSkill(skill, isPermanent=False, tankman=None):
    if skill.roleType in skills_constants.ACTIVE_SKILLS or skill.roleType in skills_constants.ROLES:
        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': skill.bigIconPath,
            'small': skill.smallIconPath,
            'role': roleIconPath
        },
        'isActive': skill.isActive,
        'isEnable': skill.isEnable,
        'roleType': skill.roleType,
        'isPerk': skill.isPerk,
        'isPermanent': isPermanent
    }
Пример #31
0
    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
 def getRankID(self):
     return Tankman.calculateRankID(tankmen.MAX_SKILL_LEVEL, self._freeXP)
Пример #33
0
    def __updateTankmen(self, *args):
        tankmen = g_itemsCache.items.getTankmen().values()
        slots = g_itemsCache.items.stats.tankmenBerthsCount
        berths = g_itemsCache.items.stats.tankmenBerthsCount
        berthPrice = g_itemsCache.items.shop.getTankmanBerthPrice(berths)
        defaultBerthPrice = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths)
        tankmenList = list()
        tankmenInBarracks = 0
        action = None
        if berthPrice[0] != defaultBerthPrice[0]:
            action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'berthsPrices', True, Money(gold=berthPrice[0]), Money(gold=defaultBerthPrice[0]))
        gold = g_itemsCache.items.stats.money.gold
        enoughGold = True
        if berthPrice[0] > gold:
            enoughGold = False
        tankmenList.append({'buy': True,
         'price': BigWorld.wg_getGoldFormat(berthPrice[0]),
         'enoughGold': enoughGold,
         'actionPriceData': action,
         'count': berthPrice[1]})
        for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)):
            if not tankman.isInTank:
                tankmenInBarracks += 1
            slot, vehicleID, vehicleInnationID, vehicle = (None, None, None, None)
            if tankman.isInTank:
                vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
                vehicleID = vehicle.invID
                vehicleInnationID = vehicle.innationID
                if vehicle is None:
                    LOG_ERROR('Cannot find vehicle for tankman: ', tankman, tankman.descriptor.role, tankman.vehicle.name, tankman.firstname, tankman.lastname)
                    continue
                slot = tankman.vehicleSlotIdx
            if self.filter['nation'] != -1 and tankman.nationID != self.filter['nation'] or self.filter['role'] != 'None' and tankman.descriptor.role != self.filter['role'] or self.filter['tankType'] != 'None' and tankman.vehicleNativeType != self.filter['tankType'] or self.filter['location'] == 'tanks' and tankman.isInTank is not True or self.filter['location'] == 'barracks' and tankman.isInTank is True or self.filter['nationID'] is not None and (self.filter['location'] != str(vehicleInnationID) or self.filter['nationID'] != str(tankman.nationID)):
                continue
            isLocked, msg = self.getTankmanLockMessage(vehicle) if tankman.isInTank else (False, '')
            tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
            isInCurrentTank = tankmanVehicle.invID == g_currentVehicle.invID if tankman.isInTank and g_currentVehicle.isPresent() else False
            tankmenList.append({'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,
             'slot': slot,
             'roleType': tankman.descriptor.role,
             'tankType': tankmanVehicle.type,
             'inTank': tankman.isInTank,
             'inCurrentTank': isInCurrentTank,
             'vehicleID': vehicleID,
             'compact': str(tankman.invID),
             'locked': isLocked,
             'lockMessage': msg,
             'vehicleBroken': vehicle.repairCost > 0 if tankman.isInTank else None,
             'isInSelfVehicleClass': vehicle.type == tankmanVehicle.type if tankman.isInTank else True,
             'isInSelfVehicleType': vehicle.shortUserName == tankmanVehicle.shortUserName if tankman.isInTank else True})

        tankmenInSlots = len(tankmenList) - 1
        if tankmenInBarracks < slots:
            tankmenList.insert(1, {'empty': True,
             'freePlaces': slots - tankmenInBarracks})
        self.as_setTankmenS(len(tankmen), tankmenInSlots, slots, tankmenInBarracks, tankmenList)
        return
Пример #34
0
    def __updateTankmen(self, *args):
        tankmen = g_itemsCache.items.getTankmen().values()
        slots = g_itemsCache.items.stats.tankmenBerthsCount
        berths = g_itemsCache.items.stats.tankmenBerthsCount
        berthPrice = g_itemsCache.items.shop.getTankmanBerthPrice(berths)
        defaultBerthPrice = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths)
        tankmenList = list()
        tankmenInBarracks = 0
        tankmenInSlots = 0
        action = None
        if berthPrice[0] != defaultBerthPrice[0]:
            action = {
                "type": ACTION_TOOLTIPS_TYPE.ECONOMICS,
                "key": "berthsPrices",
                "isBuying": True,
                "state": (None, ACTION_TOOLTIPS_STATE.DISCOUNT),
                "newPrice": (0, berthPrice[0]),
                "oldPrice": (0, defaultBerthPrice[0]),
            }
        tankmenList.append(
            {
                "buy": True,
                "price": BigWorld.wg_getGoldFormat(berthPrice[0]),
                "actionPriceData": action,
                "count": berthPrice[1],
            }
        )
        for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)):
            if not tankman.isInTank:
                tankmenInBarracks += 1
            slot, vehicleID, vehicleInnationID, vehicle = (None, None, None, None)
            if tankman.isInTank:
                vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
                vehicleID = vehicle.invID
                vehicleInnationID = vehicle.innationID
                if vehicle is None:
                    LOG_ERROR(
                        "Cannot find vehicle for tankman: ",
                        tankman,
                        tankman.descriptor.role,
                        tankman.vehicle.name,
                        tankman.firstname,
                        tankman.lastname,
                    )
                    continue
                slot = tankman.vehicleSlotIdx
            if (
                self.filter["nation"] != -1
                and tankman.nationID != self.filter["nation"]
                or self.filter["role"] != "None"
                and tankman.descriptor.role != self.filter["role"]
                or self.filter["tankType"] != "None"
                and tankman.vehicleNativeType != self.filter["tankType"]
                or self.filter["location"] == "tanks"
                and tankman.isInTank != True
                or self.filter["location"] == "barracks"
                and tankman.isInTank == True
                or self.filter["nationID"] is not None
                and (
                    self.filter["location"] != str(vehicleInnationID)
                    or self.filter["nationID"] != str(tankman.nationID)
                )
            ):
                continue
            isLocked, msg = self.getTankmanLockMessage(vehicle) if tankman.isInTank else (False, "")
            tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
            isInCurrentTank = (
                tankmanVehicle.invID == g_currentVehicle.invID
                if tankman.isInTank and g_currentVehicle.isPresent()
                else False
            )
            tankmenList.append(
                {
                    "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,
                    "slot": slot,
                    "roleType": tankman.descriptor.role,
                    "tankType": tankmanVehicle.type,
                    "inTank": tankman.isInTank,
                    "inCurrentTank": isInCurrentTank,
                    "vehicleID": vehicleID,
                    "compact": str(tankman.invID),
                    "locked": isLocked,
                    "lockMessage": msg,
                    "vehicleBroken": vehicle.repairCost > 0 if tankman.isInTank else None,
                    "isInSelfVehicleClass": vehicle.type == tankmanVehicle.type if tankman.isInTank else True,
                    "isInSelfVehicleType": vehicle.shortUserName == tankmanVehicle.shortUserName
                    if tankman.isInTank
                    else True,
                }
            )

        tankmenInSlots = len(tankmenList) - 1
        if tankmenInBarracks < slots:
            tankmenList.insert(1, {"empty": True, "freePlaces": slots - tankmenInBarracks})
        self.as_setTankmenS(len(tankmen), tankmenInSlots, slots, tankmenInBarracks, tankmenList)
        return
 def _packBlocks(self, *args, **kwargs):
     items = super(NotRecruitedTooltipData, self)._packBlocks()
     item = self.context.buildItem(*args)
     self.item = item
     blocks = list()
     blocks.append(
         formatters.packImageTextBlockData(
             title=text_styles.highTitle(item.getFullUserName()),
             desc=text_styles.main(item.getLabel())))
     specialIcon = item.getSpecialIcon()
     blocks.append(
         formatters.packImageBlockData(
             img=specialIcon
             if specialIcon is not None else item.getBigIcon(),
             align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER,
             width=350 if specialIcon is not None else -1,
             height=238 if specialIcon is not None else -1))
     blocks.append(
         formatters.packSeparatorBlockData(paddings=formatters.packPadding(
             top=-40)))
     descrStr = i18n.makeString(item.getDescription())
     hasDescr = descrStr != EMPTY_STRING
     if hasDescr:
         blocks.append(
             formatters.packTextBlockData(
                 text_styles.main(descrStr),
                 useHtml=True,
                 padding=formatters.packPadding(top=18)))
     howToGetStr = i18n.makeString(item.getHowToGetInfo())
     hasHowToGetStr = howToGetStr != EMPTY_STRING
     if hasHowToGetStr:
         blocks.append(
             formatters.packTextBlockData(text_styles.middleTitle(
                 backport.text(
                     R.strings.tooltips.notrecruitedtankman.howToGet())),
                                          useHtml=True,
                                          padding=formatters.packPadding(
                                              top=17 if hasDescr else 18,
                                              bottom=5)))
         blocks.append(
             formatters.packTextBlockData(text_styles.main(howToGetStr),
                                          useHtml=True,
                                          padding=formatters.packPadding()))
     skills = item.getLearntSkills()
     if skills:
         blocks.append(
             formatters.packTextBlockData(text_styles.middleTitle(
                 TOOLTIPS.NOTRECRUITEDTANKMAN_SKILLSTITLE),
                                          useHtml=True,
                                          padding=formatters.packPadding(
                                              top=17 if hasDescr else 18,
                                              bottom=10)))
         blocks.append(
             formatters.packImageListParameterBlockData(listIconSrc=[
                 formatters.packImageListIconData(
                     Tankman.getSkillIconPath(skillName=skillName,
                                              size='big'))
                 for skillName in skills
             ],
                                                        columnWidth=52,
                                                        rowHeight=52,
                                                        verticalGap=10,
                                                        horizontalGap=10))
     expiryTime = item.getExpiryTime()
     if expiryTime:
         blocks.append(
             formatters.packTextBlockData(
                 text_styles.middleTitle(
                     TOOLTIPS.NOTRECRUITEDTANKMAN_EXPIRETITLE),
                 useHtml=True,
                 padding=formatters.packPadding(top=20 if skills else
                                                (17 if hasDescr else 16),
                                                bottom=2)))
         expireDateStr = makeString(TOOLTIPS.NOTRECRUITEDTANKMAN_USEBEFORE,
                                    date=expiryTime)
         blocks.append(
             formatters.packTextParameterWithIconBlockData(
                 name=text_styles.premiumVehicleName(expireDateStr),
                 value='',
                 icon=ICON_TEXT_FRAMES.RENTALS,
                 padding=formatters.packPadding(left=-60, bottom=-18),
                 iconYOffset=3))
     items.append(
         formatters.packBuildUpBlockData(
             blocks, padding=formatters.packPadding(bottom=-5)))
     return items
Пример #36
0
    def __updateTankmen(self, *args):
        tankmen = g_itemsCache.items.getTankmen().values()
        slots = g_itemsCache.items.stats.tankmenBerthsCount
        berths = g_itemsCache.items.stats.tankmenBerthsCount
        berthPrice = g_itemsCache.items.shop.getTankmanBerthPrice(berths)
        defaultBerthPrice = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths)
        tankmenList = list()
        tankmenInBarracks = 0
        tankmenInSlots = 0
        action = None
        if berthPrice[0] != defaultBerthPrice[0]:
            action = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS,
             'key': 'berthsPrices',
             'isBuying': True,
             'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT),
             'newPrice': (0, berthPrice[0]),
             'oldPrice': (0, defaultBerthPrice[0])}
        tankmenList.append({'buy': True,
         'price': BigWorld.wg_getGoldFormat(berthPrice[0]),
         'actionPriceData': action,
         'count': berthPrice[1]})
        for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)):
            if not tankman.isInTank:
                tankmenInBarracks += 1
            slot, vehicleID, vehicleInnationID, vehicle = (None, None, None, None)
            if tankman.isInTank:
                vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
                vehicleID = vehicle.invID
                vehicleInnationID = vehicle.innationID
                if vehicle is None:
                    LOG_ERROR('Cannot find vehicle for tankman: ', tankman, tankman.descriptor.role, tankman.vehicle.name, tankman.firstname, tankman.lastname)
                    continue
                slot = tankman.vehicleSlotIdx
            if self.filter['nation'] != -1 and tankman.nationID != self.filter['nation'] or self.filter['role'] != 'None' and tankman.descriptor.role != self.filter['role'] or self.filter['tankType'] != 'None' and tankman.vehicleNativeType != self.filter['tankType'] or self.filter['location'] == 'tanks' and tankman.isInTank != True or self.filter['location'] == 'barracks' and tankman.isInTank == True or self.filter['nationID'] is not None and (self.filter['location'] != str(vehicleInnationID) or self.filter['nationID'] != str(tankman.nationID)):
                continue
            isLocked, msg = self.getTankmanLockMessage(vehicle) if tankman.isInTank else (False, '')
            tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
            isInCurrentTank = tankmanVehicle.invID == g_currentVehicle.invID if tankman.isInTank and g_currentVehicle.isPresent() else False
            tankmenList.append({'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,
             'slot': slot,
             'roleType': tankman.descriptor.role,
             'tankType': tankmanVehicle.type,
             'inTank': tankman.isInTank,
             'inCurrentTank': isInCurrentTank,
             'vehicleID': vehicleID,
             'compact': str(tankman.invID),
             'locked': isLocked,
             'lockMessage': msg,
             'vehicleBroken': vehicle.repairCost > 0 if tankman.isInTank else None,
             'isInSelfVehicleClass': vehicle.type == tankmanVehicle.type if tankman.isInTank else True,
             'isInSelfVehicleType': vehicle.shortUserName == tankmanVehicle.shortUserName if tankman.isInTank else True})

        tankmenInSlots = len(tankmenList) - 1
        if tankmenInBarracks < slots:
            tankmenList.insert(1, {'empty': True,
             'freePlaces': slots - tankmenInBarracks})
        self.as_setTankmenS(len(tankmen), tankmenInSlots, slots, tankmenInBarracks, tankmenList)
        return
Пример #37
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
Пример #38
0
def packTankman(tankman, isCountPermanentSkills=True):
    def vehicleIcon(vDescr, subtype=''):
        return _ICONS_MASK % {
            'type': 'vehicle',
            'subtype': subtype,
            'unicName': vDescr.name.replace(':', '-')
        }

    nativeVehicleData = {
        'typeCompDescr': tankman.vehicleNativeDescr.type.compactDescr,
        'userName': Vehicle.getShortUserName(tankman.vehicleNativeDescr.type),
        'icon': vehicleIcon(tankman.vehicleNativeDescr),
        'iconContour': vehicleIcon(tankman.vehicleNativeDescr, 'contour/')
    }
    currentVehicleData = None
    if tankman.isInTank:
        currentVehicleData = {
            'inventoryID': tankman.vehicleInvID,
            'typeCompDescr': tankman.vehicleDescr.type.compactDescr,
            'userName': Vehicle.getShortUserName(tankman.vehicleDescr.type),
            'icon': vehicleIcon(tankman.vehicleDescr),
            'iconContour': vehicleIcon(tankman.vehicleDescr, 'contour/')
        }
    skills = []
    tManFreeSkillsNum = tankman.descriptor.freeSkillsNumber
    startSkillNumber = 0 if isCountPermanentSkills else tManFreeSkillsNum
    tManSkills = tankman.skills
    for i in range(startSkillNumber, len(tManSkills)):
        skills.append(
            packTankmanSkill(
                tManSkills[i],
                isPermanent=True if i < tManFreeSkillsNum else False))

    return {
        'strCD': cPickle.dumps(tankman.strCD),
        'inventoryID': tankman.invID,
        'nationID': tankman.nationID,
        'firstUserName': tankman.firstUserName,
        'lastUserName': tankman.lastUserName,
        'roleName': tankman.descriptor.role,
        'rankUserName': tankman.rankUserName,
        'roleUserName': tankman.roleUserName,
        'skills': skills,
        'efficiencyRoleLevel': tankman.efficiencyRoleLevel,
        'realRoleLevel': tankman.realRoleLevel,
        'roleLevel': tankman.roleLevel,
        'icon': {
            'big':
            Tankman.getBigIconPath(tankman.nationID,
                                   tankman.descriptor.iconID),
            'small':
            Tankman.getSmallIconPath(tankman.nationID,
                                     tankman.descriptor.iconID),
            'barracks':
            Tankman.getBarracksIconPath(tankman.nationID,
                                        tankman.descriptor.iconID)
        },
        'iconRole': {
            'big': Tankman.getRoleBigIconPath(tankman.descriptor.role),
            'medium': Tankman.getRoleMediumIconPath(tankman.descriptor.role),
            'small': Tankman.getRoleSmallIconPath(tankman.descriptor.role)
        },
        'iconRank': {
            'big':
            Tankman.getRankBigIconPath(tankman.nationID,
                                       tankman.descriptor.rankID),
            'small':
            Tankman.getRankSmallIconPath(tankman.nationID,
                                         tankman.descriptor.rankID)
        },
        'isInTank': tankman.isInTank,
        'newSkillsCount': tankman.newSkillCount,
        'nativeVehicle': nativeVehicleData,
        'currentVehicle': currentVehicleData
    }
Пример #39
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
Пример #40
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