本文整理汇总了Python中eos.data.cache.object.modifier.Modifier类的典型用法代码示例。如果您正苦于以下问题:Python Modifier类的具体用法?Python Modifier怎么用?Python Modifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Modifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testError
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)
示例2: testLogOther
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)
示例3: testCapUpdate
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)
示例4: setUp
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)
示例5: testShip
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)
示例6: testError
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)
示例7: testError
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: setUp
def setUp(self):
AttrCalcTestCase.setUp(self)
self.tgtAttr = self.ch.attribute(attributeId=1, stackable=0)
self.srcAttr = self.ch.attribute(attributeId=2)
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = self.srcAttr.id
modifier.operator = Operator.postPercent
modifier.targetAttributeId = self.tgtAttr.id
modifier.location = Location.ship
modifier.filterType = FilterType.all_
modifier.filterValue = None
self.effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
self.effect.modifiers = (modifier,)
示例9: setUp
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.self_
modifier.filterType = FilterType.all_
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
self.influenceSource = IndependentItem(self.ch.type_(typeId=1061, effects=(effect,), attributes={srcAttr.id: 20}))
示例10: testCombination
def testCombination(self):
validModifier = Modifier()
validModifier.state = State.offline
validModifier.context = Context.local
validModifier.sourceAttributeId = self.srcAttr.id
validModifier.operator = Operator.postPercent
validModifier.targetAttributeId = self.tgtAttr.id
validModifier.location = Location.self_
validModifier.filterType = None
validModifier.filterValue = None
self.effect.modifiers = (self.invalidModifier, validModifier)
holder = IndependentItem(self.ch.type_(typeId=1, effects=(self.effect,), attributes={self.srcAttr.id: 20, self.tgtAttr.id: 100}))
self.fit.items.add(holder)
# Invalid location in modifier should prevent proper processing of other modifiers
self.assertNotAlmostEqual(holder.attributes[self.tgtAttr.id], 100)
self.fit.items.remove(holder)
self.assertEqual(len(self.log), 1)
self.assertBuffersEmpty(self.fit)
示例11: setUp
def setUp(self):
AttrCalcTestCase.setUp(self)
self.cappedAttr = self.ch.attribute(attributeId=1, maxAttributeId=2)
self.cappingAttr = self.ch.attribute(attributeId=2, defaultValue=5)
self.sourceAttr = self.ch.attribute(attributeId=3)
# Just to make sure cap is applied to final value, not
# base, make some basic modification modifier
modifier = Modifier()
modifier.state = State.offline
modifier.context = Context.local
modifier.sourceAttributeId = self.sourceAttr.id
modifier.operator = Operator.postMul
modifier.targetAttributeId = self.cappedAttr.id
modifier.location = Location.self_
modifier.filterType = None
modifier.filterValue = None
self.effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
self.effect.modifiers = (modifier,)
示例12: setUp
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.character
modifier.filterType = FilterType.all_
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
# It doesn't matter holder of which type we're using,
# the only thing which matters is its position in fit
self.influenceSource = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 20}))
self.fit.items.add(self.influenceSource)
示例13: setUp
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.other
modifier.filterType = None
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
# We added target attribute to influence source for testSelf;
# currently, eos cannot calculate attributes which are originally
# missing on item
self.influenceSource = ItemWithOther(self.ch.type_(typeId=1, effects=(effect,), attributes={self.tgtAttr.id: 100, srcAttr.id: 20}))
self.fit.items.add(self.influenceSource)
示例14: testCapModified
def testCapModified(self):
# Make sure that holder's own specified attribute
# value is taken as cap, and it's taken with all
# modifications applied onto it
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.self_
modifier.filterType = None
modifier.filterValue = None
effect = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
holder = IndependentItem(self.ch.type_(typeId=1, effects=(self.effect, effect), attributes={self.cappedAttr.id: 3, self.sourceAttr.id: 6,
self.cappingAttr.id: 0.1}))
self.fit.items.add(holder)
# Attr value is 3 * 6 = 18, but cap value is 0.1 * 6 = 0.6
self.assertAlmostEqual(holder.attributes[self.cappedAttr.id], 0.6)
self.fit.items.remove(holder)
self.assertEqual(len(self.log), 0)
self.assertLinkBuffersEmpty(self.fit)
示例15: testError
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.target
modifier.filterType = None
modifier.filterValue = None
effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
effect.modifiers = (modifier,)
influenceSource = IndependentItem(self.ch.type_(typeId=102, effects=(effect,), attributes={srcAttr.id: 20}))
# This functionality isn't implemented for now
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 102: unsupported target location {} for direct modification'.format(Location.target))
self.fit.items.remove(influenceSource)
self.assertLinkBuffersEmpty(self.fit)