From e83e081548e2e9263f297c0ea58638a9ed1144b2 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 12 Dec 2018 10:20:17 +0300 Subject: [PATCH] Calculate amount of cycles for spoolup --- ...hipmoduleremotearmormutadaptiverepairer.py | 2 +- eos/saveddata/module.py | 4 ++-- eos/utils/spoolSupport.py | 21 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/eos/effects/shipmoduleremotearmormutadaptiverepairer.py b/eos/effects/shipmoduleremotearmormutadaptiverepairer.py index 1a58ea99e..518698e29 100644 --- a/eos/effects/shipmoduleremotearmormutadaptiverepairer.py +++ b/eos/effects/shipmoduleremotearmormutadaptiverepairer.py @@ -15,5 +15,5 @@ def handler(fit, container, context, **kwargs): repSpoolMax = container.getModifiedItemAttr("repairMultiplierBonusMax") repSpoolPerCycle = container.getModifiedItemAttr("repairMultiplierBonusPerCycle") # TODO: use spoolup options to fetch main value - repAmount = repAmountBase * (1 + calculateSpoolup(repSpoolMax, repSpoolPerCycle, cycleTime, SpoolType.SCALE, 1)) + repAmount = repAmountBase * (1 + calculateSpoolup(repSpoolMax, repSpoolPerCycle, cycleTime, SpoolType.SCALE, 1)[0]) fit.extraAttributes.increase("armorRepair", repAmount / cycleTime, **kwargs) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index a780763ef..72e460ce0 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -450,7 +450,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): spoolType if spoolType is not None else self.spoolType, # Using spool type as condition as it should define if we're using # passed spoolup parameters or not - spoolAmount if spoolType is not None else self.spoolAmount) + spoolAmount if spoolType is not None else self.spoolAmount)[0] volley = DmgTypes( em=self.__baseVolley.em * spoolMultiplier * (1 - getattr(targetResists, "emAmount", 0)), thermal=self.__baseVolley.thermal * spoolMultiplier * (1 - getattr(targetResists, "thermalAmount", 0)), @@ -518,7 +518,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): spoolType if spoolType is not None else self.spoolType, # Using spool type as condition as it should define if we're using # passed spoolup parameters or not - spoolAmount if spoolType is not None else self.spoolAmount) + spoolAmount if spoolType is not None else self.spoolAmount)[0] rrAmount *= spoolMultiplier return rrType, rrAmount diff --git a/eos/utils/spoolSupport.py b/eos/utils/spoolSupport.py index b91e90d40..62e6d0839 100644 --- a/eos/utils/spoolSupport.py +++ b/eos/utils/spoolSupport.py @@ -25,9 +25,9 @@ from eos.utils.float import floatUnerr @unique class SpoolType(IntEnum): - SCALE = 0 # [0..1] - TIME = 1 # Expressed via time in seconds since spoolup started - CYCLES = 2 # Expressed in amount of cycles since spoolup started + SCALE = 0 # [0..1] + TIME = 1 # Expressed via time in seconds since spool up started + CYCLES = 2 # Expressed in amount of cycles since spool up started def calculateSpoolup(modMaxValue, modStepValue, modCycleTime, spoolType, spoolAmount): @@ -36,14 +36,15 @@ def calculateSpoolup(modMaxValue, modStepValue, modCycleTime, spoolType, spoolAm is specified in seconds. """ if not modMaxValue or not modStepValue: - return 0 + return 0, 0 if spoolType == SpoolType.SCALE: - return int(floatUnerr(spoolAmount * modMaxValue / modStepValue)) * modStepValue + cycles = int(floatUnerr(spoolAmount * modMaxValue / modStepValue)) + return cycles * modStepValue, cycles * modCycleTime elif spoolType == SpoolType.TIME: - cycles = int(floatUnerr(spoolAmount / modCycleTime)) - return min(modMaxValue, cycles * modStepValue) + cycles = min(int(floatUnerr(spoolAmount / modCycleTime)), int(floatUnerr(modMaxValue / modStepValue))) + return cycles * modStepValue, cycles * modCycleTime elif spoolType == SpoolType.CYCLES: - cycles = int(spoolAmount) - return min(modMaxValue, cycles * modStepValue) + cycles = min(int(spoolAmount), int(floatUnerr(modMaxValue / modStepValue))) + return cycles * modStepValue, cycles * modCycleTime else: - return 0 + return 0, 0