Change fit projection so that projection range actually counts for the sake of calculations overall

No effect support still
This commit is contained in:
DarkPhoenix
2019-09-30 00:19:31 +03:00
parent 20868d6b44
commit b433b0ea7c
5 changed files with 33 additions and 14 deletions

View File

@@ -18,6 +18,7 @@
# =============================================================================== # ===============================================================================
import math import math
from logbook import Logger from logbook import Logger
from sqlalchemy.orm import reconstructor, validates from sqlalchemy.orm import reconstructor, validates
@@ -25,6 +26,7 @@ import eos.db
from eos.effectHandlerHelpers import HandledCharge, HandledItem from eos.effectHandlerHelpers import HandledCharge, HandledItem
from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict
from eos.utils.cycles import CycleInfo from eos.utils.cycles import CycleInfo
from eos.utils.default import DEFAULT
from eos.utils.stats import DmgTypes, RRTypes from eos.utils.stats import DmgTypes, RRTypes
@@ -305,7 +307,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
else: else:
return True return True
def calculateModifiedAttributes(self, fit, runTime, forceProjected=False): def calculateModifiedAttributes(self, fit, runTime, forceProjected=False, forcedProjRange=DEFAULT):
if self.projected or forceProjected: if self.projected or forceProjected:
context = "projected", "drone" context = "projected", "drone"
projected = True projected = True
@@ -313,6 +315,8 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
context = ("drone",) context = ("drone",)
projected = False projected = False
projectionRange = self.projectionRange if forcedProjRange is DEFAULT else forcedProjRange
for effect in self.item.effects.values(): for effect in self.item.effects.values():
if effect.runTime == runTime and \ if effect.runTime == runTime and \
effect.activeByDefault and \ effect.activeByDefault and \
@@ -320,17 +324,17 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
projected is False and effect.isType("passive")): projected is False and effect.isType("passive")):
# See GH issue #765 # See GH issue #765
if effect.getattr('grouped'): if effect.getattr('grouped'):
effect.handler(fit, self, context, self.projectionRange, effect=effect) effect.handler(fit, self, context, projectionRange, effect=effect)
else: else:
i = 0 i = 0
while i != self.amountActive: while i != self.amountActive:
effect.handler(fit, self, context, self.projectionRange, effect=effect) effect.handler(fit, self, context, projectionRange, effect=effect)
i += 1 i += 1
if self.charge: if self.charge:
for effect in self.charge.effects.values(): for effect in self.charge.effects.values():
if effect.runTime == runTime and effect.activeByDefault: if effect.runTime == runTime and effect.activeByDefault:
effect.handler(fit, self, ("droneCharge",), self.projectionRange) effect.handler(fit, self, ("droneCharge",), projectionRange)
def __deepcopy__(self, memo): def __deepcopy__(self, memo):
copy = Drone(self.item) copy = Drone(self.item)

View File

@@ -18,6 +18,7 @@
# =============================================================================== # ===============================================================================
import math import math
from logbook import Logger from logbook import Logger
from sqlalchemy.orm import reconstructor, validates 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.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, ModifiedAttributeDict
from eos.saveddata.fighterAbility import FighterAbility from eos.saveddata.fighterAbility import FighterAbility
from eos.utils.cycles import CycleInfo, CycleSequence 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.float import floatUnerr
from eos.utils.stats import DmgTypes
pyfalog = Logger(__name__) pyfalog = Logger(__name__)
@@ -381,7 +383,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
else: else:
return True return True
def calculateModifiedAttributes(self, fit, runTime, forceProjected=False): def calculateModifiedAttributes(self, fit, runTime, forceProjected=False, forcedProjRange=DEFAULT):
if not self.active: if not self.active:
return return
@@ -392,6 +394,8 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
context = ("fighter",) context = ("fighter",)
projected = False projected = False
projectionRange = self.projectionRange if forcedProjRange is DEFAULT else forcedProjRange
for ability in self.abilities: for ability in self.abilities:
if not ability.active: if not ability.active:
continue continue
@@ -400,11 +404,11 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
if effect.runTime == runTime and effect.activeByDefault and \ if effect.runTime == runTime and effect.activeByDefault and \
((projected and effect.isType("projected")) or not projected): ((projected and effect.isType("projected")) or not projected):
if ability.grouped: if ability.grouped:
effect.handler(fit, self, context, self.projectionRange, effect=effect) effect.handler(fit, self, context, projectionRange, effect=effect)
else: else:
i = 0 i = 0
while i != self.amount: while i != self.amount:
effect.handler(fit, self, context, self.projectionRange, effect=effect) effect.handler(fit, self, context, projectionRange, effect=effect)
i += 1 i += 1
def __deepcopy__(self, memo): def __deepcopy__(self, memo):

View File

@@ -938,7 +938,9 @@ class Fit:
# apply effects onto target fit x amount of times # apply effects onto target fit x amount of times
for _ in range(projectionInfo.amount): for _ in range(projectionInfo.amount):
targetFit.register(item, origin=self) targetFit.register(item, origin=self)
item.calculateModifiedAttributes(targetFit, runTime, True) item.calculateModifiedAttributes(
targetFit, runTime, forceProjected=True,
forcedProjRange=projectionInfo.projectionRange)
def fill(self): def fill(self):
""" """
@@ -1669,6 +1671,8 @@ class Fit:
copyProjectionInfo = fit.getProjectionInfo(fitCopy.ID) copyProjectionInfo = fit.getProjectionInfo(fitCopy.ID)
originalProjectionInfo = fit.getProjectionInfo(self.ID) originalProjectionInfo = fit.getProjectionInfo(self.ID)
copyProjectionInfo.active = originalProjectionInfo.active copyProjectionInfo.active = originalProjectionInfo.active
copyProjectionInfo.amount = originalProjectionInfo.amount
copyProjectionInfo.projectionRange = originalProjectionInfo.projectionRange
forceUpdateSavedata(fit) forceUpdateSavedata(fit)
return fitCopy return fitCopy

View File

@@ -17,8 +17,9 @@
# along with eos. If not, see <http://www.gnu.org/licenses/>. # along with eos. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================== # ===============================================================================
from logbook import Logger
import math import math
from logbook import Logger
from sqlalchemy.orm import reconstructor, validates from sqlalchemy.orm import reconstructor, validates
import eos.db import eos.db
@@ -28,6 +29,7 @@ from eos.modifiedAttributeDict import ChargeAttrShortcut, ItemAttrShortcut, Modi
from eos.saveddata.citadel import Citadel from eos.saveddata.citadel import Citadel
from eos.saveddata.mutator import Mutator from eos.saveddata.mutator import Mutator
from eos.utils.cycles import CycleInfo, CycleSequence from eos.utils.cycles import CycleInfo, CycleSequence
from eos.utils.default import DEFAULT
from eos.utils.float import floatUnerr from eos.utils.float import floatUnerr
from eos.utils.spoolSupport import calculateSpoolup, resolveSpoolOptions from eos.utils.spoolSupport import calculateSpoolup, resolveSpoolOptions
from eos.utils.stats import DmgTypes, RRTypes from eos.utils.stats import DmgTypes, RRTypes
@@ -838,7 +840,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
self.itemModifiedAttributes.clear() self.itemModifiedAttributes.clear()
self.chargeModifiedAttributes.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: # We will run the effect when two conditions are met:
# 1: It makes sense to run the effect # 1: It makes sense to run the effect
# The effect is either offline # The effect is either offline
@@ -855,6 +857,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
context = ("module",) context = ("module",)
projected = False projected = False
projectionRange = self.projectionRange if forcedProjRange is DEFAULT else forcedProjRange
if self.charge is not None: if self.charge is not None:
# fix for #82 and it's regression #106 # fix for #82 and it's regression #106
if not projected or (self.projected and not forceProjected) or gang: 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"))) (not gang or (gang and effect.isType("gang")))
): ):
contexts = ("moduleCharge",) contexts = ("moduleCharge",)
effect.handler(fit, self, contexts, self.projectionRange, effect=effect) effect.handler(fit, self, contexts, projectionRange, effect=effect)
if self.item: if self.item:
if self.state >= FittingModuleState.OVERHEATED: if self.state >= FittingModuleState.OVERHEATED:
@@ -878,7 +882,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
and not forceProjected \ and not forceProjected \
and effect.activeByDefault \ and effect.activeByDefault \
and ((gang and effect.isType("gang")) or not gang): 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(): for effect in self.item.effects.values():
if effect.runTime == runTime and \ if effect.runTime == runTime and \
@@ -888,7 +892,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
(effect.isType("active") and self.state >= FittingModuleState.ACTIVE)) \ (effect.isType("active") and self.state >= FittingModuleState.ACTIVE)) \
and ((projected and effect.isType("projected")) or not projected) \ and ((projected and effect.isType("projected")) or not projected) \
and ((gang and effect.isType("gang")) or not gang): 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): def getCycleParameters(self, reloadOverride=None):
"""Copied from new eos as well""" """Copied from new eos as well"""

3
eos/utils/default.py Normal file
View File

@@ -0,0 +1,3 @@
class DEFAULT:
"""Singleton class to signify default argument value."""
pass