def getTmanRoleLevel(cls, vehInfo): if 'noCrew' not in vehInfo: if 'crewLvl' in vehInfo: return calculateRoleLevel( vehInfo.get('crewLvl', cls.DEFAULT_CREW_LVL), vehInfo.get('crewFreeXP', 0)) if 'tankmen' in vehInfo: for tman in vehInfo['tankmen']: if tman['role'] == Tankman.ROLES.COMMANDER: return calculateRoleLevel( tman.get('roleLevel', cls.DEFAULT_CREW_LVL), tman.get('freeXP', 0)) return None
def formattedList(self): result = [] for item, vehInfo in self.getVehicles(): if 'noCrew' not in vehInfo: tmanRoleLevel = calculateRoleLevel(vehInfo.get('crewLvl', self.DEFAULT_CREW_LVL), vehInfo.get('crewFreeXP', 0)) else: tmanRoleLevel = None vInfoLabels = [] if 'rent' in vehInfo: time = vehInfo.get('rent', {}).get('time', None) rentDays = None if time: if time == float('inf'): pass elif time <= time_utils.DAYS_IN_YEAR: rentDays = int(time) if rentDays: rentDaysStr = makeHtmlString('html_templates:lobby/quests/bonuses', 'rentDays', {'value': str(rentDays)}) vInfoLabels.append(rentDaysStr) if tmanRoleLevel is not None: crewLvl = i18n.makeString('#quests:bonuses/vehicles/crewLvl', tmanRoleLevel) vInfoLabels.append(crewLvl) if len(vInfoLabels): result.append(text_styles.standard(i18n.makeString('#quests:bonuses/vehicles/name', name=text_styles.main(item.userName), vehInfo='; '.join(vInfoLabels)))) else: result.append(text_styles.main(item.userName)) return result
def formatValue(self): groups = {} for tmanInfo in self.getTankmenData(): roleLevel = calculateRoleLevel(tmanInfo.roleLevel, tmanInfo.freeXP, typeID=(tmanInfo.nationID, tmanInfo.vehicleTypeID)) if tmanInfo.vehicleTypeID not in groups: vehIntCD = vehicles.makeIntCompactDescrByID( 'vehicle', tmanInfo.nationID, tmanInfo.vehicleTypeID) groups[tmanInfo.vehicleTypeID] = { 'vehName': g_itemsCache.items.getItemByCD(vehIntCD).shortUserName, 'skills': len(tmanInfo.skills), 'roleLevel': roleLevel } else: group = groups[tmanInfo.vehicleTypeID] group['skills'] += len(tmanInfo.skills) group['roleLevel'] = min(group['roleLevel'], roleLevel) result = [] for group in groups.itervalues(): if group['skills']: labelI18nKey = '#quests:bonuses/item/tankmen/with_skills' else: labelI18nKey = '#quests:bonuses/item/tankmen/no_skills' result.append(i18n.makeString(labelI18nKey, **group)) return ' '.join(result)
def formattedList(self): result = [] for item, vehInfo in self.getVehicles(): if 'noCrew' not in vehInfo: tmanRoleLevel = calculateRoleLevel( vehInfo.get('crewLvl', self.DEFAULT_CREW_LVL), vehInfo.get('crewFreeXP', 0)) else: tmanRoleLevel = None vInfoLabels = [] if 'rent' in vehInfo: rentDays = vehInfo.get('rent', {}).get('expires', {}).get('after', None) if rentDays: rentDaysStr = makeHtmlString( 'html_templates:lobby/quests/bonuses', 'rentDays', {'value': str(rentDays)}) vInfoLabels.append(rentDaysStr) if tmanRoleLevel is not None: crewLvl = i18n.makeString('#quests:bonuses/vehicles/crewLvl', tmanRoleLevel) vInfoLabels.append(crewLvl) if len(vInfoLabels): result.append( text_styles.standard( i18n.makeString('#quests:bonuses/vehicles/name', name=text_styles.main(item.userName), vehInfo='; '.join(vInfoLabels)))) else: result.append(text_styles.main(item.userName)) return result
def __getTmanRoleLevel(cls, vehInfo): if 'noCrew' not in vehInfo: return calculateRoleLevel( vehInfo.get('crewLvl', cls.DEFAULT_CREW_LVL), vehInfo.get('crewFreeXP', 0)) else: return None return None
def getTankmenGroups(self): """ Create groups by vehicle. """ groups = {} for tmanInfo in self.getTankmenData(): roleLevel = calculateRoleLevel(tmanInfo.roleLevel, tmanInfo.freeXP, typeID=(tmanInfo.nationID, tmanInfo.vehicleTypeID)) if tmanInfo.vehicleTypeID not in groups: vehIntCD = vehicles.makeIntCompactDescrByID('vehicle', tmanInfo.nationID, tmanInfo.vehicleTypeID) groups[tmanInfo.vehicleTypeID] = {'vehName': self.itemsCache.items.getItemByCD(vehIntCD).shortUserName, 'skills': len(tmanInfo.skills), 'roleLevel': roleLevel} else: group = groups[tmanInfo.vehicleTypeID] group['skills'] += len(tmanInfo.skills) group['roleLevel'] = min(group['roleLevel'], roleLevel) return groups
def formattedList(self): result = [] for item, vehInfo in self.getVehicles(): if 'noCrew' not in vehInfo: tmanRoleLevel = calculateRoleLevel(vehInfo.get('crewLvl', self.DEFAULT_CREW_LVL), vehInfo.get('crewFreeXP', 0)) else: tmanRoleLevel = None vInfoLabels = [] if 'rent' in vehInfo: rentDays = vehInfo.get('rent', {}).get('expires', {}).get('after', None) if rentDays: rentDaysStr = makeHtmlString('html_templates:lobby/quests/bonuses', 'rentDays', {'value': str(rentDays)}) vInfoLabels.append(rentDaysStr) if tmanRoleLevel is not None: crewLvl = i18n.makeString('#quests:bonuses/vehicles/crewLvl', tmanRoleLevel) vInfoLabels.append(crewLvl) if len(vInfoLabels): result.append(i18n.makeString('#quests:bonuses/vehicles/name', name=item.userName, vehInfo='; '.join(vInfoLabels))) else: result.append(item.userName) return result
def formatValue(self): groups = {} for tmanInfo in self.getTankmenData(): roleLevel = calculateRoleLevel(tmanInfo.roleLevel, tmanInfo.freeXP, typeID=(tmanInfo.nationID, tmanInfo.vehicleTypeID)) if tmanInfo.vehicleTypeID not in groups: vehIntCD = vehicles.makeIntCompactDescrByID('vehicle', tmanInfo.nationID, tmanInfo.vehicleTypeID) groups[tmanInfo.vehicleTypeID] = {'vehName': g_itemsCache.items.getItemByCD(vehIntCD).shortUserName, 'skills': len(tmanInfo.skills), 'roleLevel': roleLevel} else: group = groups[tmanInfo.vehicleTypeID] group['skills'] += len(tmanInfo.skills) group['roleLevel'] = min(group['roleLevel'], roleLevel) result = [] for group in groups.itervalues(): if group['skills']: labelI18nKey = '#quests:bonuses/item/tankmen/with_skills' else: labelI18nKey = '#quests:bonuses/item/tankmen/no_skills' result.append(i18n.makeString(labelI18nKey, **group)) return ' '.join(result)