def kpi(self): kpiList = [] name = GOODIE_TYPE_TO_KPI_NAME_MAP.get(self.boosterType) if name is not None: kpiList.append( KPI(name, 1.0 + self.effectValue / 100.0, KPI.Type.MUL)) return kpiList
def kpi(self): kpiList = super(OptionalDevice, self).kpi descr = self.descriptor if isinstance(descr, artefacts.StaticFactorDevice): kpiName = VEHICLE_ATTR_TO_KPI_NAME_MAP.get(descr.attribute) if kpiName is not None and descr.factor != 0.0: value = descr.factor if 'enhancedAimDrives' in self.tags: value = 1.0 / value kpiList.append(KPI(kpiName, value)) elif isinstance(descr, artefacts.StaticAdditiveDevice): kpiName = VEHICLE_ATTR_TO_KPI_NAME_MAP.get(descr.attribute) if kpiName is not None and descr.value != 0.0: if kpiName == KPI.Name.CREW_LEVEL: value = 1.0 + descr.value / 100.0 else: value = 1.0 + descr.value kpiList.append(KPI(kpiName, value)) elif isinstance(descr, artefacts.Stereoscope): if descr.activateWhenStillSec == 0.0: name = KPI.Name.VEHICLE_CIRCULAR_VISION_RADIUS else: name = KPI.Name.VEHICLE_STILL_CIRCULAR_VISION_RADIUS kpiList.append(KPI(name, descr.circularVisionRadiusFactor)) elif isinstance(descr, artefacts.EnhancedSuspension): kpiList.extend([KPI(KPI.Name.VEHICLE_CHASSIS_STRENGTH, descr.chassisHealthFactor), KPI(KPI.Name.VEHICLE_CHASSIS_LOAD, descr.chassisMaxLoadFactor), KPI(KPI.Name.VEHICLE_CHASSIS_FALL_DAMAGE_RESISTANCE, descr.vehicleByChassisDamageFactor)]) elif isinstance(descr, artefacts.AntifragmentationLining): kpiList.extend([KPI(KPI.Name.VEHICLE_RAM_OR_EXPLOSION_DAMAGE_RESISTANCE, descr.antifragmentationLiningFactor), KPI(KPI.Name.CREW_HIT_CHANCE, 1.0 - descr.increaseCrewChanceToEvadeHit)]) elif isinstance(descr, artefacts.Grousers): kpiList.extend([KPI(KPI.Name.VEHICLE_SOFT_GROUND_PASSABILITY, 1.0 / descr.factorSoft), KPI(KPI.Name.VEHICLE_MEDIUM_GROUND_PASSABILITY, 1.0 / descr.factorMedium)]) elif isinstance(descr, artefacts.CamouflageNet): kpiList.append(KPI(KPI.Name.VEHICLE_STILL_CAMOUFLAGE, getMaxCamouflageNetBonus())) return kpiList
def _readKpiValue(xmlCtx, section, kpiType): from gui.shared.gui_items import KPI name = section.readString('name') value = section.readFloat('value') specValue = section.readString('specValue') vehicleTypes = section.readString('vehicleTypes').split() if not name: _xml.raiseWrongXml(xmlCtx, kpiType, 'empty <name> tag not allowed') elif name not in KPI.Name.ALL(): _xml.raiseWrongXml(xmlCtx, kpiType, 'unsupported value in <name> tag') return KPI(name, value, kpiType, float(specValue) if specValue else None, vehicleTypes)
def readKpi(xmlCtx, section): from gui.shared.gui_items import KPI kpi = [] for kpiType, subsec in section.items(): if kpiType not in KPI.Type.ALL(): _xml.raiseWrongXml(xmlCtx, kpiType, 'unsupported KPI type') return if kpiType == KPI.Type.ONE_OF: kpi.append(KPI(KPI.Name.COMPOUND_KPI, readKpi(xmlCtx, subsec), KPI.Type.ONE_OF)) if kpiType == KPI.Type.AGGREGATE_MUL: kpi.append(_readAggregateKPI(xmlCtx, subsec, kpiType)) kpi.append(_readKpiValue(xmlCtx, subsec, kpiType)) return kpi
def _readAggregateKPI(xmlCtx, section, kpiType): from gui.shared.gui_items import KPI, AGGREGATE_TO_SINGLE_TYPE_KPI_MAP subKpies = [] for key, subsec in section.items(): if key in KPI.Type.ALL(): if key != AGGREGATE_TO_SINGLE_TYPE_KPI_MAP.get(kpiType, None): _xml.raiseWrongXml(xmlCtx, key, 'unsupported KPI type for aggregating') subKpies.append(_readKpiValue(xmlCtx, subsec, key)) if not subKpies: _xml.raiseWrongXml(xmlCtx, kpiType, 'has not KPI for aggregating') name = section.readString('name') if not name: _xml.raiseWrongXml(xmlCtx, kpiType, 'empty <name> tag not allowed') elif name not in KPI.Name.ALL(): _xml.raiseWrongXml(xmlCtx, kpiType, 'unsupported value in <name> tag') return KPI(name, subKpies, kpiType)
def kpi(self): kpiList = super(Equipment, self).kpi descr = self.descriptor if isinstance(descr, artefacts.Repairkit): isMedkit = 'medkit' in self.tags if isMedkit: kpiList.append(KPI(KPI.Name.CREW_HIT_CHANCE, 1.0 - descr.bonusValue)) else: kpiList.append(KPI(KPI.Name.VEHICLE_REPAIR_SPEED, 1.0 + descr.bonusValue)) elif isinstance(descr, artefacts.Extinguisher): kpiList.append(KPI(KPI.Name.VEHICLE_FIRE_CHANCE, descr.fireStartingChanceFactor)) elif isinstance(descr, artefacts.Fuel): kpiList.extend([KPI(KPI.Name.VEHICLE_ENGINE_POWER, descr.enginePowerFactor), KPI(KPI.Name.VEHICLE_TURRET_ROTATION_SPEED, descr.turretRotationSpeedFactor)]) elif isinstance(descr, artefacts.Stimulator): kpiList.append(KPI(KPI.Name.CREW_LEVEL, 1.0 + self.crewLevelIncrease / 100.0)) elif isinstance(descr, artefacts.RemovedRpmLimiter): kpiList.append(KPI(KPI.Name.VEHICLE_ENGINE_POWER, descr.enginePowerFactor)) return kpiList
def getKpiIterator(self): for kpiName, kpiValue in self.__dict.iteritems(): kpiType = self.__typeDict[kpiName] yield KPI(kpiName, (1.0 if kpiType == KPI.Type.MUL else 0.0) + kpiValue, kpiType)
def getKpi(self, kpiName): kpiType = self.__typeDict[kpiName] return KPI(kpiName, (1.0 if kpiType == KPI.Type.MUL else 0.0) + self.__dict[kpiName], kpiType)
def kpi(self): kpiList = [] if self.descriptor.stunResistanceDuration != 0.0: kpiList.append(KPI(KPI.Name.CREW_STUN_DURATION, 1.0 - self.descriptor.stunResistanceDuration)) return kpiList
def kpi(self): kpiList = super(BattleBooster, self).kpi descr = self.descriptor if isinstance(descr, artefacts.FactorSkillBattleBooster): skillName = CREW_SKILL_TO_KPI_NAME_MAP.get(descr.skillName) if skillName is not None: kpiList.append(KPI(KPI.Name.COMPOUND_KPI, [KPI(skillName, None, KPI.Type.SKILL_BOOST), KPI(skillName, descr.efficiencyFactor, KPI.Type.FACTOR)], KPI.Type.OR)) elif isinstance(descr, artefacts.FactorPerLevelBattleBooster): skillName = CREW_SKILL_TO_KPI_NAME_MAP.get(descr.skillName) if skillName is not None: kpiList.append(KPI(KPI.Name.COMPOUND_KPI, [KPI(skillName, None, KPI.Type.SKILL_BOOST), KPI(skillName, 2.0, KPI.Type.FACTOR)], KPI.Type.OR)) elif isinstance(descr, artefacts.SixthSenseBattleBooster): kpiList.append(KPI(KPI.Name.COMPOUND_KPI, [KPI(KPI.Name.CREW_SKILL_SIXTH_SENSE, None, KPI.Type.SKILL_BOOST), KPI(KPI.Name.CREW_SKILL_SIXTH_SENSE_DELAY, descr.delay, KPI.Type.VALUE)], KPI.Type.OR)) elif isinstance(descr, artefacts.LastEffortBattleBooster): kpiList.append(KPI(KPI.Name.COMPOUND_KPI, [KPI(KPI.Name.CREW_SKILL_LAST_EFFORT, None, KPI.Type.SKILL_BOOST), KPI(KPI.Name.CREW_SKILL_LAST_EFFORT_DURATION, descr.duration, KPI.Type.VALUE)], KPI.Type.OR)) elif isinstance(descr, artefacts.PedantBattleBooster): kpiList.append(KPI(KPI.Name.COMPOUND_KPI, [KPI(KPI.Name.CREW_SKILL_PEDANT, None, KPI.Type.SKILL_BOOST), KPI(KPI.Name.VEHICLE_AMMO_BAY_STRENGTH, descr.ammoBayHealthFactor, KPI.Type.FACTOR)], KPI.Type.OR)) elif isinstance(descr, artefacts.RancorousBattleBooster): kpiList.append(KPI(KPI.Name.COMPOUND_KPI, [KPI(KPI.Name.CREW_SKILL_RANCOROUS, None, KPI.Type.SKILL_BOOST), KPI(KPI.Name.CREW_SKILL_RANCOROUS_DURATION, descr.duration, KPI.Type.VALUE)], KPI.Type.OR)) elif isinstance(descr, artefacts.DynamicEquipment): attribFactors = {VEHICLE_ATTR_TO_KPI_NAME_MAP.get(attribute):(factor if isinstance(descr, artefacts.FactorBattleBooster) else 1.0 + factor / 100.0) for _, (attribute, factor) in descr._config} for name, factor in attribFactors.iteritems(): if name is not None: kpiList.append(KPI(name, factor, KPI.Type.FACTOR)) return kpiList