Finish off user-selectable booster side effects - effects are applied correctly now and each has their own display name. Implements #642

This commit is contained in:
blitzmann
2017-06-05 00:16:32 -04:00
parent c2cb5d763f
commit 47fcbefe8b
13 changed files with 81 additions and 35 deletions

View File

@@ -3,8 +3,12 @@
# Used by: # Used by:
# Implants from group: Booster (12 of 48) # Implants from group: Booster (12 of 48)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.ship.boostItemAttr("armorHP", booster.getModifiedItemAttr("boosterArmorHPPenalty")) fit.ship.boostItemAttr("armorHP", booster.getModifiedItemAttr(attr))

View File

@@ -5,9 +5,13 @@
# Implants named like: Mindflood Booster (3 of 4) # Implants named like: Mindflood Booster (3 of 4)
# Implants named like: Sooth Sayer Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Repair Unit", fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Armor Repair Unit",
"armorDamageAmount", booster.getModifiedItemAttr("boosterArmorRepairAmountPenalty")) "armorDamageAmount", booster.getModifiedItemAttr(attr))

View File

@@ -4,8 +4,12 @@
# Implants named like: Blue Pill Booster (3 of 5) # Implants named like: Blue Pill Booster (3 of 5)
# Implants named like: Exile Booster (3 of 4) # Implants named like: Exile Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.ship.boostItemAttr("capacitorCapacity", booster.getModifiedItemAttr("boosterCapacitorCapacityPenalty")) fit.ship.boostItemAttr("capacitorCapacity", booster.getModifiedItemAttr(attr))

View File

@@ -3,8 +3,12 @@
# Used by: # Used by:
# Implants from group: Booster (12 of 48) # Implants from group: Booster (12 of 48)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.ship.boostItemAttr("maxVelocity", booster.getModifiedItemAttr("boosterMaxVelocityPenalty")) fit.ship.boostItemAttr("maxVelocity", booster.getModifiedItemAttr(attr))

View File

@@ -4,9 +4,13 @@
# Implants named like: Exile Booster (3 of 4) # Implants named like: Exile Booster (3 of 4)
# Implants named like: Mindflood Booster (3 of 4) # Implants named like: Mindflood Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"),
"aoeCloudSize", booster.getModifiedItemAttr("boosterMissileAOECloudPenalty")) "aoeCloudSize", booster.getModifiedItemAttr(attr))

View File

@@ -3,9 +3,13 @@
# Used by: # Used by:
# Implants named like: Blue Pill Booster (3 of 5) # Implants named like: Blue Pill Booster (3 of 5)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"),
"aoeVelocity", booster.getModifiedItemAttr("boosterAOEVelocityPenalty")) "aoeVelocity", booster.getModifiedItemAttr(attr))

View File

@@ -4,9 +4,13 @@
# Implants named like: Crash Booster (3 of 4) # Implants named like: Crash Booster (3 of 4)
# Implants named like: X Instinct Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"), fit.modules.filteredChargeBoost(lambda mod: mod.charge.requiresSkill("Missile Launcher Operation"),
"maxVelocity", "boosterMissileVelocityPenalty") "maxVelocity", attr)

View File

@@ -3,8 +3,12 @@
# Used by: # Used by:
# Implants from group: Booster (12 of 48) # Implants from group: Booster (12 of 48)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.ship.boostItemAttr("shieldCapacity", booster.getModifiedItemAttr("boosterShieldCapacityPenalty")) fit.ship.boostItemAttr("shieldCapacity", booster.getModifiedItemAttr(attr))

View File

@@ -4,9 +4,13 @@
# Implants named like: Drop Booster (3 of 4) # Implants named like: Drop Booster (3 of 4)
# Implants named like: X Instinct Booster (3 of 4) # Implants named like: X Instinct Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
"falloff", booster.getModifiedItemAttr("boosterTurretFalloffPenalty")) "falloff", booster.getModifiedItemAttr(attr))

View File

@@ -5,9 +5,13 @@
# Implants named like: Mindflood Booster (3 of 4) # Implants named like: Mindflood Booster (3 of 4)
# Implants named like: Sooth Sayer Booster (3 of 4) # Implants named like: Sooth Sayer Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
"maxRange", booster.getModifiedItemAttr("boosterTurretOptimalRange")) "maxRange", booster.getModifiedItemAttr(attr))

View File

@@ -4,9 +4,13 @@
# Implants named like: Exile Booster (3 of 4) # Implants named like: Exile Booster (3 of 4)
# Implants named like: Frentix Booster (3 of 4) # Implants named like: Frentix Booster (3 of 4)
type = "boosterSideEffect" 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): def handler(fit, booster, context):
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"), fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Gunnery"),
"trackingSpeed", booster.getModifiedItemAttr("boosterTurretTrackingPenalty")) "trackingSpeed", booster.getModifiedItemAttr(attr))

View File

@@ -76,9 +76,13 @@ class Booster(HandledItem, ItemAttrShortcut):
def sideEffects(self): def sideEffects(self):
return self.__sideEffects or [] return self.__sideEffects or []
@property
def activeSideEffectEffects(self):
return [x.effect for x in self.sideEffects if x.active]
def __getSideEffects(self): def __getSideEffects(self):
"""Returns list of BoosterSideEffect that are loaded with data""" """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 @property
def itemModifiedAttributes(self): def itemModifiedAttributes(self):
@@ -111,19 +115,14 @@ class Booster(HandledItem, ItemAttrShortcut):
return return
if not self.active: if not self.active:
return return
for effect in self.item.effects.itervalues(): for effect in self.item.effects.itervalues():
if effect.runTime == runTime and \ if effect.runTime == runTime and \
(effect.isType("passive") or effect.isType("boosterSideEffect")) and \ (effect.isType("passive") or effect.isType("boosterSideEffect")):
effect.activeByDefault: if effect.isType("boosterSideEffect") and effect not in self.activeSideEffectEffects:
continue
effect.handler(fit, self, ("booster",)) 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") @validates("ID", "itemID", "ammoID", "active")
def validator(self, key, val): def validator(self, key, val):
map = { map = {

View File

@@ -55,9 +55,12 @@ class BoosterSideEffect(object):
@property @property
def name(self): 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 @property
def attrPrefix(self): def attr(self):
return self.__effect.getattr('prefix') return self.__effect.getattr('attr')