From 46ae2a006e3fe8753f213348c90be0fc8d279b19 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Thu, 22 Aug 2019 11:58:31 +0300 Subject: [PATCH] Consider default attr value when fetching original value, too --- eos/modifiedAttributeDict.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index 04015405f..b1fcbdb5d 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -31,6 +31,20 @@ defaultValuesCache = {} cappingAttrKeyCache = {} +def getAttrDefault(key, fallback=None): + try: + default = defaultValuesCache[key] + except KeyError: + attrInfo = getAttributeInfo(key) + if attrInfo is None: + default = defaultValuesCache[key] = None + else: + default = defaultValuesCache[key] = attrInfo.defaultValue + if default is None: + default = fallback + return default + + def getResistanceAttrID(modifyingItem, effect): # If it doesn't exist on the effect, check the modifying modules attributes. If it's there, set it on the # effect for this session so that we don't have to look here again (won't always work when it's None, but @@ -286,6 +300,9 @@ class ModifiedAttributeDict(collections.MutableMapping): if self.original: val = self.original.get(key, val) + if val is None: + val = getAttrDefault(key, fallback=None) + if val is None and val != default: val = default @@ -374,16 +391,7 @@ class ModifiedAttributeDict(collections.MutableMapping): # Grab initial value, priorities are: # Results of ongoing calculation > preAssign > original > 0 - try: - default = defaultValuesCache[key] - except KeyError: - attrInfo = getAttributeInfo(key) - if attrInfo is None: - default = defaultValuesCache[key] = 0.0 - else: - dv = attrInfo.defaultValue - default = defaultValuesCache[key] = dv if dv is not None else 0.0 - + default = getAttrDefault(key, fallback=0.0) val = self.__intermediary.get(key, self.__preAssigns.get(key, self.getOriginal(key, default))) # We'll do stuff in the following order: