diff --git a/graphs/data/__init__.py b/graphs/data/__init__.py index 94d5d30e3..e4207f1cf 100644 --- a/graphs/data/__init__.py +++ b/graphs/data/__init__.py @@ -22,7 +22,7 @@ from . import fitDamageStats from . import fitEwarStats from . import fitRemoteReps from . import fitShieldRegen -from . import fitCapRegen +from . import fitCapacitor from . import fitMobility from . import fitWarpTime from . import fitLockTime diff --git a/graphs/data/base/defs.py b/graphs/data/base/defs.py index 69e778821..94daa676a 100644 --- a/graphs/data/base/defs.py +++ b/graphs/data/base/defs.py @@ -22,7 +22,6 @@ from collections import namedtuple VectorDef = namedtuple('VectorDef', ('lengthHandle', 'lengthUnit', 'angleHandle', 'angleUnit', 'label')) -InputCheckbox = namedtuple('InputCheckbox', ('handle', 'label', 'defaultValue')) class YDef: @@ -111,3 +110,25 @@ class Input: self.mainTooltip == other.mainTooltip, self.secondaryTooltip == other.secondaryTooltip, self.conditions == other.conditions)) + + +class InputCheckbox: + + def __init__(self, handle, label, defaultValue, conditions=()): + self.handle = handle + self.label = label + self.defaultValue = defaultValue + # Format: ((x condition, y condition), (x condition, y condition), ...) + self.conditions = tuple(conditions) + + def __hash__(self): + return hash((self.handle, self.label, self.defaultValue, self.conditions)) + + def __eq__(self, other): + if not isinstance(other, Input): + return False + return all(( + self.handle == other.handle, + self.label == other.label, + self.defaultValue == other.defaultValue, + self.conditions == other.conditions)) diff --git a/graphs/data/fitCapRegen/__init__.py b/graphs/data/fitCapacitor/__init__.py similarity index 100% rename from graphs/data/fitCapRegen/__init__.py rename to graphs/data/fitCapacitor/__init__.py diff --git a/graphs/data/fitCapRegen/getter.py b/graphs/data/fitCapacitor/getter.py similarity index 93% rename from graphs/data/fitCapRegen/getter.py rename to graphs/data/fitCapacitor/getter.py index 66d577a37..9bd43b5a0 100644 --- a/graphs/data/fitCapRegen/getter.py +++ b/graphs/data/fitCapacitor/getter.py @@ -35,6 +35,7 @@ class Time2CapAmountGetter(SmoothPointGetter): capAmount = calculateCapAmount( maxCapAmount=commonData['maxCapAmount'], capRegenTime=commonData['capRegenTime'], + capAmountT0=miscParams['capAmountT0'] or 0, time=time) return capAmount @@ -51,6 +52,7 @@ class Time2CapRegenGetter(SmoothPointGetter): capAmount = calculateCapAmount( maxCapAmount=commonData['maxCapAmount'], capRegenTime=commonData['capRegenTime'], + capAmountT0=miscParams['capAmountT0'] or 0, time=time) capRegen = calculateCapRegen( maxCapAmount=commonData['maxCapAmount'], @@ -83,9 +85,9 @@ class CapAmount2CapRegenGetter(SmoothPointGetter): return capRegen -def calculateCapAmount(maxCapAmount, capRegenTime, time): +def calculateCapAmount(maxCapAmount, capRegenTime, capAmountT0, time): # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate - return maxCapAmount * (1 + math.exp(5 * -time / capRegenTime) * -1) ** 2 + return maxCapAmount * (1 + math.exp(5 * -time / capRegenTime) * (math.sqrt(capAmountT0 / maxCapAmount) - 1)) ** 2 def calculateCapRegen(maxCapAmount, capRegenTime, currentCapAmount): diff --git a/graphs/data/fitCapRegen/graph.py b/graphs/data/fitCapacitor/graph.py similarity index 76% rename from graphs/data/fitCapRegen/graph.py rename to graphs/data/fitCapacitor/graph.py index e69099e2d..5e206be84 100644 --- a/graphs/data/fitCapRegen/graph.py +++ b/graphs/data/fitCapacitor/graph.py @@ -39,12 +39,18 @@ class FitCapRegenGraph(FitGraph): (('time', 's'), None)]), Input(handle='capAmount', unit='%', label='Cap amount', iconID=1668, defaultValue=25, defaultRange=(0, 100), conditions=[ (('capAmount', 'GJ'), None), - (('capAmount', '%'), None)])] + (('capAmount', '%'), None)]), + Input(handle='capAmountT0', unit='%', label='Starting cap amount', iconID=1668, defaultValue=0, defaultRange=(0, 100), conditions=[ + (('time', 's'), None)])] srcExtraCols = ('CapAmount', 'CapTime') # Calculation stuff - _normalizers = {('capAmount', '%'): lambda v, src, tgt: v / 100 * src.item.ship.getModifiedItemAttr('capacitorCapacity')} - _limiters = {'capAmount': lambda src, tgt: (0, src.item.ship.getModifiedItemAttr('capacitorCapacity'))} + _normalizers = { + ('capAmount', '%'): lambda v, src, tgt: v / 100 * src.item.ship.getModifiedItemAttr('capacitorCapacity'), + ('capAmountT0', '%'): lambda v, src, tgt: None if v is None else v / 100 * src.item.ship.getModifiedItemAttr('capacitorCapacity')} + _limiters = { + 'capAmount': lambda src, tgt: (0, src.item.ship.getModifiedItemAttr('capacitorCapacity')), + 'capAmountT0': lambda src, tgt: (0, src.item.ship.getModifiedItemAttr('capacitorCapacity'))} _getters = { ('time', 'capAmount'): Time2CapAmountGetter, ('time', 'capRegen'): Time2CapRegenGetter,