diff --git a/eos/saveddata/drone.py b/eos/saveddata/drone.py index 15098711c..7b76a3678 100644 --- a/eos/saveddata/drone.py +++ b/eos/saveddata/drone.py @@ -18,6 +18,7 @@ # =============================================================================== import math + from logbook import Logger from sqlalchemy.orm import reconstructor, validates @@ -25,6 +26,7 @@ import eos.db from eos.effectHandlerHelpers import HandledCharge, HandledItem from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict from eos.utils.cycles import CycleInfo +from eos.utils.default import DEFAULT from eos.utils.stats import DmgTypes, RRTypes @@ -305,7 +307,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): else: return True - def calculateModifiedAttributes(self, fit, runTime, forceProjected=False): + def calculateModifiedAttributes(self, fit, runTime, forceProjected=False, forcedProjRange=DEFAULT): if self.projected or forceProjected: context = "projected", "drone" projected = True @@ -313,6 +315,8 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): context = ("drone",) projected = False + projectionRange = self.projectionRange if forcedProjRange is DEFAULT else forcedProjRange + for effect in self.item.effects.values(): if effect.runTime == runTime and \ effect.activeByDefault and \ @@ -320,17 +324,17 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): projected is False and effect.isType("passive")): # See GH issue #765 if effect.getattr('grouped'): - effect.handler(fit, self, context, self.projectionRange, effect=effect) + effect.handler(fit, self, context, projectionRange, effect=effect) else: i = 0 while i != self.amountActive: - effect.handler(fit, self, context, self.projectionRange, effect=effect) + effect.handler(fit, self, context, projectionRange, effect=effect) i += 1 if self.charge: for effect in self.charge.effects.values(): if effect.runTime == runTime and effect.activeByDefault: - effect.handler(fit, self, ("droneCharge",), self.projectionRange) + effect.handler(fit, self, ("droneCharge",), projectionRange) def __deepcopy__(self, memo): copy = Drone(self.item) diff --git a/eos/saveddata/fighter.py b/eos/saveddata/fighter.py index fe771ba2b..5b177c451 100644 --- a/eos/saveddata/fighter.py +++ b/eos/saveddata/fighter.py @@ -18,6 +18,7 @@ # =============================================================================== import math + from logbook import Logger from sqlalchemy.orm import reconstructor, validates @@ -27,8 +28,9 @@ from eos.effectHandlerHelpers import HandledCharge, HandledItem from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict from eos.saveddata.fighterAbility import FighterAbility from eos.utils.cycles import CycleInfo, CycleSequence -from eos.utils.stats import DmgTypes +from eos.utils.default import DEFAULT from eos.utils.float import floatUnerr +from eos.utils.stats import DmgTypes pyfalog = Logger(__name__) @@ -381,7 +383,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): else: return True - def calculateModifiedAttributes(self, fit, runTime, forceProjected=False): + def calculateModifiedAttributes(self, fit, runTime, forceProjected=False, forcedProjRange=DEFAULT): if not self.active: return @@ -392,6 +394,8 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): context = ("fighter",) projected = False + projectionRange = self.projectionRange if forcedProjRange is DEFAULT else forcedProjRange + for ability in self.abilities: if not ability.active: continue @@ -400,11 +404,11 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): if effect.runTime == runTime and effect.activeByDefault and \ ((projected and effect.isType("projected")) or not projected): if ability.grouped: - effect.handler(fit, self, context, self.projectionRange, effect=effect) + effect.handler(fit, self, context, projectionRange, effect=effect) else: i = 0 while i != self.amount: - effect.handler(fit, self, context, self.projectionRange, effect=effect) + effect.handler(fit, self, context, projectionRange, effect=effect) i += 1 def __deepcopy__(self, memo): diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index c26b31604..3b608eeb4 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -938,7 +938,9 @@ class Fit: # apply effects onto target fit x amount of times for _ in range(projectionInfo.amount): targetFit.register(item, origin=self) - item.calculateModifiedAttributes(targetFit, runTime, True) + item.calculateModifiedAttributes( + targetFit, runTime, forceProjected=True, + forcedProjRange=projectionInfo.projectionRange) def fill(self): """ @@ -1669,6 +1671,8 @@ class Fit: copyProjectionInfo = fit.getProjectionInfo(fitCopy.ID) originalProjectionInfo = fit.getProjectionInfo(self.ID) copyProjectionInfo.active = originalProjectionInfo.active + copyProjectionInfo.amount = originalProjectionInfo.amount + copyProjectionInfo.projectionRange = originalProjectionInfo.projectionRange forceUpdateSavedata(fit) return fitCopy diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index c0f26bcc6..7cce0ccfb 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -17,8 +17,9 @@ # along with eos. If not, see . # =============================================================================== -from logbook import Logger import math + +from logbook import Logger from sqlalchemy.orm import reconstructor, validates import eos.db @@ -28,6 +29,7 @@ from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, Modi from eos.saveddata.citadel import Citadel from eos.saveddata.mutator import Mutator from eos.utils.cycles import CycleInfo, CycleSequence +from eos.utils.default import DEFAULT from eos.utils.float import floatUnerr from eos.utils.spoolSupport import calculateSpoolup, resolveSpoolOptions from eos.utils.stats import DmgTypes, RRTypes @@ -838,7 +840,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): self.itemModifiedAttributes.clear() self.chargeModifiedAttributes.clear() - def calculateModifiedAttributes(self, fit, runTime, forceProjected=False, gang=False): + def calculateModifiedAttributes(self, fit, runTime, forceProjected=False, gang=False, forcedProjRange=DEFAULT): # We will run the effect when two conditions are met: # 1: It makes sense to run the effect # The effect is either offline @@ -855,6 +857,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): context = ("module",) projected = False + projectionRange = self.projectionRange if forcedProjRange is DEFAULT else forcedProjRange + if self.charge is not None: # fix for #82 and it's regression #106 if not projected or (self.projected and not forceProjected) or gang: @@ -868,7 +872,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): (not gang or (gang and effect.isType("gang"))) ): contexts = ("moduleCharge",) - effect.handler(fit, self, contexts, self.projectionRange, effect=effect) + effect.handler(fit, self, contexts, projectionRange, effect=effect) if self.item: if self.state >= FittingModuleState.OVERHEATED: @@ -878,7 +882,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): and not forceProjected \ and effect.activeByDefault \ and ((gang and effect.isType("gang")) or not gang): - effect.handler(fit, self, context, self.projectionRange) + effect.handler(fit, self, context, projectionRange) for effect in self.item.effects.values(): if effect.runTime == runTime and \ @@ -888,7 +892,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): (effect.isType("active") and self.state >= FittingModuleState.ACTIVE)) \ and ((projected and effect.isType("projected")) or not projected) \ and ((gang and effect.isType("gang")) or not gang): - effect.handler(fit, self, context, self.projectionRange, effect=effect) + effect.handler(fit, self, context, projectionRange, effect=effect) def getCycleParameters(self, reloadOverride=None): """Copied from new eos as well""" diff --git a/eos/utils/default.py b/eos/utils/default.py new file mode 100644 index 000000000..764aa042f --- /dev/null +++ b/eos/utils/default.py @@ -0,0 +1,3 @@ +class DEFAULT: + """Singleton class to signify default argument value.""" + pass