Rework shield regen graph

This commit is contained in:
DarkPhoenix
2019-08-02 10:32:02 +03:00
parent d52dd535a3
commit 0733fee878
7 changed files with 155 additions and 121 deletions

View File

@@ -46,7 +46,6 @@ class FitCapRegenGraph(FitGraph):
'capAmount': lambda fit, tgt: (0, fit.ship.getModifiedItemAttr('capacitorCapacity'))}
_denormalizers = {
('capAmount', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('capacitorCapacity')}
_getters = {
('time', 'capAmount'): Time2CapAmountGetter,
('time', 'capRegen'): Time2CapRegenGetter,

View File

@@ -39,7 +39,6 @@ class FitMobilityVsTimeGraph(FitGraph):
# Calculation stuff
_denormalizers = {
('distance', 'km'): lambda v, fit, tgt: v / 1000}
_getters = {
('time', 'speed'): Time2SpeedGetter,
('time', 'distance'): Time2DistanceGetter}

View File

@@ -1,118 +0,0 @@
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
import math
from .base import FitGraph, XDef, YDef, Input
class FitShieldRegenGraph(FitGraph):
# UI stuff
internalName = 'shieldRegenGraph'
name = 'Shield Regeneration'
xDefs = [
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')),
XDef(handle='shieldAmount', unit='EHP', label='Shield amount', mainInput=('shieldAmount', '%')),
XDef(handle='shieldAmount', unit='HP', label='Shield amount', mainInput=('shieldAmount', '%')),
XDef(handle='shieldAmount', unit='%', label='Shield amount', mainInput=('shieldAmount', '%'))]
yDefs = [
YDef(handle='shieldAmount', unit='EHP', label='Shield amount'),
YDef(handle='shieldAmount', unit='HP', label='Shield amount'),
YDef(handle='shieldRegen', unit='EHP/s', label='Shield regen'),
YDef(handle='shieldRegen', unit='HP/s', label='Shield regen')]
inputs = [
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=True),
Input(handle='shieldAmount', unit='%', label='Shield amount', iconID=1384, defaultValue=25, defaultRange=(0, 100), mainOnly=True)]
srcExtraCols = ('ShieldAmount', 'ShieldTime')
# Calculation stuff
_normalizers = {
('shieldAmount', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('shieldCapacity')}
_limiters = {
'shieldAmount': lambda fit, tgt: (0, fit.ship.getModifiedItemAttr('shieldCapacity'))}
_denormalizers = {
('shieldAmount', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('shieldCapacity'),
('shieldAmount', 'EHP'): lambda v, fit, tgt: fit.damagePattern.effectivify(fit, v, 'shield'),
('shieldRegen', 'EHP/s'): lambda v, fit, tgt: fit.damagePattern.effectivify(fit, v, 'shield')}
def _time2shieldAmountFull(self, mainParam, miscParams, fit, tgt):
xs = []
ys = []
maxShieldAmount = fit.ship.getModifiedItemAttr('shieldCapacity')
shieldRegenTime = fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000
for time in self._iterLinear(mainParam[1]):
currentShieldAmount = calculateShieldAmount(maxShieldAmount=maxShieldAmount, shieldRegenTime=shieldRegenTime, time=time)
xs.append(time)
ys.append(currentShieldAmount)
return xs, ys
def _time2shieldRegenFull(self, mainParam, miscParams, fit, tgt):
xs = []
ys = []
maxShieldAmount = fit.ship.getModifiedItemAttr('shieldCapacity')
shieldRegenTime = fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000
for time in self._iterLinear(mainParam[1]):
currentShieldAmount = calculateShieldAmount(maxShieldAmount=maxShieldAmount, shieldRegenTime=shieldRegenTime, time=time)
currentShieldRegen = calculateShieldRegen(maxShieldAmount=maxShieldAmount, shieldRegenTime=shieldRegenTime, currentShieldAmount=currentShieldAmount)
xs.append(time)
ys.append(currentShieldRegen)
return xs, ys
def _shieldAmount2shieldAmountFull(self, mainParam, miscParams, fit, tgt):
# Useless, but valid combination of x and y
xs = []
ys = []
for currentShieldAmount in self._iterLinear(mainParam[1]):
xs.append(currentShieldAmount)
ys.append(currentShieldAmount)
return xs, ys
def _shieldAmount2shieldRegenFull(self, mainParam, miscParams, fit, tgt):
xs = []
ys = []
maxShieldAmount = fit.ship.getModifiedItemAttr('shieldCapacity')
shieldRegenTime = fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000
for currentShieldAmount in self._iterLinear(mainParam[1]):
currentShieldRegen = calculateShieldRegen(maxShieldAmount=maxShieldAmount, shieldRegenTime=shieldRegenTime, currentShieldAmount=currentShieldAmount)
xs.append(currentShieldAmount)
ys.append(currentShieldRegen)
return xs, ys
_getters = {
('time', 'shieldAmount'): _time2shieldAmountFull,
('time', 'shieldRegen'): _time2shieldRegenFull,
('shieldAmount', 'shieldAmount'): _shieldAmount2shieldAmountFull,
('shieldAmount', 'shieldRegen'): _shieldAmount2shieldRegenFull}
def calculateShieldAmount(maxShieldAmount, shieldRegenTime, time):
# The same formula as for cap
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
return maxShieldAmount * (1 + math.exp(5 * -time / shieldRegenTime) * -1) ** 2
def calculateShieldRegen(maxShieldAmount, shieldRegenTime, currentShieldAmount):
# The same formula as for cap
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
return 10 * maxShieldAmount / shieldRegenTime * (math.sqrt(currentShieldAmount / maxShieldAmount) - currentShieldAmount / maxShieldAmount)
FitShieldRegenGraph.register()

View File

@@ -0,0 +1 @@
import gui.builtinGraphs.fitShieldRegen.graph # noqa: E402,F401

View File

@@ -0,0 +1,91 @@
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
import math
from gui.builtinGraphs.base import SmoothPointGetter
class Time2ShieldAmountGetter(SmoothPointGetter):
def _getCommonData(self, miscParams, fit, tgt):
return {
'maxShieldAmount': fit.ship.getModifiedItemAttr('shieldCapacity'),
'shieldRegenTime': fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000}
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
y = calculateShieldAmount(
maxShieldAmount=commonData['maxShieldAmount'],
shieldRegenTime=commonData['shieldRegenTime'],
time=x)
return y
class Time2ShieldRegenGetter(SmoothPointGetter):
def _getCommonData(self, miscParams, fit, tgt):
return {
'maxShieldAmount': fit.ship.getModifiedItemAttr('shieldCapacity'),
'shieldRegenTime': fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000}
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
currentShieldAmount = calculateShieldAmount(
maxShieldAmount=commonData['maxShieldAmount'],
shieldRegenTime=commonData['shieldRegenTime'],
time=x)
y = calculateShieldRegen(
maxShieldAmount=commonData['maxShieldAmount'],
shieldRegenTime=commonData['shieldRegenTime'],
currentShieldAmount=currentShieldAmount)
return y
# Useless, but valid combination of x and y
class ShieldAmount2ShieldAmountGetter(SmoothPointGetter):
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
return x
class ShieldAmount2ShieldRegenGetter(SmoothPointGetter):
def _getCommonData(self, miscParams, fit, tgt):
return {
'maxShieldAmount': fit.ship.getModifiedItemAttr('shieldCapacity'),
'shieldRegenTime': fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000}
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
y = calculateShieldRegen(
maxShieldAmount=commonData['maxShieldAmount'],
shieldRegenTime=commonData['shieldRegenTime'],
currentShieldAmount=x)
return y
def calculateShieldAmount(maxShieldAmount, shieldRegenTime, time):
# The same formula as for cap
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
return maxShieldAmount * (1 + math.exp(5 * -time / shieldRegenTime) * -1) ** 2
def calculateShieldRegen(maxShieldAmount, shieldRegenTime, currentShieldAmount):
# The same formula as for cap
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
return 10 * maxShieldAmount / shieldRegenTime * (math.sqrt(currentShieldAmount / maxShieldAmount) - currentShieldAmount / maxShieldAmount)

View File

@@ -0,0 +1,63 @@
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
from gui.builtinGraphs.base import FitGraph, XDef, YDef, Input
from .getter import (
Time2ShieldAmountGetter, Time2ShieldRegenGetter,
ShieldAmount2ShieldAmountGetter, ShieldAmount2ShieldRegenGetter)
class FitShieldRegenGraph(FitGraph):
# UI stuff
internalName = 'shieldRegenGraph'
name = 'Shield Regeneration'
xDefs = [
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')),
XDef(handle='shieldAmount', unit='EHP', label='Shield amount', mainInput=('shieldAmount', '%')),
XDef(handle='shieldAmount', unit='HP', label='Shield amount', mainInput=('shieldAmount', '%')),
XDef(handle='shieldAmount', unit='%', label='Shield amount', mainInput=('shieldAmount', '%'))]
yDefs = [
YDef(handle='shieldAmount', unit='EHP', label='Shield amount'),
YDef(handle='shieldAmount', unit='HP', label='Shield amount'),
YDef(handle='shieldRegen', unit='EHP/s', label='Shield regen'),
YDef(handle='shieldRegen', unit='HP/s', label='Shield regen')]
inputs = [
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=True),
Input(handle='shieldAmount', unit='%', label='Shield amount', iconID=1384, defaultValue=25, defaultRange=(0, 100), mainOnly=True)]
srcExtraCols = ('ShieldAmount', 'ShieldTime')
# Calculation stuff
_normalizers = {
('shieldAmount', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('shieldCapacity')}
_limiters = {
'shieldAmount': lambda fit, tgt: (0, fit.ship.getModifiedItemAttr('shieldCapacity'))}
_denormalizers = {
('shieldAmount', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('shieldCapacity'),
('shieldAmount', 'EHP'): lambda v, fit, tgt: fit.damagePattern.effectivify(fit, v, 'shield'),
('shieldRegen', 'EHP/s'): lambda v, fit, tgt: fit.damagePattern.effectivify(fit, v, 'shield')}
_getters = {
('time', 'shieldAmount'): Time2ShieldAmountGetter,
('time', 'shieldRegen'): Time2ShieldRegenGetter,
('shieldAmount', 'shieldAmount'): ShieldAmount2ShieldAmountGetter,
('shieldAmount', 'shieldRegen'): ShieldAmount2ShieldRegenGetter}
FitShieldRegenGraph.register()

View File

@@ -58,7 +58,6 @@ class FitWarpTimeGraph(FitGraph):
_denormalizers = {
('distance', 'AU'): lambda v, fit, tgt: v / AU_METERS,
('distance', 'km'): lambda v, fit, tgt: v / 1000}
_getters = {
('distance', 'time'): Distance2TimeGetter}