def commanderTutorXpBonusFactorForCrew(crew, ammo): tutorLevel = component_constants.ZERO_FLOAT haveBrotherhood = True for t in crew: if t.role == 'commander': tutorLevel = t.skillLevel('commander_tutor') if not tutorLevel: return component_constants.ZERO_FLOAT if t.skillLevel('brotherhood') != MAX_SKILL_LEVEL: haveBrotherhood = False skillsConfig = getSkillsConfig() if haveBrotherhood: tutorLevel += skillsConfig.getSkill('brotherhood').crewLevelIncrease equipCrewLevelIncrease = component_constants.ZERO_FLOAT cache = vehicles.g_cache for compDescr, count in AmmoIterator(ammo): itemTypeIdx, _, itemIdx = vehicles.parseIntCompactDescr(compDescr) if itemTypeIdx == ITEM_TYPES.equipment: equipCrewLevelIncrease += getattr(cache.equipments()[itemIdx], 'crewLevelIncrease', component_constants.ZERO_FLOAT) tutorLevel += equipCrewLevelIncrease return tutorLevel * skillsConfig.getSkill( 'commander_tutor').xpBonusFactorPerLevel
def getShellsLayout(self, intCD): vehicleData = self._data['vehicles'].get(intCD) if vehicleData is None: return tuple() return map( lambda data: (g_itemsCache.items.getItemByCD(data[0]), data[1]), AmmoIterator(vehicleData['ammoList']))
def __onGetAmmoSellPriceResponse(self, resultID, ammo, callback): if resultID < 0: if callback is not None: callback(resultID, None, self.__getCacheRevision()) return price = 0 for shellCompDescr, count in AmmoIterator(ammo): if count == 0: continue shellPrice = self.__getPriceFromCache(shellCompDescr) shellSellPrice = self.getSellPrice(shellPrice, self.__getSellPriceModifiersFromCache(shellCompDescr), _SHELL) price += shellSellPrice * count if callback is not None: callback(resultID, price, self.__getCacheRevision())
def calculateLayout(isBoughtForCredits): goldPrice = 0 creditsPrice = 0 for shellCompDescr, count in AmmoIterator(shellsLayout): if not shellCompDescr or not count: continue shell = g_itemsCache.items.getItemByCD(shellCompDescr) if shell.buyPrice[1] and not isBoughtForCredits: goldPrice += shell.buyPrice[1] * count elif shell.buyPrice[1] and isBoughtForCredits: creditsPrice += shell.buyPrice[ 1] * count * g_itemsCache.items.shop.exchangeRateForShellsAndEqs elif shell.buyPrice[0]: creditsPrice += shell.buyPrice[0] * count return (creditsPrice, goldPrice)
def isVehicleValid(vehDescr, vehAmmo, limits): minLevel, maxLevel = limits['level'] classLevelLimits = limits['classLevel'] for classTag in VEHICLE_CLASSES: if classTag not in vehDescr.type.tags: continue if classTag in classLevelLimits: classMinLevel, classMaxLevel = classLevelLimits[classTag] if not classMinLevel <= vehDescr.level <= classMaxLevel: return (False, 'limits/classLevel') elif not minLevel <= vehDescr.level <= maxLevel: return (False, 'limits/level') classesLimits = limits['classes'] if classesLimits is not None: for classTag in VEHICLE_CLASSES: if classTag in vehDescr.type.tags and classTag not in classesLimits: return (False, 'limits/classes') nationLimits = limits['nations'] if nationLimits is not None and nations.NAMES[ vehDescr.type.id[0]] not in nationLimits: return (False, 'limits/nations') else: vehTypeCompDescr = vehDescr.type.compactDescr vehicleLimits = limits['vehicles'] if vehicleLimits is not None and vehTypeCompDescr not in vehicleLimits: return (False, 'limits/vehicles') componentLimits = limits['components'].get(vehTypeCompDescr, None) if componentLimits is not None: isValid, components = componentLimits for compDescr in _collectCurrentReplaceableVehicleComponents( vehDescr): if isValid and compDescr not in components: return (False, 'limits/components') if not isValid and compDescr in components: return (False, 'limits/components') ammoLimits = limits['ammo'] if ammoLimits is not None: isValid, ammoSet = ammoLimits for compDescr, count in AmmoIterator(vehAmmo): if compDescr == 0 or count == 0: continue if isValid and compDescr not in ammoSet: return (False, 'limits/ammo') if not isValid and compDescr in ammoSet: return (False, 'limits/ammo') shellsLimits = limits['shells'] if shellsLimits: for compDescr, count in AmmoIterator(vehAmmo): if compDescr == 0 or count == 0: continue itemTypeIdx = vehicles.parseIntCompactDescr(compDescr)[0] if itemTypeIdx != ITEM_TYPES.shell: continue if count > shellsLimits.get(compDescr, 65535): return (False, 'limits/shells') tagsLimits = limits['tags'] if tagsLimits is not None: isValid, tagSet = tagsLimits for tag in tagSet: if isValid and tag not in vehDescr.type.tags: return (False, 'limits/tags') if not isValid and tag in vehDescr.type.tags: return (False, 'limits/tags') return (True, None)