Merge pull request #110 from blitzmann/issue-101

Add "Change affecting skill" context menu, resolves #101
This commit is contained in:
Anton Vorobyov
2014-06-01 19:06:19 +04:00
13 changed files with 126 additions and 28 deletions

View File

@@ -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=True):
"""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"""

View File

@@ -87,6 +87,7 @@ class Character(object):
all0 = eos.db.getCharacter("All 0")
if all0 is None:
all0 = Character("All 0")
all0.defaultLevel = None
eos.db.add(all0)
cls.__all0 = all0
@@ -173,12 +174,6 @@ class Character(object):
return self.__implants
def iterSkills(self):
if self.defaultLevel is not None:
return self.iterDefaultLevel()
else:
return self.__skills.__iter__()
def iterDefaultLevel(self):
for item in self.getSkillList():
yield self.getSkill(item)
@@ -275,7 +270,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

View File

@@ -588,8 +588,11 @@ class Fit(object):
for attr in ("shieldRepair", "armorRepair", "hullRepair"):
sustainable[attr] = self.extraAttributes[attr]
dict = self.extraAttributes.getAfflictions(attr)
print dict
if self in dict:
for mod, _, amount in dict[self]:
for mod, _, amount, used in dict[self]:
if not used:
continue
if mod.projected is False:
usesCap = True
try: