Exemplo n.º 1
0
 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.postDiv
     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.fit = Fit()
     self.influenceSource1 = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 1.2}))
     self.influenceSource2 = IndependentItem(self.ch.type_(typeId=2, effects=(effect,), attributes={srcAttr.id: 1.5}))
     self.influenceSource3 = IndependentItem(self.ch.type_(typeId=3, effects=(effect,), attributes={srcAttr.id: 0.1}))
     self.influenceSource4 = IndependentItem(self.ch.type_(typeId=4, effects=(effect,), attributes={srcAttr.id: 0.75}))
     self.influenceSource5 = IndependentItem(self.ch.type_(typeId=5, effects=(effect,), attributes={srcAttr.id: 5}))
     self.influenceTarget = ShipItem(self.ch.type_(typeId=6, attributes={self.tgtAttr.id: 100}))
     self.fit.items.append(self.influenceSource1)
     self.fit.items.append(self.influenceSource2)
     self.fit.items.append(self.influenceSource3)
     self.fit.items.append(self.influenceSource4)
     self.fit.items.append(self.influenceSource5)
     self.fit.items.append(self.influenceTarget)
Exemplo n.º 2
0
 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 = None
     modifier.filterValue = None
     effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
     effect._modifiers = (modifier,)
     fit = Fit()
     influenceSource = IndependentItem(self.ch.type_(typeId=772, effects=(effect,), attributes={srcAttr.id: 20}))
     # This location just isn't used in EVE and unsupported by Eos by design
     fit.items.append(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 772: unsupported target location {} for direct modification".format(Location.area))
     fit.items.remove(influenceSource)
     self.assertBuffersEmpty(fit)
Exemplo n.º 3
0
 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,)
     fit = Fit()
     influenceSource = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 20}))
     fit.items.append(influenceSource)
     item = self.ch.type_(typeId=None, attributes={tgtAttr.id: 100})
     influenceTarget1 = IndependentItem(item)
     fit.ship = influenceTarget1
     self.assertNotAlmostEqual(influenceTarget1.attributes[tgtAttr.id], 100)
     fit.ship = None
     influenceTarget2 = IndependentItem(item)
     fit.ship = influenceTarget2
     self.assertNotAlmostEqual(influenceTarget2.attributes[tgtAttr.id], 100)
     fit.items.remove(influenceSource)
     fit.ship = None
     self.assertBuffersEmpty(fit)
Exemplo n.º 4
0
 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.append(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.append(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.assertBuffersEmpty(self.fit)
Exemplo n.º 5
0
 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,)
     fit = Fit()
     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
     fit.items.append(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))
     fit.items.remove(influenceSource)
     self.assertBuffersEmpty(fit)
Exemplo n.º 6
0
 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,)
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=83, effects=(effect,), attributes={srcAttr.id: 1.2, tgtAttr.id: 100}))
     fit.items.append(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")
     fit.items.remove(holder)
     self.assertBuffersEmpty(fit)
Exemplo n.º 7
0
 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,)
     fit = Fit()
     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
     fit.items.append(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))
     fit.items.remove(influenceSource)
     self.assertBuffersEmpty(fit)
Exemplo n.º 8
0
 def setUp(self):
     AttrCalcTestCase.setUp(self)
     self.tgtAttr = self.ch.attribute(attributeId=1)
     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.self_
     modifier.filterType = None
     modifier.filterValue = None
     self.effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
     self.effect._modifiers = (modifier,)
     self.fit = Fit()
Exemplo n.º 9
0
 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.append(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.assertBuffersEmpty(self.fit)
Exemplo n.º 10
0
 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.space
     modifier.filterType = FilterType.all_
     modifier.filterValue = None
     effect = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
     effect._modifiers = (modifier,)
     self.fit = Fit()
     self.influenceSource = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 20}))
     self.fit.items.append(self.influenceSource)
Exemplo n.º 11
0
 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,)
     self.fit = Fit()
Exemplo n.º 12
0
 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,)
     self.fit = Fit()
     # 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.append(self.influenceSource)
Exemplo n.º 13
0
 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,)
     self.fit = Fit()
     # 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.append(self.influenceSource)
Exemplo n.º 14
0
 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.append(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.assertBuffersEmpty(self.fit)
Exemplo n.º 15
0
 def testAllIn(self):
     tgtAttr = self.ch.attribute(attributeId=1, stackable=0)
     srcAttr = self.ch.attribute(attributeId=2)
     fit = Fit()
     modifierPreAss = Modifier()
     modifierPreAss.state = State.offline
     modifierPreAss.context = Context.local
     modifierPreAss.sourceAttributeId = srcAttr.id
     modifierPreAss.operator = Operator.preAssignment
     modifierPreAss.targetAttributeId = tgtAttr.id
     modifierPreAss.location = Location.ship
     modifierPreAss.filterType = FilterType.all_
     modifierPreAss.filterValue = None
     effectPreAss = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
     effectPreAss._modifiers = (modifierPreAss,)
     valuePreAss = 5
     influenceSourcePreAss = IndependentItem(self.ch.type_(typeId=1, effects=(effectPreAss,), attributes={srcAttr.id: valuePreAss}))
     fit.items.append(influenceSourcePreAss)
     modifierPreMul = Modifier()
     modifierPreMul.state = State.offline
     modifierPreMul.context = Context.local
     modifierPreMul.sourceAttributeId = srcAttr.id
     modifierPreMul.operator = Operator.preMul
     modifierPreMul.targetAttributeId = tgtAttr.id
     modifierPreMul.location = Location.ship
     modifierPreMul.filterType = FilterType.all_
     modifierPreMul.filterValue = None
     effectPreMul = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
     effectPreMul._modifiers = (modifierPreMul,)
     valuePreMul = 50
     influenceSourcePreMul = IndependentItem(self.ch.type_(typeId=2, effects=(effectPreMul,), attributes={srcAttr.id: valuePreMul}))
     fit.items.append(influenceSourcePreMul)
     modifierPreDiv = Modifier()
     modifierPreDiv.state = State.offline
     modifierPreDiv.context = Context.local
     modifierPreDiv.sourceAttributeId = srcAttr.id
     modifierPreDiv.operator = Operator.preDiv
     modifierPreDiv.targetAttributeId = tgtAttr.id
     modifierPreDiv.location = Location.ship
     modifierPreDiv.filterType = FilterType.all_
     modifierPreDiv.filterValue = None
     effectPreDiv = self.ch.effect(effectId=3, categoryId=EffectCategory.passive)
     effectPreDiv._modifiers = (modifierPreDiv,)
     valuePreDiv = 0.5
     influenceSourcePreDiv = IndependentItem(self.ch.type_(typeId=3, effects=(effectPreDiv,), attributes={srcAttr.id: valuePreDiv}))
     fit.items.append(influenceSourcePreDiv)
     modifierModAdd = Modifier()
     modifierModAdd.state = State.offline
     modifierModAdd.context = Context.local
     modifierModAdd.sourceAttributeId = srcAttr.id
     modifierModAdd.operator = Operator.modAdd
     modifierModAdd.targetAttributeId = tgtAttr.id
     modifierModAdd.location = Location.ship
     modifierModAdd.filterType = FilterType.all_
     modifierModAdd.filterValue = None
     effectModAdd = self.ch.effect(effectId=4, categoryId=EffectCategory.passive)
     effectModAdd._modifiers = (modifierModAdd,)
     valueModAdd = 10
     influenceSourceModAdd = IndependentItem(self.ch.type_(typeId=4, effects=(effectModAdd,), attributes={srcAttr.id: valueModAdd}))
     fit.items.append(influenceSourceModAdd)
     modifierModSub = Modifier()
     modifierModSub.state = State.offline
     modifierModSub.context = Context.local
     modifierModSub.sourceAttributeId = srcAttr.id
     modifierModSub.operator = Operator.modSub
     modifierModSub.targetAttributeId = tgtAttr.id
     modifierModSub.location = Location.ship
     modifierModSub.filterType = FilterType.all_
     modifierModSub.filterValue = None
     effectModSub = self.ch.effect(effectId=5, categoryId=EffectCategory.passive)
     effectModSub._modifiers = (modifierModSub,)
     valueModSub = 63
     influenceSourceModSub = IndependentItem(self.ch.type_(typeId=5, effects=(effectModSub,), attributes={srcAttr.id: valueModSub}))
     fit.items.append(influenceSourceModSub)
     modifierPostMul = Modifier()
     modifierPostMul.state = State.offline
     modifierPostMul.context = Context.local
     modifierPostMul.sourceAttributeId = srcAttr.id
     modifierPostMul.operator = Operator.postMul
     modifierPostMul.targetAttributeId = tgtAttr.id
     modifierPostMul.location = Location.ship
     modifierPostMul.filterType = FilterType.all_
     modifierPostMul.filterValue = None
     effectPostMul = self.ch.effect(effectId=6, categoryId=EffectCategory.passive)
     effectPostMul._modifiers = (modifierPostMul,)
     valuePostMul = 1.35
     influenceSourcePostMul = IndependentItem(self.ch.type_(typeId=6, effects=(effectPostMul,), attributes={srcAttr.id: valuePostMul}))
     fit.items.append(influenceSourcePostMul)
     modifierPostDiv = Modifier()
     modifierPostDiv.state = State.offline
     modifierPostDiv.context = Context.local
     modifierPostDiv.sourceAttributeId = srcAttr.id
     modifierPostDiv.operator = Operator.postDiv
     modifierPostDiv.targetAttributeId = tgtAttr.id
     modifierPostDiv.location = Location.ship
     modifierPostDiv.filterType = FilterType.all_
     modifierPostDiv.filterValue = None
     effectPostDiv = self.ch.effect(effectId=7, categoryId=EffectCategory.passive)
     effectPostDiv._modifiers = (modifierPostDiv,)
     valuePostDiv = 2.7
     influenceSourcePostDiv = IndependentItem(self.ch.type_(typeId=7, effects=(effectPostDiv,), attributes={srcAttr.id: valuePostDiv}))
     fit.items.append(influenceSourcePostDiv)
     modifierPostPerc = Modifier()
     modifierPostPerc.state = State.offline
     modifierPostPerc.context = Context.local
     modifierPostPerc.sourceAttributeId = srcAttr.id
     modifierPostPerc.operator = Operator.postPercent
     modifierPostPerc.targetAttributeId = tgtAttr.id
     modifierPostPerc.location = Location.ship
     modifierPostPerc.filterType = FilterType.all_
     modifierPostPerc.filterValue = None
     effectPostPerc = self.ch.effect(effectId=8, categoryId=EffectCategory.passive)
     effectPostPerc._modifiers = (modifierPostPerc,)
     valuePostPerc = 15
     influenceSourcePostPerc = IndependentItem(self.ch.type_(typeId=8, effects=(effectPostPerc,), attributes={srcAttr.id: valuePostPerc}))
     fit.items.append(influenceSourcePostPerc)
     influenceTarget = ShipItem(self.ch.type_(typeId=9, attributes={tgtAttr.id: 100}))
     fit.items.append(influenceTarget)
     # Operators shouldn't be penalized and should go in this order
     expValue = ((valuePreAss * valuePreMul / valuePreDiv) + valueModAdd - valueModSub) * valuePostMul / valuePostDiv * (1 + valuePostPerc / 100)
     self.assertAlmostEqual(influenceTarget.attributes[tgtAttr.id], expValue)
     fit.items.remove(influenceSourcePreAss)
     fit.items.remove(influenceSourcePreMul)
     fit.items.remove(influenceSourcePreDiv)
     fit.items.remove(influenceSourceModAdd)
     fit.items.remove(influenceSourceModSub)
     fit.items.remove(influenceSourcePostMul)
     fit.items.remove(influenceSourcePostDiv)
     fit.items.remove(influenceSourcePostPerc)
     fit.items.remove(influenceTarget)
     self.assertBuffersEmpty(fit)
Exemplo n.º 16
0
 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}))
     fit = Fit()
     fit.items.append(holder1)
     fit.ship = holder2
     fit.items.append(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)
     fit.items.remove(holder1)
     fit.ship = None
     fit.items.remove(holder3)
     self.assertBuffersEmpty(fit)
Exemplo n.º 17
0
 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}))
     fit = Fit()
     fit.items.append(holder1)
     fit.ship = holder2
     fit.items.append(holder3)
     self.assertAlmostEqual(holder3.attributes[attr3.id], 0.6875)
     fit.items.remove(holder1)
     # When holder1 is removed, attr2 of holder2 and attr3 of holder3
     # must be cleaned to allow recalculation of attr3 based on new data
     self.assertAlmostEqual(holder3.attributes[attr3.id], 0.5375)
     fit.ship = None
     fit.items.remove(holder3)
     self.assertBuffersEmpty(fit)
Exemplo n.º 18
0
 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)
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 1.5, tgtAttr.id: 100}))
     fit.items.append(holder)
     # Make sure presence of invalid operator doesn't prevent
     # from calculating value based on valid modifiers
     self.assertNotAlmostEqual(holder.attributes[tgtAttr.id], 100)
     fit.items.remove(holder)
     self.assertBuffersEmpty(fit)
Exemplo n.º 19
0
 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)
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={srcAttr.id: 1.5, tgtAttr.id: 100}))
     fit.items.append(holder)
     # Invalid source value shouldn't screw whole calculation process
     self.assertNotAlmostEqual(holder.attributes[tgtAttr.id], 100)
     fit.items.remove(holder)
     self.assertBuffersEmpty(fit)
Exemplo n.º 20
0
 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.fit = Fit()
     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}))
Exemplo n.º 21
0
 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)
     fit = Fit()
     holder = IndependentItem(self.ch.type_(typeId=1, effects=(effect,), attributes={tgtAttr1.id: 50, tgtAttr2.id: 80,
                                                                                     tgtAttr3.id: 100, srcAttr.id: 20}))
     fit.items.append(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)
     fit.items.remove(holder)
     self.assertBuffersEmpty(fit)
Exemplo n.º 22
0
 def testForcedValue(self):
     tgtAttr = self.ch.attribute(attributeId=1)
     srcAttr = self.ch.attribute(attributeId=2)
     fit = Fit()
     modifierPreAss = Modifier()
     modifierPreAss.state = State.offline
     modifierPreAss.context = Context.local
     modifierPreAss.sourceAttributeId = srcAttr.id
     modifierPreAss.operator = Operator.preAssignment
     modifierPreAss.targetAttributeId = tgtAttr.id
     modifierPreAss.location = Location.ship
     modifierPreAss.filterType = FilterType.all_
     modifierPreAss.filterValue = None
     effectPreAss = self.ch.effect(effectId=1, categoryId=EffectCategory.passive)
     effectPreAss._modifiers = (modifierPreAss,)
     influenceSourcePreAss = IndependentItem(self.ch.type_(typeId=1, effects=(effectPreAss,), attributes={srcAttr.id: 5}))
     fit.items.append(influenceSourcePreAss)
     modifierPreMul = Modifier()
     modifierPreMul.state = State.offline
     modifierPreMul.context = Context.local
     modifierPreMul.sourceAttributeId = srcAttr.id
     modifierPreMul.operator = Operator.preMul
     modifierPreMul.targetAttributeId = tgtAttr.id
     modifierPreMul.location = Location.ship
     modifierPreMul.filterType = FilterType.all_
     modifierPreMul.filterValue = None
     effectPreMul = self.ch.effect(effectId=2, categoryId=EffectCategory.passive)
     effectPreMul._modifiers = (modifierPreMul,)
     influenceSourcePreMul = IndependentItem(self.ch.type_(typeId=2, effects=(effectPreMul,), attributes={srcAttr.id: 50}))
     fit.items.append(influenceSourcePreMul)
     modifierPreDiv = Modifier()
     modifierPreDiv.state = State.offline
     modifierPreDiv.context = Context.local
     modifierPreDiv.sourceAttributeId = srcAttr.id
     modifierPreDiv.operator = Operator.preDiv
     modifierPreDiv.targetAttributeId = tgtAttr.id
     modifierPreDiv.location = Location.ship
     modifierPreDiv.filterType = FilterType.all_
     modifierPreDiv.filterValue = None
     effectPreDiv = self.ch.effect(effectId=3, categoryId=EffectCategory.passive)
     effectPreDiv._modifiers = (modifierPreDiv,)
     influenceSourcePreDiv = IndependentItem(self.ch.type_(typeId=3, effects=(effectPreDiv,), attributes={srcAttr.id: 0.5}))
     fit.items.append(influenceSourcePreDiv)
     modifierModAdd = Modifier()
     modifierModAdd.state = State.offline
     modifierModAdd.context = Context.local
     modifierModAdd.sourceAttributeId = srcAttr.id
     modifierModAdd.operator = Operator.modAdd
     modifierModAdd.targetAttributeId = tgtAttr.id
     modifierModAdd.location = Location.ship
     modifierModAdd.filterType = FilterType.all_
     modifierModAdd.filterValue = None
     effectModAdd = self.ch.effect(effectId=4, categoryId=EffectCategory.passive)
     effectModAdd._modifiers = (modifierModAdd,)
     influenceSourceModAdd = IndependentItem(self.ch.type_(typeId=4, effects=(effectModAdd,), attributes={srcAttr.id: 10}))
     fit.items.append(influenceSourceModAdd)
     modifierModSub = Modifier()
     modifierModSub.state = State.offline
     modifierModSub.context = Context.local
     modifierModSub.sourceAttributeId = srcAttr.id
     modifierModSub.operator = Operator.modSub
     modifierModSub.targetAttributeId = tgtAttr.id
     modifierModSub.location = Location.ship
     modifierModSub.filterType = FilterType.all_
     modifierModSub.filterValue = None
     effectModSub = self.ch.effect(effectId=5, categoryId=EffectCategory.passive)
     effectModSub._modifiers = (modifierModSub,)
     influenceSourceModSub = IndependentItem(self.ch.type_(typeId=5, effects=(effectModSub,), attributes={srcAttr.id: 63}))
     fit.items.append(influenceSourceModSub)
     modifierPostMul = Modifier()
     modifierPostMul.state = State.offline
     modifierPostMul.context = Context.local
     modifierPostMul.sourceAttributeId = srcAttr.id
     modifierPostMul.operator = Operator.postMul
     modifierPostMul.targetAttributeId = tgtAttr.id
     modifierPostMul.location = Location.ship
     modifierPostMul.filterType = FilterType.all_
     modifierPostMul.filterValue = None
     effectPostMul = self.ch.effect(effectId=6, categoryId=EffectCategory.passive)
     effectPostMul._modifiers = (modifierPostMul,)
     influenceSourcePostMul = IndependentItem(self.ch.type_(typeId=6, effects=(effectPostMul,), attributes={srcAttr.id: 1.35}))
     fit.items.append(influenceSourcePostMul)
     modifierPostDiv = Modifier()
     modifierPostDiv.state = State.offline
     modifierPostDiv.context = Context.local
     modifierPostDiv.sourceAttributeId = srcAttr.id
     modifierPostDiv.operator = Operator.postDiv
     modifierPostDiv.targetAttributeId = tgtAttr.id
     modifierPostDiv.location = Location.ship
     modifierPostDiv.filterType = FilterType.all_
     modifierPostDiv.filterValue = None
     effectPostDiv = self.ch.effect(effectId=7, categoryId=EffectCategory.passive)
     effectPostDiv._modifiers = (modifierPostDiv,)
     influenceSourcePostDiv = IndependentItem(self.ch.type_(typeId=7, effects=(effectPostDiv,), attributes={srcAttr.id: 2.7}))
     fit.items.append(influenceSourcePostDiv)
     modifierPostPerc = Modifier()
     modifierPostPerc.state = State.offline
     modifierPostPerc.context = Context.local
     modifierPostPerc.sourceAttributeId = srcAttr.id
     modifierPostPerc.operator = Operator.postPercent
     modifierPostPerc.targetAttributeId = tgtAttr.id
     modifierPostPerc.location = Location.ship
     modifierPostPerc.filterType = FilterType.all_
     modifierPostPerc.filterValue = None
     effectPostPerc = self.ch.effect(effectId=8, categoryId=EffectCategory.passive)
     effectPostPerc._modifiers = (modifierPostPerc,)
     influenceSourcePostPerc = IndependentItem(self.ch.type_(typeId=8, effects=(effectPostPerc,), attributes={srcAttr.id: 15}))
     fit.items.append(influenceSourcePostPerc)
     modifierPostAss = Modifier()
     modifierPostAss.state = State.offline
     modifierPostAss.context = Context.local
     modifierPostAss.sourceAttributeId = srcAttr.id
     modifierPostAss.operator = Operator.postAssignment
     modifierPostAss.targetAttributeId = tgtAttr.id
     modifierPostAss.location = Location.ship
     modifierPostAss.filterType = FilterType.all_
     modifierPostAss.filterValue = None
     effectPostAss = self.ch.effect(effectId=9, categoryId=EffectCategory.passive)
     effectPostAss._modifiers = (modifierPostAss,)
     influenceSourcePostAss = IndependentItem(self.ch.type_(typeId=9, effects=(effectPostAss,), attributes={srcAttr.id: 68}))
     fit.items.append(influenceSourcePostAss)
     influenceTarget = ShipItem(self.ch.type_(typeId=10, attributes={tgtAttr.id: 100}))
     fit.items.append(influenceTarget)
     # Post-assignment value must override all other modifications
     self.assertAlmostEqual(influenceTarget.attributes[tgtAttr.id], 68)
     fit.items.remove(influenceSourcePreAss)
     fit.items.remove(influenceSourcePreMul)
     fit.items.remove(influenceSourcePreDiv)
     fit.items.remove(influenceSourceModAdd)
     fit.items.remove(influenceSourceModSub)
     fit.items.remove(influenceSourcePostMul)
     fit.items.remove(influenceSourcePostDiv)
     fit.items.remove(influenceSourcePostPerc)
     fit.items.remove(influenceSourcePostAss)
     fit.items.remove(influenceTarget)
     self.assertBuffersEmpty(fit)
Exemplo n.º 23
0

from itertools import chain

from eos.const import State, Location, EffectBuildStatus, Context, FilterType, Operator
from eos.eve.const import Type, Group, Attribute, EffectCategory
from eos.eve.effect import Effect
from eos.fit.attributeCalculator.modifier.modifier import Modifier


# Define modifiers which apply character's missile damage
# multiplier onto missiles from its fit
charMissileDamageModifiers = []
for damageAttr in (Attribute.emDamage, Attribute.thermalDamage,
                   Attribute.kineticDamage, Attribute.explosiveDamage):
    modifier = Modifier()
    modifier.state = State.offline
    modifier.context = Context.local
    modifier.sourceAttributeId = Attribute.missileDamageMultiplier
    modifier.operator = Operator.postMul
    modifier.targetAttributeId = damageAttr
    modifier.location = Location.space
    modifier.filterType = FilterType.skill
    modifier.filterValue = Type.missileLauncherOperation
    charMissileDamageModifiers.append(modifier)
charMissileDmgEffect = Effect(categoryId=EffectCategory.passive)
charMissileDmgEffect.modifierStatus = EffectBuildStatus.override
charMissileDmgEffect._modifiers = tuple(charMissileDamageModifiers)

def customizeType(type_, ):
    """Control all customizations performed on type"""
Exemplo n.º 24
0
 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}))
     fit = Fit()
     fit.items.append(holder1)
     fit.ship = holder2
     fit.items.append(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)
     fit.items.remove(holder1)
     fit.ship = None
     fit.items.remove(holder3)
     self.assertBuffersEmpty(fit)