Files
pyfa/graphs/data/fitEwarStats/graph.py
2019-08-14 00:09:38 +03:00

47 lines
2.1 KiB
Python

# =============================================================================
# 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 graphs.data.base import FitGraph, Input, XDef, YDef
from .getter import Distance2WebbingStrGetter, Distance2DampStrLockRangeGetter
class FitEwarStatsGraph(FitGraph):
# UI stuff
internalName = 'ewarStatsGraph'
name = 'Electronic Warfare Stats'
xDefs = [XDef(handle='distance', unit='km', label='Distance', mainInput=('distance', 'km'))]
yDefs = [
YDef(handle='webStr', unit='%', label='Web speed reduction'),
YDef(handle='dampStrLockRange', unit='%', label='Damp lock range reduction')]
inputs = [
Input(handle='distance', unit='km', label='Distance', iconID=1391, defaultValue=None, defaultRange=(0, 100)),
Input(handle='resist', unit='%', label='Target resistance', iconID=1393, defaultValue=0, defaultRange=(0, 100))]
# Calculation stuff
_normalizers = {
('distance', 'km'): lambda v, src, tgt: None if v is None else v * 1000,
('resist', '%'): lambda v, src, tgt: None if v is None else v / 100}
_limiters = {'resist': lambda src, tgt: (0, 1)}
_getters = {
('distance', 'webStr'): Distance2WebbingStrGetter,
('distance', 'dampStrLockRange'): Distance2DampStrLockRangeGetter}
_denormalizers = {('distance', 'km'): lambda v, src, tgt: None if v is None else v / 1000}