def getCommonData(self, callback): items = self.itemsCache.items tankman = items.getTankman(self.tmanInvID) changeRoleCost = items.shop.changeRoleCost defaultChangeRoleCost = items.shop.defaults.changeRoleCost if changeRoleCost != defaultChangeRoleCost and not self.bootcamp.isInBootcamp(): discount = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'changeRoleCost', True, Money(gold=changeRoleCost), Money(gold=defaultChangeRoleCost)) else: discount = None rate = items.shop.freeXPToTManXPRate if rate: toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate) enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0 else: enoughFreeXPForTeaching = False nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) td = tankman.descriptor changeRoleEnabled = tankmen.tankmenGroupCanChangeRole(td.nationID, td.gid, td.isPremium) if changeRoleEnabled: tooltipChangeRole = makeTooltip(TOOLTIPS.CREW_ROLECHANGE_HEADER, TOOLTIPS.CREW_ROLECHANGE_TEXT) else: roleStr = i18n.makeString(TOOLTIPS.crewRole(td.role)) tooltipChangeRole = makeTooltip(TOOLTIPS.CREW_ROLECHANGEFORBID_HEADER, i18n.makeString(TOOLTIPS.CREW_ROLECHANGEFORBID_TEXT, role=roleStr)) showDocumentTab = not td.getRestrictions().isPassportReplacementForbidden() bonuses = tankman.realRoleLevel[1] modifiers = [] if bonuses[0]: modifiers.append({'id': 'fromCommander', 'val': bonuses[0]}) if bonuses[1]: modifiers.append({'id': 'fromSkills', 'val': bonuses[1]}) if bonuses[2] or bonuses[3]: modifiers.append({'id': 'fromEquipment', 'val': bonuses[2] + bonuses[3]}) if bonuses[4]: modifiers.append({'id': 'penalty', 'val': bonuses[4]}) tankmanData = packTankman(tankman) repackTankmanWithSkinData(tankman, tankmanData) callback({'tankman': tankmanData, 'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': packVehicle(nativeVehicle), 'isOpsLocked': isLocked, 'lockMessage': reason, 'modifiers': modifiers, 'enoughFreeXPForTeaching': enoughFreeXPForTeaching, 'tabsData': self.getTabsButtons(showDocumentTab), 'tooltipDismiss': TOOLTIPS.BARRACKS_TANKMEN_DISMISS, 'tooltipUnload': TOOLTIPS.BARRACKS_TANKMEN_UNLOAD, 'dismissEnabled': True, 'unloadEnabled': True, 'changeRoleEnabled': changeRoleEnabled, 'tooltipChangeRole': tooltipChangeRole, 'actionChangeRole': discount}) return
def getCommonData(self, callback): """ Returns common personal case data for tankman, tankman's vehicles, message, flags and so on. """ tankman = g_itemsCache.items.getTankman(self.tmanInvID) nativeVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleDescr.type.compactDescr) (isLocked, reason,) = self.__getTankmanLockMessage(currentVehicle) bonuses = tankman.realRoleLevel[1] modifiers = [] if bonuses[0]: modifiers.append({'id': 'fromCommander', 'val': bonuses[0]}) if bonuses[1]: modifiers.append({'id': 'fromSkills', 'val': bonuses[1]}) if bonuses[2] or bonuses[3]: modifiers.append({'id': 'fromEquipment', 'val': bonuses[2] + bonuses[3]}) if bonuses[4]: modifiers.append({'id': 'penalty', 'val': bonuses[4]}) callback({'tankman': packTankman(tankman), 'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': packVehicle(nativeVehicle), 'isOpsLocked': isLocked or g_currentVehicle.isLocked(), 'lockMessage': reason, 'modifiers': modifiers})
def __setData(self, *args): items = g_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 = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(tankman.skills) hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(tankman.skills)) self.as_setDataS({'money': items.stats.money, 'tankman': packTankman(tankman, isCountPermanentSkills=False), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'newSkills': tankman.newSkillCount, 'defaultSavingMode': 0, 'texts': self.__getTexts()}) return
def __prepareTankmanData(self): items = yield ItemsRequester().request() dropSkillsCost = [] for k in sorted(items.shop.dropSkillsCost.keys()): dropSkillsCost.append(items.shop.dropSkillsCost[k]) skills_count = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(self.__tankman.skills) hasNewSkills = self.__tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (self.__tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(self.__tankman.skills)) self.as_tankManS({'money': (items.stats.credits, items.stats.gold), 'tankman': packTankman(self.__tankman), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'newSkills': self.__tankman.newSkillCount, 'defaultSavingMode': 0}) if len(self.__tankman.skills) < 1: if self.__tankman.roleLevel < 100: self.question = i18n.makeString(DIALOGS.DISMISSTANKMAN_MESSAGE) else: self.__controlNumber = str(self.__tankman.roleLevel) self.question = makeHtmlString('html_templates:lobby/dialogs', 'dismissTankmanMain', {'roleLevel': str(self.__tankman.roleLevel)}) else: if self.__tankman.skills[-1].isPerk: skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISPERK else: skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISABILLITY self.question = makeHtmlString('html_templates:lobby/dialogs', 'dismissTankmanAdditional', {'skillType': i18n.makeString(skillType), 'skillName': self.__tankman.skills[-1].userName, 'roleLevel': str(self.__tankman.skills[-1].level)}) self.__controlNumber = str(self.__tankman.skills[-1].level) self.__updateInputChecker()
def getCommonData(self, callback): items = g_itemsCache.items tankman = items.getTankman(self.tmanInvID) rate = items.shop.freeXPToTManXPRate if rate: toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate) enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0 else: enoughFreeXPForTeaching = False nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) bonuses = tankman.realRoleLevel[1] modifiers = [] if bonuses[0]: modifiers.append({'id': 'fromCommander', 'val': bonuses[0]}) if bonuses[1]: modifiers.append({'id': 'fromSkills', 'val': bonuses[1]}) if bonuses[2] or bonuses[3]: modifiers.append({'id': 'fromEquipment', 'val': bonuses[2] + bonuses[3]}) if bonuses[4]: modifiers.append({'id': 'penalty', 'val': bonuses[4]}) callback({'tankman': packTankman(tankman), 'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': packVehicle(nativeVehicle), 'isOpsLocked': isLocked or g_currentVehicle.isLocked(), 'lockMessage': reason, 'modifiers': modifiers, 'enoughFreeXPForTeaching': enoughFreeXPForTeaching})
def _setTankmanData(self): packedTankman = packTankman(self._tankman) nation = nations.NAMES[packedTankman['nationID']] tankmanIcon = packedTankman['icon']['big'] roleIcon = packedTankman['iconRole']['small'] skinID = self._tankman.skinID if skinID != NO_CREW_SKIN_ID and self.lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = self.itemsCache.items.getCrewSkin(skinID) tankmanIcon = getCrewSkinIconBig(skinItem.getIconID()) tankmanName = localizedFullName(skinItem) else: tankmanName = self._tankman.fullUserName skills = packedTankman['skills'] lastSkillIcon = '' lastSkillLevel = 0 skillsCount = len(skills) if skillsCount > 0: lastSkill = skills[-1] lastSkillIcon = lastSkill['icon']['small'] lastSkillLevel = lastSkill['level'] preLastSkillIcon = '' if skillsCount > 1: preLastSkillIcon = skills[-2]['icon']['small'] roleLevel = packedTankman['roleLevel'] hasNewSkill = self._tankman.hasNewSkill(useCombinedRoles=True) isSkilledTankmen = roleLevel == MAX_SKILL_LEVEL or lastSkillIcon != '' or hasNewSkill isProtectedState = self._isDismissState and isSkilledTankmen if not isSkilledTankmen: skillsCount = -1 newSkillsCount, lastNewSkillLevel = self._tankman.newSkillCount if skillsCount == 0 and hasNewSkill: skillsCount = newSkillsCount preLastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillLevel = lastNewSkillLevel hasNewSkill = False tankmanBlockVO = { 'nation': nation, 'tankmanName': tankmanName, 'tankmanIcon': tankmanIcon, 'roleIcon': roleIcon, 'skillsCount': skillsCount, 'lastSkill': lastSkillIcon, 'lastSkillLevel': lastSkillLevel, 'preLastSkill': preLastSkillIcon, 'hasNewSkill': hasNewSkill, 'newSkillsCount': newSkillsCount, 'lastNewSkillLevel': lastNewSkillLevel, 'roleLevel': roleLevel } vo = self._buildVO() vo.update({ 'isProtectedState': isProtectedState, 'tankmanBlockVO': tankmanBlockVO }) self.as_setDataS(vo)
def __setData(self, *args): items = g_itemsCache.items tankman = items.getTankman(self.tmanInvID) if tankman is None: self.onWindowClose() return dropSkillsCost = [] for k in sorted(items.shop.dropSkillsCost.keys()): skillCost = items.shop.dropSkillsCost[k] defaultSkillCots = items.shop.defaults.dropSkillsCost[k] price = (skillCost['credits'], skillCost['gold']) defaultPrice = (defaultSkillCots['credits'], defaultSkillCots['gold']) isPremium = skillCost['gold'] != 0 action = None if price != defaultPrice: key = 'goldDropSkillsCost' if isPremium else 'creditsDropSkillsCost' newPrice = (0, skillCost['gold']) if isPremium else ( skillCost['credits'], 0) oldPrice = (0, defaultSkillCots['gold']) if isPremium else ( defaultSkillCots['credits'], 0) state = (None, ACTION_TOOLTIPS_STATE.DISCOUNT) if isPremium else ( ACTION_TOOLTIPS_STATE.DISCOUNT, None) action = { 'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': key, 'isBuying': True, 'state': state, 'newPrice': newPrice, 'oldPrice': oldPrice } skillCost['action'] = action dropSkillsCost.append(skillCost) skills_count = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(tankman.skills) hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and ( tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(tankman.skills)) self.as_setDataS({ 'money': items.stats.money, 'tankman': packTankman(tankman, isCountPermanentSkills=False), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'newSkills': tankman.newSkillCount, 'defaultSavingMode': 0, 'texts': self.__getTexts() })
def _getTankmanVO(tankman): packedTankman = packTankman(tankman, isCountPermanentSkills=False) fullName = '%s %s' % (packedTankman['firstUserName'], packedTankman['lastUserName']) return {'name': fullName, 'nation': NAMES[tankman.nationID], 'rank': packedTankman['rankUserName'], 'vehicle': packedTankman['nativeVehicle']['userName'], 'faceIcon': packedTankman['icon']['big'], 'rankIcon': packedTankman['iconRank']['big'], 'roleIcon': packedTankman['iconRole']['medium']}
def _setTankmanData(self): packedTankman = packTankman(self._tankman) nation = nations.NAMES[packedTankman['nationID']] tankmanName = self._tankman.fullUserName tankmanIcon = packedTankman['icon']['big'] roleIcon = packedTankman['iconRole']['small'] skills = packedTankman['skills'] lastSkillIcon = '' lastSkillLevel = 0 skillsCount = len(skills) if skillsCount > 0: lastSkill = skills[-1] lastSkillIcon = lastSkill['icon']['small'] lastSkillLevel = lastSkill['level'] preLastSkillIcon = '' if skillsCount > 1: preLastSkillIcon = skills[-2]['icon']['small'] roleLevel = packedTankman['roleLevel'] hasNewSkill = self._tankman.hasNewSkill(useCombinedRoles=True) isSkilledTankmen = roleLevel == MAX_SKILL_LEVEL or lastSkillIcon != '' or hasNewSkill isProtectedState = self._isDismissState and isSkilledTankmen if not isSkilledTankmen: skillsCount = -1 newSkillsCount, lastNewSkillLevel = self._tankman.newSkillCount if skillsCount == 0 and hasNewSkill: skillsCount = newSkillsCount preLastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillLevel = lastNewSkillLevel hasNewSkill = False tankmanBlockVO = { 'nation': nation, 'tankmanName': tankmanName, 'tankmanIcon': tankmanIcon, 'roleIcon': roleIcon, 'skillsCount': skillsCount, 'lastSkill': lastSkillIcon, 'lastSkillLevel': lastSkillLevel, 'preLastSkill': preLastSkillIcon, 'hasNewSkill': hasNewSkill, 'newSkillsCount': newSkillsCount, 'lastNewSkillLevel': lastNewSkillLevel, 'roleLevel': roleLevel } vo = self._buildVO() vo.update({ 'isProtectedState': isProtectedState, 'tankmanBlockVO': tankmanBlockVO }) self.as_setDataS(vo)
def getCommonData(self, callback): items = self.itemsCache.items tankman = items.getTankman(self.tmanInvID) rate = items.shop.freeXPToTManXPRate if rate: toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate) enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0 else: enoughFreeXPForTeaching = False nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) td = tankman.descriptor changeRoleEnabled = tankmen.tankmenGroupCanChangeRole(td.nationID, td.gid, td.isPremium) if changeRoleEnabled: tooltipChangeRole = '' else: tooltipChangeRole = makeTooltip(TOOLTIPS.CREW_ROLECHANGEFORBID_HEADER, TOOLTIPS.CREW_ROLECHANGEFORBID_TEXT) showDocumentTab = not td.getRestrictions().isPassportReplacementForbidden() bonuses = tankman.realRoleLevel[1] modifiers = [] if bonuses[0]: modifiers.append({'id': 'fromCommander', 'val': bonuses[0]}) if bonuses[1]: modifiers.append({'id': 'fromSkills', 'val': bonuses[1]}) if bonuses[2] or bonuses[3]: modifiers.append({'id': 'fromEquipment', 'val': bonuses[2] + bonuses[3]}) if bonuses[4]: modifiers.append({'id': 'penalty', 'val': bonuses[4]}) callback({'tankman': packTankman(tankman), 'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': packVehicle(nativeVehicle), 'isOpsLocked': isLocked or g_currentVehicle.isLocked(), 'lockMessage': reason, 'modifiers': modifiers, 'enoughFreeXPForTeaching': enoughFreeXPForTeaching, 'tabsData': self.getTabsButtons(showDocumentTab), 'tooltipDismiss': TOOLTIPS.BARRACKS_TANKMEN_DISMISS, 'tooltipUnload': TOOLTIPS.BARRACKS_TANKMEN_UNLOAD, 'dismissEnabled': True, 'unloadEnabled': True, 'changeRoleEnabled': changeRoleEnabled, 'tooltipChangeRole': tooltipChangeRole}) return
def getCommonData(self, callback): items = g_itemsCache.items tankman = items.getTankman(self.tmanInvID) rate = items.shop.freeXPToTManXPRate if rate: toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate) enoughFreeXPForTeaching = items.stats.freeXP - max( 1, toNextPrcLeft / rate) >= 0 else: enoughFreeXPForTeaching = False nativeVehicle = items.getItemByCD( tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = items.getItemByCD( tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) bonuses = tankman.realRoleLevel[1] modifiers = [] if bonuses[0]: modifiers.append({'id': 'fromCommander', 'val': bonuses[0]}) if bonuses[1]: modifiers.append({'id': 'fromSkills', 'val': bonuses[1]}) if bonuses[2] or bonuses[3]: modifiers.append({ 'id': 'fromEquipment', 'val': bonuses[2] + bonuses[3] }) if bonuses[4]: modifiers.append({'id': 'penalty', 'val': bonuses[4]}) callback({ 'tankman': packTankman(tankman), 'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': packVehicle(nativeVehicle), 'isOpsLocked': isLocked or g_currentVehicle.isLocked(), 'lockMessage': reason, 'modifiers': modifiers, 'enoughFreeXPForTeaching': enoughFreeXPForTeaching }) return
def __setTankmanData(self): packedTankman = packTankman(self._tankman) nation = nations.NAMES[packedTankman['nationID']] tankmanName = self._tankman.fullUserName tankmanIcon = packedTankman['icon']['big'] roleIcon = packedTankman['iconRole']['small'] skills = packedTankman['skills'] lastSkillIcon = '' lastSkillLevel = 0 skillsCount = len(skills) if skillsCount > 0: lastSkill = skills[-1] lastSkillIcon = lastSkill['icon']['small'] lastSkillLevel = lastSkill['level'] preLastSkillIcon = '' if skillsCount > 1: preLastSkillIcon = skills[-2]['icon']['small'] roleLevel = packedTankman['roleLevel'] hasNewSkill = self._tankman.hasNewSkill(useCombinedRoles=True) isSkilledTankmen = roleLevel == MAX_SKILL_LEVEL or lastSkillIcon is not '' or hasNewSkill isProtectedState = self._isDismissState and isSkilledTankmen if not isSkilledTankmen: skillsCount = -1 newSkillsCount, lastNewSkillLevel = self._tankman.newSkillCount if skillsCount == 0 and hasNewSkill: skillsCount = newSkillsCount preLastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillLevel = lastNewSkillLevel hasNewSkill = False tankmanBlockVO = {'nation': nation, 'tankmanName': tankmanName, 'tankmanIcon': tankmanIcon, 'roleIcon': roleIcon, 'skillsCount': skillsCount, 'lastSkill': lastSkillIcon, 'lastSkillLevel': lastSkillLevel, 'preLastSkill': preLastSkillIcon, 'hasNewSkill': hasNewSkill, 'newSkillsCount': newSkillsCount, 'lastNewSkillLevel': lastNewSkillLevel, 'roleLevel': roleLevel} vo = self._buildVO() vo.update({'isProtectedState': isProtectedState, 'tankmanBlockVO': tankmanBlockVO}) self.as_setDataS(vo)
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) tankmanData = packTankman(tankman, isCountPermanentSkills=False) repackTankmanWithSkinData(tankman, tankmanData) self.as_setDataS({ 'tankman': tankmanData, 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'newSkills': tankman.newSkillCount, 'defaultSavingMode': 0, 'texts': self.__getTexts() }) self.as_updateRetrainButtonsDataS(packDropSkill(tankman)) return
def __setData(self, *args): items = g_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 = (skillCost['credits'], skillCost['gold']) defaultPrice = (defaultSkillCots['credits'], defaultSkillCots['gold']) isPremium = skillCost['gold'] != 0 action = None if price != defaultPrice: key = 'goldDropSkillsCost' if isPremium else 'creditsDropSkillsCost' newPrice = (0, skillCost['gold']) if isPremium else (skillCost['credits'], 0) oldPrice = (0, defaultSkillCots['gold']) if isPremium else (defaultSkillCots['credits'], 0) state = (None, ACTION_TOOLTIPS_STATE.DISCOUNT) if isPremium else (ACTION_TOOLTIPS_STATE.DISCOUNT, None) action = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': key, 'isBuying': True, 'state': state, 'newPrice': newPrice, 'oldPrice': oldPrice} skillCost['action'] = action dropSkillsCost.append(skillCost) skills_count = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(tankman.skills) hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(tankman.skills)) self.as_setDataS({'money': items.stats.money, 'tankman': packTankman(tankman, isCountPermanentSkills=False), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'newSkills': tankman.newSkillCount, 'defaultSavingMode': 0, 'texts': self.__getTexts()}) return
def getCommonData(self, callback): items = g_itemsCache.items tankman = items.getTankman(self.tmanInvID) rate = items.shop.freeXPToTManXPRate if rate: toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate) enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0 else: enoughFreeXPForTeaching = False nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) bonuses = tankman.realRoleLevel[1] modifiers = [] if bonuses[0]: modifiers.append({"id": "fromCommander", "val": bonuses[0]}) if bonuses[1]: modifiers.append({"id": "fromSkills", "val": bonuses[1]}) if bonuses[2] or bonuses[3]: modifiers.append({"id": "fromEquipment", "val": bonuses[2] + bonuses[3]}) if bonuses[4]: modifiers.append({"id": "penalty", "val": bonuses[4]}) callback( { "tankman": packTankman(tankman), "currentVehicle": packVehicle(currentVehicle) if currentVehicle is not None else None, "nativeVehicle": packVehicle(nativeVehicle), "isOpsLocked": isLocked or g_currentVehicle.isLocked(), "lockMessage": reason, "modifiers": modifiers, "enoughFreeXPForTeaching": enoughFreeXPForTeaching, } ) return