From 6786cc7efff6b4f3ed8fefa4ef57aa83a72ff05c Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sun, 7 Jul 2019 21:39:36 +0300 Subject: [PATCH] Expose boost/multiplier data to calculation method --- eos/modifiedAttributeDict.py | 47 +++++++++++++++++------ gui/builtinGraphs/fitDamageStats/graph.py | 1 - 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index e44d9b6cf..2948e16c7 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -35,7 +35,7 @@ class ItemAttrShortcut: def getModifiedItemAttrWithExtraMods(self, key, multipliers=(), boosts=(), default=0): """Returns attribute value with passed modifiers applied to it.""" - return_value = self.itemModifiedAttributes.get(key) + return_value = self.itemModifiedAttributes.getWithExtraMods(key, multipliers=multipliers, boosts=boosts) return return_value or default def getItemBaseAttrValue(self, key, default=0): @@ -51,7 +51,7 @@ class ChargeAttrShortcut: def getModifiedChargeAttrWithExtraMods(self, key, multipliers=(), boosts=(), default=0): """Returns attribute value with passed modifiers applied to it.""" - return_value = self.itemModifiedAttributes.get(key) + return_value = self.itemModifiedAttributes.getWithExtraMods(key, multipliers=multipliers, boosts=boosts) return return_value or default def getChargeBaseAttrValue(self, key, default=0): @@ -146,24 +146,47 @@ class ModifiedAttributeDict(collections.MutableMapping): def __getitem__(self, key): # Check if we have final calculated value - key_value = self.__modified.get(key) - if key_value is self.CalculationPlaceholder: - key_value = self.__modified[key] = self.__calculateValue(key) - - if key_value is not None: - return key_value + val = self.__modified.get(key) + if val is self.CalculationPlaceholder: + val = self.__modified[key] = self.__calculateValue(key) + if val is not None: + return val # Then in values which are not yet calculated if self.__intermediary: val = self.__intermediary.get(key) else: val = None - if val is not None: return val + + # Original value is the least priority + return self.getOriginal(key) + + def getWithExtraMods(self, key, multipliers=(), boosts=(), default=0): + """Copy of __getitem__ with some modifications.""" + if not multipliers and not boosts: + return self.get(key, default=default) + + val = self.__calculateValue(key, extraMultipliers=multipliers, extraBoosts=boosts) + if val is not None: + return val + + # Then in values which are not yet calculated + if self.__intermediary: + val = self.__intermediary.get(key) else: - # Original value is the least priority - return self.getOriginal(key) + val = None + if val is not None: + return val + + # Original value + val = self.getOriginal(key) + if val is not None: + return val + + # Passed in default value + return default def __delitem__(self, key): if key in self.__modified: @@ -210,7 +233,7 @@ class ModifiedAttributeDict(collections.MutableMapping): keys.update(iter(self.__intermediary.keys())) return len(keys) - def __calculateValue(self, key): + def __calculateValue(self, key, extraMultipliers=(), extraBoosts=()): # It's possible that various attributes are capped by other attributes, # it's defined by reference maxAttributeID try: diff --git a/gui/builtinGraphs/fitDamageStats/graph.py b/gui/builtinGraphs/fitDamageStats/graph.py index dc5386c96..31b3c7389 100644 --- a/gui/builtinGraphs/fitDamageStats/graph.py +++ b/gui/builtinGraphs/fitDamageStats/graph.py @@ -188,7 +188,6 @@ class FitDamageStatsGraph(FitGraph): tgt=tgt, tpMods=tpMods, distance=distance) - print(tgtSpeed, tgtSigRadius) else: tgtSpeed = miscInputMap['tgtSpeed'] tgtSigRadius = tgt.ship.getModifiedItemAttr('signatureRadius')