From c7c0c492184d81d8e2c87d7f8f9607ca9635642f Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 27 Nov 2015 20:08:36 -0500 Subject: [PATCH] Fix #434 --- eos/effects/covertopscloakcpupercentbonus1.py | 2 +- eos/modifiedAttributeDict.py | 14 +++++++++++--- eos/saveddata/module.py | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/eos/effects/covertopscloakcpupercentbonus1.py b/eos/effects/covertopscloakcpupercentbonus1.py index cdd671913..534a50a38 100644 --- a/eos/effects/covertopscloakcpupercentbonus1.py +++ b/eos/effects/covertopscloakcpupercentbonus1.py @@ -5,5 +5,5 @@ type = "passive" runTime = "early" def handler(fit, ship, context): - fit.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Cloaking Device", + fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Cloaking"), "cpu", ship.getModifiedItemAttr("eliteBonusCoverOps1"), skill="Covert Ops") diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index a9a0e9fe5..203a1d99a 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -44,7 +44,8 @@ class ModifiedAttributeDict(collections.MutableMapping): class CalculationPlaceholder(): pass - def __init__(self, fit = None): + def __init__(self, fit=None, parent=None): + self.parent = parent self.fit = fit # Stores original values of the entity self.__original = None @@ -225,8 +226,15 @@ class ModifiedAttributeDict(collections.MutableMapping): with the fit and thus get the correct affector. Returns skill level to be used to modify modifier. See GH issue #101 """ - skill = self.fit.character.getSkill(skillName) - self.fit.register(skill) + fit = self.fit + if not fit: + # self.fit is usually set during fit calculations when the item is registered with the fit. However, + # under certain circumstances, an effect will not work as it will try to modify an item which has NOT + # yet been registered and thus has not had self.fit set. In this case, use the modules owner attribute + # to point to the correct fit. See GH Issue #434 + fit = self.parent.owner + skill = fit.character.getSkill(skillName) + fit.register(skill) return skill.level def getAfflictions(self, key): diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 5fbb75e1c..59d2703cd 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -107,8 +107,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): self.__reloadForce = None self.__chargeCycles = None self.__hardpoint = Hardpoint.NONE - self.__itemModifiedAttributes = ModifiedAttributeDict() - self.__chargeModifiedAttributes = ModifiedAttributeDict() + self.__itemModifiedAttributes = ModifiedAttributeDict(parent=self) + self.__chargeModifiedAttributes = ModifiedAttributeDict(parent=self) self.__slot = self.dummySlot # defaults to None if self.__item: