本文整理汇总了Python中eos.data.cache.object.modifier.Modifier.operator方法的典型用法代码示例。如果您正苦于以下问题:Python Modifier.operator方法的具体用法?Python Modifier.operator怎么用?Python Modifier.operator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eos.data.cache.object.modifier.Modifier
的用法示例。
在下文中一共展示了Modifier.operator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCombination
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testCombination(self):
tgtAttr = self.ch.attribute(attributeId=1)
absAttr = self.ch.attribute(attributeId=2)
srcAttr = self.ch.attribute(attributeId=3)
invalidModifier = Modifier()
invalidModifier.state = State.offline
invalidModifier.context = Context.local
invalidModifier.sourceAttributeId = absAttr.id
invalidModifier.operator = Operator.postPercent
invalidModifier.targetAttributeId = tgtAttr.id
invalidModifier.location = Location.self_
invalidModifier.filterType = None
invalidModifier.filterValue = None
validModifier = Modifier()
validModifier.state = State.offline
validModifier.context = Context.local
validModifier.sourceAttributeId = srcAttr.id
validModifier.operator = Operator.postMul
validModifier.targetAttributeId = tgtAttr.id
validModifier.location = Location.self_
validModifier.filterType = None
validModifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (invalidModifier, validModifier)
holder = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 1.5, tgtAttr.id: 100}))
self.fit.items.add(holder)
# Invalid source value shouldn't screw whole calculation process
self.assertNotAlmostEqual(holder.attributes[tgtAttr.id], 100)
self.assertEqual(len(self.log), 1)
logRecord = self.log[0]
self.assertEqual(logRecord.name, 'eos_test.attributeCalculator')
self.assertEqual(logRecord.levelno, Logger.WARNING)
self.assertEqual(logRecord.msg, 'unable to find base value for attribute 2 on item 1')
self.fit.items.remove(holder)
self.assertBuffersEmpty(self.fit)
示例2: testCombination
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testCombination(self):
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
invalidModifier = Modifier()
invalidModifier.state = State.offline
invalidModifier.context = Context.local
invalidModifier.sourceAttributeId = srcAttr.id
invalidModifier.operator = 1008
invalidModifier.targetAttributeId = tgtAttr.id
invalidModifier.location = Location.self_
invalidModifier.filterType = None
invalidModifier.filterValue = None
validModifier = Modifier()
validModifier.state = State.offline
validModifier.context = Context.local
validModifier.sourceAttributeId = srcAttr.id
validModifier.operator = Operator.postMul
validModifier.targetAttributeId = tgtAttr.id
validModifier.location = Location.self_
validModifier.filterType = None
validModifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (invalidModifier, validModifier)
holder = IndependentItem(
self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 1.5, tgtAttr.id: 100})
)
self.fit.items.add(holder)
# Make sure presence of invalid operator doesn't prevent
# from calculating value based on valid modifiers
self.assertNotAlmostEqual(holder.attributes[tgtAttr.id], 100)
self.fit.items.remove(holder)
self.assertEqual(len(self.log), 1)
self.assertBuffersEmpty(self.fit)
示例3: setUp
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def setUp(self):
AttrCalcTestCase.setUp(self)
self.tgtAttr = self.ch.attribute(attributeId=1, stackable=1)
srcAttr1 = self.ch.attribute(attributeId=2)
srcAttr2 = self.ch.attribute(attributeId=3)
srcAttr3 = self.ch.attribute(attributeId=4)
srcAttr4 = self.ch.attribute(attributeId=5)
modifierOff = Modifier()
modifierOff.state = State.offline
modifierOff.context = Context.local
modifierOff.sourceAttributeId = srcAttr1.id
modifierOff.operator = Operator.postMul
modifierOff.targetAttributeId = self.tgtAttr.id
modifierOff.location = Location.self_
modifierOff.filterType = None
modifierOff.filterValue = None
modifierOn = Modifier()
modifierOn.state = State.online
modifierOn.context = Context.local
modifierOn.sourceAttributeId = srcAttr2.id
modifierOn.operator = Operator.postMul
modifierOn.targetAttributeId = self.tgtAttr.id
modifierOn.location = Location.self_
modifierOn.filterType = None
modifierOn.filterValue = None
modifierAct = Modifier()
modifierAct.state = State.active
modifierAct.context = Context.local
modifierAct.sourceAttributeId = srcAttr3.id
modifierAct.operator = Operator.postMul
modifierAct.targetAttributeId = self.tgtAttr.id
modifierAct.location = Location.self_
modifierAct.filterType = None
modifierAct.filterValue = None
modifierOver = Modifier()
modifierOver.state = State.overload
modifierOver.context = Context.local
modifierOver.sourceAttributeId = srcAttr4.id
modifierOver.operator = Operator.postMul
modifierOver.targetAttributeId = self.tgtAttr.id
modifierOver.location = Location.self_
modifierOver.filterType = None
modifierOver.filterValue = None
# Overload category will make sure that holder can enter all states
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.overload)
effect.modifiers = (modifierOff, modifierOn, modifierAct, modifierOver)
self.holder = IndependentItem(
self.ch.type_(
typeId=1,
effects=(effect,),
attributes={
self.tgtAttr.id: 100,
srcAttr1.id: 1.1,
srcAttr2.id: 1.3,
srcAttr3.id: 1.5,
srcAttr4.id: 1.7,
},
)
)
示例4: testCalculation
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testCalculation(self):
attr1 = self.ch.attribute(attributeId=1)
attr2 = self.ch.attribute(attributeId=2)
attr3 = self.ch.attribute(attributeId=3)
attr4 = self.ch.attribute(attributeId=4)
modifier1 = Modifier()
modifier1.state = State.offline
modifier1.context = Context.local
modifier1.sourceAttributeId = attr1.id
modifier1.operator = Operator.postMul
modifier1.targetAttributeId = attr2.id
modifier1.location = Location.self_
modifier1.filterType = None
modifier1.filterValue = None
effect1 = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect1.modifiers = (modifier1,)
modifier2 = Modifier()
modifier2.state = State.offline
modifier2.context = Context.local
modifier2.sourceAttributeId = attr2.id
modifier2.operator = Operator.postPercent
modifier2.targetAttributeId = attr3.id
modifier2.location = Location.ship
modifier2.filterType = None
modifier2.filterValue = None
effect2 = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
effect2.modifiers = (modifier2,)
holder1 = CharacterItem(self.ch.type_(typeId=1, effects=(effect1, effect2), attributes={attr1.id: 5, attr2.id: 20}))
modifier3 = Modifier()
modifier3.state = State.offline
modifier3.context = Context.local
modifier3.sourceAttributeId = attr3.id
modifier3.operator = Operator.postPercent
modifier3.targetAttributeId = attr4.id
modifier3.location = Location.ship
modifier3.filterType = FilterType.all_
modifier3.filterValue = None
effect3 = self.ch.effect(effectId=3, categoryId=EffectCategory.passive)
effect3.modifiers = (modifier3,)
holder2 = IndependentItem(self.ch.type_(typeId=2, effects=(effect3,), attributes={attr3.id: 150}))
holder3 = ShipItem(self.ch.type_(typeId=3, attributes={attr4.id: 12.5}))
self.fit.items.add(holder1)
self.fit.ship = holder2
self.fit.items.add(holder3)
# If everything is processed properly, holder1 will multiply attr2 by attr1
# on self, resulting in 20 * 5 = 100, then apply it as percentage modifier
# on ship's (holder2) attr3, resulting in 150 + 100% = 300, then it is applied
# to all entities assigned to ship, including holder3, to theirs attr4 as
# percentage modifier again - so final result is 12.5 + 300% = 50
self.assertAlmostEqual(holder3.attributes[attr4.id], 50)
self.fit.items.remove(holder1)
self.fit.ship = None
self.fit.items.remove(holder3)
self.assertEqual(len(self.log), 0)
self.assertLinkBuffersEmpty(self.fit)
示例5: testError
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testError(self):
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = srcAttr.id
modifier.operator = Operator.postPercent
modifier.targetAttributeId = tgtAttr.id
modifier.location = Location.area
modifier.filterType = FilterType.all_
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
influenceSource = IndependentItem(self.ch.type_(typeId=56, effects=(effect,), attributes={srcAttr.id: 20}))
# This location just isn't used in EVE and unsupported by Eos by design
self.fit.items.add(influenceSource)
self.assertEqual(len(self.log), 1)
logRecord = self.log[0]
self.assertEqual(logRecord.name, "eos_test.attributeCalculator")
self.assertEqual(logRecord.levelno, Logger.WARNING)
self.assertEqual(
logRecord.msg,
"malformed modifier on item 56: unsupported target location {} for filtered modification".format(
Location.area
),
)
self.fit.items.remove(influenceSource)
self.assertLinkBuffersEmpty(self.fit)
示例6: testLogOther
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testLogOther(self):
# Check how unknown operator value influences
# attribute calculator
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
invalidModifier = Modifier()
invalidModifier.state = State.offline
invalidModifier.context = Context.local
invalidModifier.sourceAttributeId = srcAttr.id
invalidModifier.operator = 1008
invalidModifier.targetAttributeId = tgtAttr.id
invalidModifier.location = Location.self_
invalidModifier.filterType = None
invalidModifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (invalidModifier,)
holder = IndependentItem(
self.ch.type_(typeId=83, effects=(effect,), attributes={srcAttr.id: 1.2, tgtAttr.id: 100})
)
self.fit.items.add(holder)
self.assertAlmostEqual(holder.attributes[tgtAttr.id], 100)
self.assertEqual(len(self.log), 1)
logRecord = self.log[0]
self.assertEqual(logRecord.name, "eos_test.attributeCalculator")
self.assertEqual(logRecord.levelno, Logger.WARNING)
self.assertEqual(logRecord.msg, "malformed modifier on item 83: unknown operator 1008")
self.fit.items.remove(holder)
self.assertBuffersEmpty(self.fit)
示例7: testError
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testError(self):
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = srcAttr.id
modifier.operator = Operator.postPercent
modifier.targetAttributeId = tgtAttr.id
modifier.location = Location.space
modifier.filterType = None
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
influenceSource = IndependentItem(self.ch.type_(typeId=34, effects=(effect,), attributes={srcAttr.id: 20}))
# Space location was introduced in Eos as holder to contain in-space
# items like missiles or drones, but it can't be targeted directly
self.fit.items.add(influenceSource)
self.assertEqual(len(self.log), 1)
logRecord = self.log[0]
self.assertEqual(logRecord.name, 'eos_test.attributeCalculator')
self.assertEqual(logRecord.levelno, Logger.WARNING)
self.assertEqual(logRecord.msg, 'malformed modifier on item 34: unsupported target location {} for direct modification'.format(Location.space))
self.fit.items.remove(influenceSource)
self.assertBuffersEmpty(self.fit)
示例8: testCapUpdate
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testCapUpdate(self):
# If cap updates, capped attributes should
# be updated too
holder = ShipItem(self.ch.type_(typeId=1, effects=(self.effect,), attributes={self.cappedAttr.id: 3, self.sourceAttr.id: 6,
self.cappingAttr.id: 2}))
self.fit.items.add(holder)
# Check attribute vs original cap
self.assertAlmostEqual(holder.attributes[self.cappedAttr.id], 2)
# Add something which changes capping attribute
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = self.sourceAttr.id
modifier.operator = Operator.postMul
modifier.targetAttributeId = self.cappingAttr.id
modifier.location = Location.ship
modifier.filterType = FilterType.all_
modifier.filterValue = None
effect = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
capUpdater = IndependentItem(self.ch.type_(typeId=2, effects=(effect,), attributes={self.sourceAttr.id: 3.5}))
self.fit.items.add(capUpdater)
# As capping attribute is updated, capped attribute must be updated too
self.assertAlmostEqual(holder.attributes[self.cappedAttr.id], 7)
self.fit.items.remove(holder)
self.fit.items.remove(capUpdater)
self.assertEqual(len(self.log), 0)
self.assertLinkBuffersEmpty(self.fit)
示例9: setUp
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def setUp(self):
AttrCalcTestCase.setUp(self)
self.tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = srcAttr.id
modifier.operator = Operator.postPercent
modifier.targetAttributeId = self.tgtAttr.id
modifier.location = Location.ship
modifier.filterType = FilterType.all_
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
self.influenceSource1 = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 20}))
self.influenceSource2 = IndependentItem(self.ch.type_(typeId=2, effects=(effect,), attributes={srcAttr.id: 50}))
self.influenceSource3 = IndependentItem(self.ch.type_(typeId=3, effects=(effect,), attributes={srcAttr.id: -90}))
self.influenceSource4 = IndependentItem(self.ch.type_(typeId=4, effects=(effect,), attributes={srcAttr.id: -25}))
self.influenceSource5 = IndependentItem(self.ch.type_(typeId=5, effects=(effect,), attributes={srcAttr.id: 400}))
self.influenceTarget = ShipItem(self.ch.type_(typeId=6, attributes={self.tgtAttr.id: 100}))
self.fit.items.add(self.influenceSource1)
self.fit.items.add(self.influenceSource2)
self.fit.items.add(self.influenceSource3)
self.fit.items.add(self.influenceSource4)
self.fit.items.add(self.influenceSource5)
self.fit.items.add(self.influenceTarget)
示例10: testShip
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testShip(self):
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = srcAttr.id
modifier.operator = Operator.postPercent
modifier.targetAttributeId = tgtAttr.id
modifier.location = Location.ship
modifier.filterType = None
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
influenceSource = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 20}))
self.fit.items.add(influenceSource)
item = self.ch.type_(typeId=None, attributes={tgtAttr.id: 100})
influenceTarget1 = IndependentItem(item)
self.fit.ship = influenceTarget1
self.assertNotAlmostEqual(influenceTarget1.attributes[tgtAttr.id], 100)
self.fit.ship = None
influenceTarget2 = IndependentItem(item)
self.fit.ship = influenceTarget2
self.assertNotAlmostEqual(influenceTarget2.attributes[tgtAttr.id], 100)
self.fit.items.remove(influenceSource)
self.fit.ship = None
self.assertEqual(len(self.log), 0)
self.assertBuffersEmpty(self.fit)
示例11: testError
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testError(self):
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = srcAttr.id
modifier.operator = Operator.postPercent
modifier.targetAttributeId = tgtAttr.id
modifier.location = Location.other
modifier.filterType = FilterType.all_
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
influenceSource = IndependentItem(self.ch.type_(typeId=90, effects=(effect,), attributes={srcAttr.id: 20}))
# Charge's container or module's charge can't be 'owner'
# of other holders, thus such modification type is unsupported
self.fit.items.add(influenceSource)
self.assertEqual(len(self.log), 1)
logRecord = self.log[0]
self.assertEqual(logRecord.name, 'eos_test.attributeCalculator')
self.assertEqual(logRecord.levelno, Logger.WARNING)
self.assertEqual(logRecord.msg, 'malformed modifier on item 90: unsupported target location {} for filtered modification'.format(Location.other))
self.fit.items.remove(influenceSource)
self.assertBuffersEmpty(self.fit)
示例12: testTargetAttributes
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testTargetAttributes(self):
tgtAttr1 = self.ch.attribute(attributeId=1)
tgtAttr2 = self.ch.attribute(attributeId=2)
tgtAttr3 = self.ch.attribute(attributeId=3)
srcAttr = self.ch.attribute(attributeId=4)
modifier1 = Modifier()
modifier1.state = State.offline
modifier1.context = Context.local
modifier1.sourceAttributeId = srcAttr.id
modifier1.operator = Operator.postPercent
modifier1.targetAttributeId = tgtAttr1.id
modifier1.location = Location.self_
modifier1.filterType = None
modifier1.filterValue = None
modifier2 = Modifier()
modifier2.state = State.offline
modifier2.context = Context.local
modifier2.sourceAttributeId = srcAttr.id
modifier2.operator = Operator.postPercent
modifier2.targetAttributeId = tgtAttr2.id
modifier2.location = Location.self_
modifier2.filterType = None
modifier2.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier1, modifier2)
holder = IndependentItem(
self.ch.type_(
typeId=1,
effects=(effect,),
attributes={tgtAttr1.id: 50, tgtAttr2.id: 80, tgtAttr3.id: 100, srcAttr.id: 20},
)
)
self.fit.items.add(holder)
# First attribute should be modified by modifier1
self.assertAlmostEqual(holder.attributes[tgtAttr1.id], 60)
# Second should be modified by modifier2
self.assertAlmostEqual(holder.attributes[tgtAttr2.id], 96)
# Third should stay unmodified
self.assertAlmostEqual(holder.attributes[tgtAttr3.id], 100)
self.fit.items.remove(holder)
self.assertEqual(len(self.log), 0)
self.assertBuffersEmpty(self.fit)
示例13: testAttribute
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testAttribute(self):
attr1 = self.ch.attribute(attributeId=1)
attr2 = self.ch.attribute(attributeId=2)
attr3 = self.ch.attribute(attributeId=3)
modifier1 = Modifier()
modifier1.state = State.offline
modifier1.context = Context.local
modifier1.sourceAttributeId = attr1.id
modifier1.operator = Operator.postMul
modifier1.targetAttributeId = attr2.id
modifier1.location = Location.ship
modifier1.filterType = None
modifier1.filterValue = None
effect1 = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect1.modifiers = (modifier1,)
holder1 = CharacterItem(self.ch.type_(typeId=1, effects=(effect1,), attributes={attr1.id: 5}))
modifier2 = Modifier()
modifier2.state = State.offline
modifier2.context = Context.local
modifier2.sourceAttributeId = attr2.id
modifier2.operator = Operator.postPercent
modifier2.targetAttributeId = attr3.id
modifier2.location = Location.ship
modifier2.filterType = FilterType.all_
modifier2.filterValue = None
effect2 = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
effect2.modifiers = (modifier2,)
holder2 = IndependentItem(self.ch.type_(typeId=2, effects=(effect2,), attributes={attr2.id: 7.5}))
holder3 = ShipItem(self.ch.type_(typeId=3, attributes={attr3.id: 0.5}))
self.fit.items.add(holder1)
self.fit.ship = holder2
self.fit.items.add(holder3)
self.assertAlmostEqual(holder3.attributes[attr3.id], 0.6875)
holder1.attributes[attr1.id] = 4
# Manually changed attribute must trigger damaging whole chain
# of attributes, effectively allowing us to recalculate its new value
self.assertAlmostEqual(holder3.attributes[attr3.id], 0.65)
self.fit.items.remove(holder1)
self.fit.ship = None
self.fit.items.remove(holder3)
self.assertEqual(len(self.log), 0)
self.assertBuffersEmpty(self.fit)
示例14: testAttribute
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testAttribute(self):
attr1 = self.ch.attribute(attributeId=1)
attr2 = self.ch.attribute(attributeId=2)
attr3 = self.ch.attribute(attributeId=3)
modifier1 = Modifier()
modifier1.state = State.offline
modifier1.context = Context.local
modifier1.sourceAttributeId = attr1.id
modifier1.operator = Operator.postMul
modifier1.targetAttributeId = attr2.id
modifier1.location = Location.ship
modifier1.filterType = None
modifier1.filterValue = None
effect1 = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect1.modifiers = (modifier1,)
holder1 = CharacterItem(self.ch.type_(typeId=1, effects=(effect1,), attributes={attr1.id: 5}))
modifier2 = Modifier()
modifier2.state = State.offline
modifier2.context = Context.local
modifier2.sourceAttributeId = attr2.id
modifier2.operator = Operator.postPercent
modifier2.targetAttributeId = attr3.id
modifier2.location = Location.ship
modifier2.filterType = FilterType.all_
modifier2.filterValue = None
effect2 = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
effect2.modifiers = (modifier2,)
holder2 = IndependentItem(self.ch.type_(typeId=2, effects=(effect2,), attributes={attr2.id: 7.5}))
holder3 = ShipItem(self.ch.type_(typeId=3, attributes={attr3.id: 0.5}))
self.fit.ship = holder2
self.fit.items.add(holder3)
self.assertAlmostEqual(holder3.attributes[attr3.id], 0.5375)
self.fit.items.add(holder1)
# Added holder must clean all already calculated attributes
# which are now affected by it, to allow recalculation
self.assertAlmostEqual(holder3.attributes[attr3.id], 0.6875)
self.fit.items.remove(holder1)
self.fit.ship = None
self.fit.items.remove(holder3)
self.assertEqual(len(self.log), 0)
self.assertLinkBuffersEmpty(self.fit)
示例15: testLogUnorderableCombination
# 需要导入模块: from eos.data.cache.object.modifier import Modifier [as 别名]
# 或者: from eos.data.cache.object.modifier.Modifier import operator [as 别名]
def testLogUnorderableCombination(self):
# Check how non-orderable operator value influences
# attribute calculator. Previously, bug in calculation
# method made it to crash
tgtAttr = self.ch.attribute(attributeId=1)
srcAttr = self.ch.attribute(attributeId=2)
invalidModifier = Modifier()
invalidModifier.state = State.offline
invalidModifier.context = Context.local
invalidModifier.sourceAttributeId = srcAttr.id
invalidModifier.operator = None
invalidModifier.targetAttributeId = tgtAttr.id
invalidModifier.location = Location.self_
invalidModifier.filterType = None
invalidModifier.filterValue = None
validModifier = Modifier()
validModifier.state = State.offline
validModifier.context = Context.local
validModifier.sourceAttributeId = srcAttr.id
validModifier.operator = Operator.postMul
validModifier.targetAttributeId = tgtAttr.id
validModifier.location = Location.self_
validModifier.filterType = None
validModifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (invalidModifier, validModifier)
holder = IndependentItem(self.ch.type_(typeId=83, effects=(effect,), attributes={srcAttr.id: 1.2, tgtAttr.id: 100}))
self.fit.items.add(holder)
self.assertAlmostEqual(holder.attributes[tgtAttr.id], 120)
self.assertEqual(len(self.log), 1)
logRecord = self.log[0]
self.assertEqual(logRecord.name, 'eos_test.attributeCalculator')
self.assertEqual(logRecord.levelno, Logger.WARNING)
self.assertEqual(logRecord.msg, 'malformed modifier on item 83: unknown operator None')
self.fit.items.remove(holder)
self.assertLinkBuffersEmpty(self.fit)