From 45fca2a87dac5a3dd1a4f3dd7d7834e1711aca8a Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sun, 25 May 2014 14:48:40 -0400 Subject: [PATCH] All things that can affect attribute from current fit/ships is included in modifiedAttributeDict. The previous method was to only add those that change a value. This adds things can can affect it, and then pass a new `used` flag to the dict to show if it's used or not. --- eos/modifiedAttributeDict.py | 16 +++++----------- eos/saveddata/character.py | 4 +++- gui/itemStats.py | 6 ++++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index 324d83b69..f067d27ff 100755 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -184,7 +184,7 @@ class ModifiedAttributeDict(collections.MutableMapping): def iterAfflictions(self): return self.__affectedBy.__iter__() - def __afflict(self, attributeName, operation, bonus): + def __afflict(self, attributeName, operation, bonus, used): """Add modifier to list of things affecting current item""" # Do nothing if no fit is assigned if self.fit is None: @@ -201,15 +201,13 @@ class ModifiedAttributeDict(collections.MutableMapping): # Get modifier which helps to compose 'Affected by' map modifier = self.fit.getModifier() # Add current affliction to set - affs.add((modifier, operation, bonus)) + affs.add((modifier, operation, bonus, used)) def preAssign(self, attributeName, value): """Overwrites original value of the entity with given one, allowing further modification""" self.__preAssigns[attributeName] = value self.__placehold(attributeName) - # Add to afflictions only if preassigned value differs from original - if value != self.getOriginal(attributeName): - self.__afflict(attributeName, "=", value) + self.__afflict(attributeName, "=", value, value != self.getOriginal(attributeName)) def increase(self, attributeName, increase, position="pre"): """Increase value of given attribute by given number""" @@ -225,9 +223,7 @@ class ModifiedAttributeDict(collections.MutableMapping): tbl[attributeName] = 0 tbl[attributeName] += increase self.__placehold(attributeName) - # Add to list of afflictions only if we actually modify value - if increase != 0: - self.__afflict(attributeName, "+", increase) + self.__afflict(attributeName, "+", increase, increase != 0) def multiply(self, attributeName, multiplier, stackingPenalties=False, penaltyGroup="default"): """Multiply value of given attribute by given factor""" @@ -246,9 +242,7 @@ class ModifiedAttributeDict(collections.MutableMapping): self.__multipliers[attributeName] = 1 self.__multipliers[attributeName] *= multiplier self.__placehold(attributeName) - # Add to list of afflictions only if we actually modify value - if multiplier != 1: - self.__afflict(attributeName, "%s*" % ("s" if stackingPenalties else ""), multiplier) + self.__afflict(attributeName, "%s*" % ("s" if stackingPenalties else ""), multiplier, multiplier != 1) def boost(self, attributeName, boostFactor, *args, **kwargs): """Boost value by some percentage""" diff --git a/eos/saveddata/character.py b/eos/saveddata/character.py index 8695ddba2..eaa1fc47c 100755 --- a/eos/saveddata/character.py +++ b/eos/saveddata/character.py @@ -275,7 +275,9 @@ class Skill(HandledItem): return self.item.attributes[key].value def calculateModifiedAttributes(self, fit, runTime): - if self.__suppressed or not self.learned: return + if self.__suppressed: # or not self.learned - removed for GH issue 101 + return + item = self.item if item is None: return diff --git a/gui/itemStats.py b/gui/itemStats.py index 6f4d1c6fa..8a20b28b9 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -615,13 +615,15 @@ class ItemAffectedBy (wx.Panel): cont = self.stuff.itemModifiedAttributes if self.item == self.stuff.item else self.stuff.chargeModifiedAttributes things = {} + for attrName in cont.iterAfflictions(): + # if value is 0 or there has been no change from original to modified, return if cont[attrName] == (cont.getOriginal(attrName) or 0): continue for fit, afflictors in cont.getAfflictions(attrName).iteritems(): - for afflictor, modifier, amount in afflictors: - if afflictor.item is None: + for afflictor, modifier, amount, used in afflictors: + if not used or afflictor.item is None: continue if afflictor.item.name not in things: things[afflictor.item.name] = [type(afflictor), set(), set()]