示例#1
0
    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
示例#2
0
    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
示例#3
0
    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)
示例#4
0
    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
示例#5
0
 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
示例#6
0
    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
示例#7
0
文件: bonuses.py 项目: webiumsk/WoT
    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
示例#8
0
    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)