diff --git a/eos/effects/boosterarmorhppenalty.py b/eos/effects/boosterarmorhppenalty.py index c2db78c40..8acfcf6ad 100644 --- a/eos/effects/boosterarmorhppenalty.py +++ b/eos/effects/boosterarmorhppenalty.py @@ -3,8 +3,12 @@ # Used by: # Implants from group: Booster (12 of 48) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Armor Capacity" + +# Attribute that this effect targets +attr = "boosterArmorHPPenalty" def handler(fit, booster, context): - fit.ship.boostItemAttr("armorHP", booster.getModifiedItemAttr("boosterArmorHPPenalty")) + fit.ship.boostItemAttr("armorHP", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boosterarmorrepairamountpenalty.py b/eos/effects/boosterarmorrepairamountpenalty.py index ac06a9c22..5f556908b 100644 --- a/eos/effects/boosterarmorrepairamountpenalty.py +++ b/eos/effects/boosterarmorrepairamountpenalty.py @@ -5,9 +5,13 @@ # Implants named like: Mindflood Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Armor Repair Amount" + +# Attribute that this effect targets +attr = "boosterArmorRepairAmountPenalty" def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Repair Unit", - "armorDamageAmount", booster.getModifiedItemAttr("boosterArmorRepairAmountPenalty")) + "armorDamageAmount", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boostercapacitorcapacitypenalty.py b/eos/effects/boostercapacitorcapacitypenalty.py index 3a8351ac4..087b591f5 100644 --- a/eos/effects/boostercapacitorcapacitypenalty.py +++ b/eos/effects/boostercapacitorcapacitypenalty.py @@ -4,8 +4,12 @@ # Implants named like: Blue Pill Booster (3 of 5) # Implants named like: Exile Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Cap Capacity" + +# Attribute that this effect targets +attr = "boosterCapacitorCapacityPenalty" def handler(fit, booster, context): - fit.ship.boostItemAttr("capacitorCapacity", booster.getModifiedItemAttr("boosterCapacitorCapacityPenalty")) + fit.ship.boostItemAttr("capacitorCapacity", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boostermaxvelocitypenalty.py b/eos/effects/boostermaxvelocitypenalty.py index 0bc951e9e..9059fe0f4 100644 --- a/eos/effects/boostermaxvelocitypenalty.py +++ b/eos/effects/boostermaxvelocitypenalty.py @@ -3,8 +3,12 @@ # Used by: # Implants from group: Booster (12 of 48) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Velocity" + +# Attribute that this effect targets +attr = "boosterMaxVelocityPenalty" def handler(fit, booster, context): - fit.ship.boostItemAttr("maxVelocity", booster.getModifiedItemAttr("boosterMaxVelocityPenalty")) + fit.ship.boostItemAttr("maxVelocity", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boostermissileexplosioncloudpenaltyfixed.py b/eos/effects/boostermissileexplosioncloudpenaltyfixed.py index 778e4b28c..270f53fc3 100644 --- a/eos/effects/boostermissileexplosioncloudpenaltyfixed.py +++ b/eos/effects/boostermissileexplosioncloudpenaltyfixed.py @@ -4,9 +4,13 @@ # Implants named like: Exile Booster (3 of 4) # Implants named like: Mindflood Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Missile Explosion Radius" + +# Attribute that this effect targets +attr = "boosterMissileAOECloudPenalty" def handler(fit, booster, context): fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), - "aoeCloudSize", booster.getModifiedItemAttr("boosterMissileAOECloudPenalty")) + "aoeCloudSize", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boostermissileexplosionvelocitypenalty.py b/eos/effects/boostermissileexplosionvelocitypenalty.py index e81a9fc96..e9857e13c 100644 --- a/eos/effects/boostermissileexplosionvelocitypenalty.py +++ b/eos/effects/boostermissileexplosionvelocitypenalty.py @@ -3,9 +3,13 @@ # Used by: # Implants named like: Blue Pill Booster (3 of 5) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Missile Explosion Velocity" + +# Attribute that this effect targets +attr = "boosterAOEVelocityPenalty" def handler(fit, booster, context): fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), - "aoeVelocity", booster.getModifiedItemAttr("boosterAOEVelocityPenalty")) + "aoeVelocity", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boostermissilevelocitypenalty.py b/eos/effects/boostermissilevelocitypenalty.py index a4f2d1205..5ffe02dd8 100644 --- a/eos/effects/boostermissilevelocitypenalty.py +++ b/eos/effects/boostermissilevelocitypenalty.py @@ -4,9 +4,13 @@ # Implants named like: Crash Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Missile Velocity" + +# Attribute that this effect targets +attr = "boosterMissileVelocityPenalty" def handler(fit, booster, context): fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), - "maxVelocity", "boosterMissileVelocityPenalty") + "maxVelocity", attr) diff --git a/eos/effects/boostershieldcapacitypenalty.py b/eos/effects/boostershieldcapacitypenalty.py index b2c5ed801..8cf5d85c3 100644 --- a/eos/effects/boostershieldcapacitypenalty.py +++ b/eos/effects/boostershieldcapacitypenalty.py @@ -3,8 +3,12 @@ # Used by: # Implants from group: Booster (12 of 48) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Shield Capacity" + +# Attribute that this effect targets +attr = "boosterShieldCapacityPenalty" def handler(fit, booster, context): - fit.ship.boostItemAttr("shieldCapacity", booster.getModifiedItemAttr("boosterShieldCapacityPenalty")) + fit.ship.boostItemAttr("shieldCapacity", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boosterturretfalloffpenalty.py b/eos/effects/boosterturretfalloffpenalty.py index 84f2e2145..f79674987 100644 --- a/eos/effects/boosterturretfalloffpenalty.py +++ b/eos/effects/boosterturretfalloffpenalty.py @@ -4,9 +4,13 @@ # Implants named like: Drop Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Turret Falloff" + +# Attribute that this effect targets +attr = "boosterTurretFalloffPenalty" def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), - "falloff", booster.getModifiedItemAttr("boosterTurretFalloffPenalty")) + "falloff", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boosterturretoptimalrangepenalty.py b/eos/effects/boosterturretoptimalrangepenalty.py index d70275c29..e4f9d7e4c 100644 --- a/eos/effects/boosterturretoptimalrangepenalty.py +++ b/eos/effects/boosterturretoptimalrangepenalty.py @@ -5,9 +5,13 @@ # Implants named like: Mindflood Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Turret Optimal Range" + +# Attribute that this effect targets +attr = "boosterTurretOptimalRange" def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), - "maxRange", booster.getModifiedItemAttr("boosterTurretOptimalRange")) + "maxRange", booster.getModifiedItemAttr(attr)) diff --git a/eos/effects/boosterturrettrackingpenalty.py b/eos/effects/boosterturrettrackingpenalty.py index 6f268fdc4..0e6025b66 100644 --- a/eos/effects/boosterturrettrackingpenalty.py +++ b/eos/effects/boosterturrettrackingpenalty.py @@ -4,9 +4,13 @@ # Implants named like: Exile Booster (3 of 4) # Implants named like: Frentix Booster (3 of 4) type = "boosterSideEffect" -activeByDefault = False +# User-friendly name for the side effect +displayName = "Turret Tracking" + +# Attribute that this effect targets +attr = "boosterTurretTrackingPenalty" def handler(fit, booster, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), - "trackingSpeed", booster.getModifiedItemAttr("boosterTurretTrackingPenalty")) + "trackingSpeed", booster.getModifiedItemAttr(attr)) diff --git a/eos/saveddata/booster.py b/eos/saveddata/booster.py index aa5d6bfcb..413661e86 100644 --- a/eos/saveddata/booster.py +++ b/eos/saveddata/booster.py @@ -76,9 +76,13 @@ class Booster(HandledItem, ItemAttrShortcut): def sideEffects(self): return self.__sideEffects or [] + @property + def activeSideEffectEffects(self): + return [x.effect for x in self.sideEffects if x.active] + def __getSideEffects(self): """Returns list of BoosterSideEffect that are loaded with data""" - return [BoosterSideEffect(effect) for effect in self.item.effects.values() if effect.type and 'boosterSideEffect' in effect.type] + return [BoosterSideEffect(effect) for effect in self.item.effects.values() if effect.isType("boosterSideEffect")] @property def itemModifiedAttributes(self): @@ -111,19 +115,14 @@ class Booster(HandledItem, ItemAttrShortcut): return if not self.active: return + for effect in self.item.effects.itervalues(): if effect.runTime == runTime and \ - (effect.isType("passive") or effect.isType("boosterSideEffect")) and \ - effect.activeByDefault: + (effect.isType("passive") or effect.isType("boosterSideEffect")): + if effect.isType("boosterSideEffect") and effect not in self.activeSideEffectEffects: + continue effect.handler(fit, self, ("booster",)) - # Legacy booster code, not fully implemented - ''' - for sideEffect in self.iterSideEffects(): - if sideEffect.active and sideEffect.effect.runTime == runTime: - sideEffect.effect.handler(fit, self, ("boosterSideEffect",)) - ''' - @validates("ID", "itemID", "ammoID", "active") def validator(self, key, val): map = { diff --git a/eos/saveddata/boosterSideEffect.py b/eos/saveddata/boosterSideEffect.py index 71014c3a7..6f08c0904 100644 --- a/eos/saveddata/boosterSideEffect.py +++ b/eos/saveddata/boosterSideEffect.py @@ -55,9 +55,12 @@ class BoosterSideEffect(object): @property def name(self): - return self.__effect.getattr('displayName') or self.__effect.handlerName + return "{0}% {1}".format( + self.booster.getModifiedItemAttr(self.attr), + self.__effect.getattr('displayName') or self.__effect.handlerName, + ) @property - def attrPrefix(self): - return self.__effect.getattr('prefix') + def attr(self): + return self.__effect.getattr('attr')