Merge branch 'EffectTest' of https://github.com/Ebag333/Pyfa into Ebag333-EffectTest

Conflicts:
	eos/saveddata/fit.py
	eos/saveddata/module.py
This commit is contained in:
Ryan Holmes
2016-11-22 12:34:10 -05:00
24 changed files with 192 additions and 57 deletions

View File

@@ -64,13 +64,18 @@ class Booster(HandledItem, ItemAttrShortcut):
self.__itemModifiedAttributes.overrides = self.__item.overrides
self.__slot = self.__calculateSlot(self.__item)
# Legacy booster side effect code, disabling as not currently implemented
'''
for effect in self.__item.effects.itervalues():
if effect.isType("boosterSideEffect"):
s = SideEffect(self)
s.effect = effect
s.active = effect.ID in self.__activeSideEffectIDs
self.__sideEffects.append(s)
'''
# Legacy booster side effect code, disabling as not currently implemented
'''
def iterSideEffects(self):
return self.__sideEffects.__iter__()
@@ -80,6 +85,7 @@ class Booster(HandledItem, ItemAttrShortcut):
return sideEffect
raise KeyError("SideEffect with %s as name not found" % name)
'''
@property
def itemModifiedAttributes(self):
@@ -112,12 +118,17 @@ class Booster(HandledItem, ItemAttrShortcut):
if not self.active:
return
for effect in self.item.effects.itervalues():
if effect.runTime == runTime and effect.isType("passive"):
if effect.runTime == runTime and \
(effect.isType("passive") or effect.isType("boosterSideEffect")) and \
effect.activeByDefault:
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):
@@ -135,46 +146,52 @@ class Booster(HandledItem, ItemAttrShortcut):
def __deepcopy__(self, memo):
copy = Booster(self.item)
copy.active = self.active
# Legacy booster side effect code, disabling as not currently implemented
'''
origSideEffects = list(self.iterSideEffects())
copySideEffects = list(copy.iterSideEffects())
i = 0
while i < len(origSideEffects):
copySideEffects[i].active = origSideEffects[i].active
i += 1
'''
return copy
# Legacy booster side effect code, disabling as not currently implemented
'''
class SideEffect(object):
def __init__(self, owner):
self.__owner = owner
self.__active = False
self.__effect = None
class SideEffect(object):
def __init__(self, owner):
self.__owner = owner
self.__active = False
self.__effect = None
@property
def active(self):
return self.__active
@property
def active(self):
return self.__active
@active.setter
def active(self, active):
if not isinstance(active, bool):
raise TypeError("Expecting a bool, not a " + type(active))
@active.setter
def active(self, active):
if not isinstance(active, bool):
raise TypeError("Expecting a bool, not a " + type(active))
if active != self.__active:
if active:
self.__owner._Booster__activeSideEffectIDs.append(self.effect.ID)
else:
self.__owner._Booster__activeSideEffectIDs.remove(self.effect.ID)
if active != self.__active:
if active:
self.__owner._Booster__activeSideEffectIDs.append(self.effect.ID)
else:
self.__owner._Booster__activeSideEffectIDs.remove(self.effect.ID)
self.__active = active
self.__active = active
@property
def effect(self):
return self.__effect
@property
def effect(self):
return self.__effect
@effect.setter
def effect(self, effect):
if not hasattr(effect, "handler"):
raise TypeError("Need an effect with a handler")
@effect.setter
def effect(self, effect):
if not hasattr(effect, "handler"):
raise TypeError("Need an effect with a handler")
self.__effect = effect
self.__effect = effect
'''

View File

@@ -335,8 +335,10 @@ class Skill(HandledItem):
return
for effect in item.effects.itervalues():
if effect.runTime == runTime and effect.isType("passive") and \
(not fit.isStructure or effect.isType("structure")):
if effect.runTime == runTime and \
effect.isType("passive") and \
(not fit.isStructure or effect.isType("structure")) and \
effect.activeByDefault:
try:
effect.handler(fit, self, ("skill",))
except AttributeError:

View File

@@ -232,6 +232,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
for effect in self.item.effects.itervalues():
if effect.runTime == runTime and \
effect.activeByDefault and \
((projected is True and effect.isType("projected")) or
projected is False and effect.isType("passive")):
# See GH issue #765
@@ -245,7 +246,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if self.charge:
for effect in self.charge.effects.itervalues():
if effect.runTime == runTime:
if effect.runTime == runTime and effect.activeByDefault:
effect.handler(fit, self, ("droneCharge",))
def __deepcopy__(self, memo):

View File

@@ -270,6 +270,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if ability.active:
effect = ability.effect
if effect.runTime == runTime and \
effect.activeByDefault and \
((projected and effect.isType("projected")) or not projected):
if ability.grouped:
effect.handler(fit, self, context)

View File

@@ -462,6 +462,8 @@ class Fit(object):
context = ("commandRun", thing.__class__.__name__.lower())
if isinstance(thing, Module):
# This should always be a gang effect, otherwise it wouldn't be added to commandBonuses
# @todo: Check this
if effect.isType("gang"):
# todo: ensure that these are run with the module is active only
context += ("commandRun",)

View File

@@ -93,7 +93,7 @@ class Implant(HandledItem, ItemAttrShortcut):
if not self.active:
return
for effect in self.item.effects.itervalues():
if effect.runTime == runTime and effect.isType("passive"):
if effect.runTime == runTime and effect.isType("passive") and effect.activeByDefault:
effect.handler(fit, self, ("implant",))
@validates("fitID", "itemID", "active")

View File

@@ -51,5 +51,5 @@ class Mode(ItemAttrShortcut, HandledItem):
def calculateModifiedAttributes(self, fit, runTime, forceProjected=False):
if self.item:
for effect in self.item.effects.itervalues():
if effect.runTime == runTime:
if effect.runTime == runTime and effect.activeByDefault:
effect.handler(fit, self, context=("module",))

View File

@@ -625,6 +625,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if not projected or (self.projected and not forceProjected) or gang:
for effect in self.charge.effects.itervalues():
if effect.runTime == runTime and \
effect.activeByDefault and \
(effect.isType("offline") or
(effect.isType("passive") and self.state >= State.ONLINE) or
(effect.isType("active") and self.state >= State.ACTIVE)) and \
@@ -645,19 +646,18 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if effect.runTime == runTime and \
effect.isType("overheat") \
and not forceProjected \
and effect.activeByDefault \
and ((gang and effect.isType("gang")) or not gang):
effect.handler(fit, self, context)
for effect in self.item.effects.itervalues():
if effect.runTime == runTime and \
effect.activeByDefault and \
(effect.isType("offline") or
(effect.isType("passive") and self.state >= State.ONLINE) or
(effect.isType("active") and self.state >= State.ACTIVE))\
and ((projected and effect.isType("projected")) or not projected)\
and ((gang and effect.isType("gang")) or not gang):
thing = effect.isType("gang")
if gang:
pass
effect.handler(fit, self, context)
@property

View File

@@ -82,7 +82,9 @@ class Ship(ItemAttrShortcut, HandledItem):
if forceProjected:
return
for effect in self.item.effects.itervalues():
if effect.runTime == runTime and effect.isType("passive"):
if effect.runTime == runTime and \
effect.isType("passive") and \
effect.activeByDefault:
# Ships have effects that utilize the level of a skill as an
# additional operator to the modifier. These are defined in
# the effect itself, and these skillbooks are registered when