Rework cap regen graph to use new interfaces

This commit is contained in:
DarkPhoenix
2019-05-17 15:11:52 +03:00
parent 1aee4c59c4
commit 690cf5eca1
7 changed files with 80 additions and 118 deletions

View File

@@ -3,21 +3,21 @@ import math
from eos.graph import Graph
class FitCapAmountTimeGraph(Graph):
class FitCapAmountVsTimeGraph(Graph):
def getPlotPoints(self, fit, extraData, xRange, xAmount):
xs = []
ys = []
for x in self._xIter(xRange, xAmount):
xs.append(x)
ys.append(self.calcCap(fit, x))
ys.append(self.calc(fit, x))
return xs, {'capAmount': ys}
def getYForX(self, fit, extraData, x):
return {'capAmount': self.calcCap(fit, x)}
return {'capAmount': self.calc(fit, x)}
@staticmethod
def calcCap(fit, time):
def calc(fit, time):
if time < 0:
return 0
maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity')

View File

@@ -1,25 +0,0 @@
import math
from logbook import Logger
from eos.graph import Graph
pyfalog = Logger(__name__)
class FitCapRegenAmountGraph(Graph):
defaults = {"percentage": '0-100'}
def __init__(self, fit, data=None):
Graph.__init__(self, fit, self.calcRegen, data if data is not None else self.defaults)
self.fit = fit
def calcRegen(self, data):
perc = data['percentage']
maxCap = self.fit.ship.getModifiedItemAttr('capacitorCapacity')
regenTime = self.fit.ship.getModifiedItemAttr('rechargeRate') / 1000
currentCap = maxCap * perc / 100
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
regen = 10 * maxCap / regenTime * (math.sqrt(currentCap / maxCap) - currentCap / maxCap)
return regen

View File

@@ -0,0 +1,26 @@
import math
from eos.graph import Graph
class FitCapRegenVsCapPercGraph(Graph):
def getPlotPoints(self, fit, extraData, xRange, xAmount):
xs = []
ys = []
for x in self._xIter(xRange, xAmount):
xs.append(x)
ys.append(self.calc(fit, x))
return xs, {'capRegen': ys}
def getYForX(self, fit, extraData, x):
return {'capRegen': self.calc(fit, x)}
@staticmethod
def calc(fit, perc):
maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity')
regenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000
currentCap = maxCap * perc / 100
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
regen = 10 * maxCap / regenTime * (math.sqrt(currentCap / maxCap) - currentCap / maxCap)
return regen