コード例 #1
0
ファイル: testSplicing.py プロジェクト: oneillkza/Eos
 def testBuildSuccess(self):
     eTgtLoc = self.ch.expression(expressionId=1, operandId=24, value="Target")
     eTgtSrq = self.ch.expression(expressionId=2, operandId=29, expressionTypeId=3300)
     eTgtAttr1 = self.ch.expression(expressionId=3, operandId=22, expressionAttributeId=54)
     eTgtAttr2 = self.ch.expression(expressionId=4, operandId=22, expressionAttributeId=158)
     eTgtAttr3 = self.ch.expression(expressionId=5, operandId=22, expressionAttributeId=160)
     eOptr = self.ch.expression(expressionId=6, operandId=21, value="PostPercent")
     eSrcAttr1 = self.ch.expression(expressionId=7, operandId=22, expressionAttributeId=351)
     eSrcAttr2 = self.ch.expression(expressionId=8, operandId=22, expressionAttributeId=349)
     eSrcAttr3 = self.ch.expression(expressionId=9, operandId=22, expressionAttributeId=767)
     eTgtItms = self.ch.expression(expressionId=10, operandId=49, arg1Id=eTgtLoc.id, arg2Id=eTgtSrq.id)
     eTgtSpec1 = self.ch.expression(expressionId=11, operandId=12, arg1Id=eTgtItms.id, arg2Id=eTgtAttr1.id)
     eTgtSpec2 = self.ch.expression(expressionId=12, operandId=12, arg1Id=eTgtItms.id, arg2Id=eTgtAttr2.id)
     eTgtSpec3 = self.ch.expression(expressionId=13, operandId=12, arg1Id=eTgtItms.id, arg2Id=eTgtAttr3.id)
     eOptrTgt1 = self.ch.expression(expressionId=14, operandId=31, arg1Id=eOptr.id, arg2Id=eTgtSpec1.id)
     eOptrTgt2 = self.ch.expression(expressionId=15, operandId=31, arg1Id=eOptr.id, arg2Id=eTgtSpec2.id)
     eOptrTgt3 = self.ch.expression(expressionId=16, operandId=31, arg1Id=eOptr.id, arg2Id=eTgtSpec3.id)
     eAddMod1 = self.ch.expression(expressionId=17, operandId=9, arg1Id=eOptrTgt1.id, arg2Id=eSrcAttr1.id)
     eAddMod2 = self.ch.expression(expressionId=18, operandId=9, arg1Id=eOptrTgt2.id, arg2Id=eSrcAttr2.id)
     eAddMod3 = self.ch.expression(expressionId=19, operandId=9, arg1Id=eOptrTgt3.id, arg2Id=eSrcAttr3.id)
     eRmMod1 = self.ch.expression(expressionId=20, operandId=61, arg1Id=eOptrTgt1.id, arg2Id=eSrcAttr1.id)
     eRmMod2 = self.ch.expression(expressionId=21, operandId=61, arg1Id=eOptrTgt2.id, arg2Id=eSrcAttr2.id)
     eRmMod3 = self.ch.expression(expressionId=22, operandId=61, arg1Id=eOptrTgt3.id, arg2Id=eSrcAttr3.id)
     eAddSplice1 = self.ch.expression(expressionId=23, operandId=17, arg1Id=eAddMod1.id, arg2Id=eAddMod3.id)
     eAddSplice2 = self.ch.expression(expressionId=24, operandId=17, arg1Id=eAddMod2.id, arg2Id=eAddSplice1.id)
     eRmSplice1 = self.ch.expression(expressionId=25, operandId=17, arg1Id=eRmMod1.id, arg2Id=eRmMod3.id)
     eRmSplice2 = self.ch.expression(expressionId=26, operandId=17, arg1Id=eRmMod2.id, arg2Id=eRmSplice1.id)
     effect = self.ch.effect(categoryId=0, preExpressionId=eAddSplice2.id, postExpressionId=eRmSplice2.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 3)
コード例 #2
0
ファイル: testStub.py プロジェクト: oneillkza/Eos
 def testBuildSuccess(self):
     ePreStub = self.ch.expression(expressionId=1, operandId=23, value="True")
     ePostStub = self.ch.expression(expressionId=2, operandId=27, value="0")
     effect = self.ch.effect(categoryId=0, preExpressionId=ePreStub.id, postExpressionId=ePostStub.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 0)
コード例 #3
0
ファイル: testModLoc.py プロジェクト: oneillkza/Eos
 def testEffCategoryTarget(self):
     effect = self.ch.effect(categoryId=2, preExpressionId=self.eAddMod.id, postExpressionId=self.eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 1)
     modifier = modifiers[0]
     self.assertEqual(modifier.state, State.active)
     self.assertEqual(modifier.context, Context.projected)
コード例 #4
0
ファイル: testModLoc.py プロジェクト: oneillkza/Eos
 def testEffCategoryOverload(self):
     effect = self.ch.effect(categoryId=5, preExpressionId=self.eAddMod.id, postExpressionId=self.eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 1)
     modifier = modifiers[0]
     self.assertEqual(modifier.state, State.overload)
     self.assertEqual(modifier.context, Context.local)
コード例 #5
0
ファイル: testModifier.py プロジェクト: oneillkza/Eos
 def testDataDirect(self):
     # Check reaction to expression data fetch errors
     effect = self.ch.effect(effectId=900, categoryId=0, preExpressionId=902, postExpressionId=28)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.ERROR)
     self.assertEqual(logRecord.msg, "failed to parse expressions of effect 900: unable to fetch expression 902")
コード例 #6
0
ファイル: testAction.py プロジェクト: oneillkza/Eos
 def testBoolStub(self):
     ePreStub = self.ch.expression(expressionId=1, operandId=27, value="0")
     ePost = self.ch.expression(expressionId=2, operandId=23, value="False")
     effect = self.ch.effect(effectId=92, categoryId=0, preExpressionId=ePreStub.id, postExpressionId=ePost.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.WARNING)
     self.assertEqual(logRecord.msg, "failed to parse expressions of effect 92: boolean stub with unexpected value False")
コード例 #7
0
ファイル: testAction.py プロジェクト: oneillkza/Eos
 def testGeneric(self):
     ePreStub = self.ch.expression(expressionId=1, operandId=27, value="1")
     ePost = self.ch.expression(expressionId=2, operandId=1009)
     effect = self.ch.effect(effectId=568, categoryId=0, preExpressionId=ePreStub.id, postExpressionId=ePost.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.WARNING)
     self.assertEqual(logRecord.msg, "failed to parse expressions of effect 568: unknown generic operand 1009")
コード例 #8
0
ファイル: testAction.py プロジェクト: oneillkza/Eos
 def testDataIndirect(self):
     # Check reaction to expression data fetch errors,
     # if they occur not for root expression
     splice = self.ch.expression(expressionId=1, operandId=17, arg1Id=37, arg2Id=105)
     effect = self.ch.effect(effectId=900, categoryId=0, preExpressionId=splice.id, postExpressionId=splice.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.ERROR)
     self.assertEqual(logRecord.msg, "failed to parse expressions of effect 900: unable to fetch expression 37")
コード例 #9
0
ファイル: testModLoc.py プロジェクト: oneillkza/Eos
 def testGenericBuildSuccess(self):
     effect = self.ch.effect(categoryId=0, preExpressionId=self.eAddMod.id, postExpressionId=self.eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 1)
     modifier = modifiers[0]
     self.assertEqual(modifier.context, Context.local)
     self.assertEqual(modifier.sourceAttributeId, 1503)
     self.assertEqual(modifier.operator, Operator.postPercent)
     self.assertEqual(modifier.targetAttributeId, 1211)
     self.assertEqual(modifier.location, Location.ship)
     self.assertEqual(modifier.filterType, FilterType.all_)
     self.assertIsNone(modifier.filterValue)
コード例 #10
0
ファイル: testModGangOwnSrq.py プロジェクト: oneillkza/Eos
 def testGenericBuildSuccess(self):
     effect = self.ch.effect(categoryId=0, preExpressionId=self.eAddMod.id, postExpressionId=self.eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 1)
     modifier = modifiers[0]
     self.assertEqual(modifier.context, Context.gang)
     self.assertEqual(modifier.sourceAttributeId, 848)
     self.assertEqual(modifier.operator, Operator.postMul)
     self.assertEqual(modifier.targetAttributeId, 654)
     self.assertEqual(modifier.location, Location.space)
     self.assertEqual(modifier.filterType, FilterType.skill)
     self.assertEqual(modifier.filterValue, 3326)
コード例 #11
0
ファイル: effect.py プロジェクト: oneillkza/Eos
    def getModifiers(self, logger):
        """
        Get modifiers of effect.

        Positional arguments:
        logger -- instance of logger to use for error reporting

        Return value:
        Set with Modifier objects generated by effect
        """
        if self._modifiers is None:
            self._modifiers, self.modifierStatus = ModifierBuilder.build(self, logger)
        return self._modifiers
コード例 #12
0
ファイル: testAction.py プロジェクト: oneillkza/Eos
 def testUnknown(self):
     # Check reaction to any errors of action builder,
     # which are not specifically processed by it
     ePreStub = self.ch.expression(expressionId=1, operandId=27, value="0")
     ePost = self.ch.expression(expressionId=2, operandId=23, value="Garbage")
     effect = self.ch.effect(effectId=66, categoryId=0, preExpressionId=ePreStub.id, postExpressionId=ePost.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.ERROR)
     self.assertEqual(logRecord.msg, "failed to parse expressions of effect 66 due to unknown reason")
コード例 #13
0
ファイル: testSelfType.py プロジェクト: oneillkza/Eos
 def testBuildSuccess(self):
     eTgtOwn = self.ch.expression(expressionId=1, operandId=24, value="Char")
     eSelf = self.ch.expression(expressionId=2, operandId=24, value="Self")
     eSelfType = self.ch.expression(expressionId=3, operandId=36, arg1Id=eSelf.id)
     eTgtAttr = self.ch.expression(expressionId=4, operandId=22, expressionAttributeId=64)
     eOptr = self.ch.expression(expressionId=5, operandId=21, value="PostPercent")
     eSrcAttr = self.ch.expression(expressionId=6, operandId=22, expressionAttributeId=292)
     eTgtItms = self.ch.expression(expressionId=7, operandId=49, arg1Id=eTgtOwn.id, arg2Id=eSelfType.id)
     eTgtSpec = self.ch.expression(expressionId=8, operandId=12, arg1Id=eTgtItms.id, arg2Id=eTgtAttr.id)
     eOptrTgt = self.ch.expression(expressionId=9, operandId=31, arg1Id=eOptr.id, arg2Id=eTgtSpec.id)
     eAddMod = self.ch.expression(expressionId=10, operandId=11, arg1Id=eOptrTgt.id, arg2Id=eSrcAttr.id)
     eRmMod = self.ch.expression(expressionId=11, operandId=62, arg1Id=eOptrTgt.id, arg2Id=eSrcAttr.id)
     effect = self.ch.effect(categoryId=0, preExpressionId=eAddMod.id, postExpressionId=eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okFull)
     self.assertEqual(len(modifiers), 1)
     modifier = modifiers[0]
     self.assertEqual(modifier.filterType, FilterType.skill)
     self.assertEqual(modifier.filterValue, InvType.self_)
コード例 #14
0
ファイル: testModifier.py プロジェクト: oneillkza/Eos
 def testUnusedActions(self):
     # To produce unused actions, we're passing just tree
     # which describes action which applies something, and
     # stub instead of action undoing it
     eTgt = self.ch.expression(expressionId=1, operandId=24, value="Ship")
     eTgtAttr = self.ch.expression(expressionId=2, operandId=22, expressionAttributeId=9)
     eOptr = self.ch.expression(expressionId=3, operandId=21, value="PostPercent")
     eSrcAttr = self.ch.expression(expressionId=4, operandId=22, expressionAttributeId=327)
     eTgtSpec = self.ch.expression(expressionId=5, operandId=12, arg1Id=eTgt.id, arg2Id=eTgtAttr.id)
     eOptrTgt = self.ch.expression(expressionId=6, operandId=31, arg1Id=eOptr.id, arg2Id=eTgtSpec.id)
     eAddMod = self.ch.expression(expressionId=7, operandId=6, arg1Id=eOptrTgt.id, arg2Id=eSrcAttr.id)
     ePostStub = self.ch.expression(expressionId=8, operandId=27, value="1")
     effect = self.ch.effect(effectId=799, categoryId=0, preExpressionId=eAddMod.id, postExpressionId=ePostStub.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okPartial)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.WARNING)
     self.assertEqual(logRecord.msg, "unused actions left after generating modifiers for effect 799")
コード例 #15
0
ファイル: testAction.py プロジェクト: oneillkza/Eos
 def testValidation(self):
     # To make invalid action, we've just took location
     # and group- filtered expression tree and replaced its
     # actual top-level operands with operand describing
     # direct modification
     eTgtLoc = self.ch.expression(expressionId=1, operandId=24, value="Ship")
     eTgtGrp = self.ch.expression(expressionId=2, operandId=26, expressionGroupId=46)
     eTgtAttr = self.ch.expression(expressionId=3, operandId=22, expressionAttributeId=6)
     eOptr = self.ch.expression(expressionId=4, operandId=21, value="PostPercent")
     eSrcAttr = self.ch.expression(expressionId=5, operandId=22, expressionAttributeId=1576)
     eTgtItms = self.ch.expression(expressionId=6, operandId=48, arg1Id=eTgtLoc.id, arg2Id=eTgtGrp.id)
     eTgtSpec = self.ch.expression(expressionId=7, operandId=12, arg1Id=eTgtItms.id, arg2Id=eTgtAttr.id)
     eOptrTgt = self.ch.expression(expressionId=8, operandId=31, arg1Id=eOptr.id, arg2Id=eTgtSpec.id)
     eAddMod = self.ch.expression(expressionId=9, operandId=6, arg1Id=eOptrTgt.id, arg2Id=eSrcAttr.id)
     eRmMod = self.ch.expression(expressionId=10, operandId=58, arg1Id=eOptrTgt.id, arg2Id=eSrcAttr.id)
     effect = self.ch.effect(effectId=20807, categoryId=0, preExpressionId=eAddMod.id, postExpressionId=eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
     self.assertEqual(len(self.log), 1)
     logRecord = self.log[0]
     self.assertEqual(logRecord.name, "eos_test.modifierBuilder")
     self.assertEqual(logRecord.levelno, Logger.WARNING)
     self.assertEqual(logRecord.msg, "failed to parse expressions of effect 20807: failed to validate action")
コード例 #16
0
ファイル: testInactive.py プロジェクト: oneillkza/Eos
 def testFofLaunch(self):
     disabledPre = self.ch.expression(expressionId=1, operandId=47)
     effect = self.ch.effect(categoryId=0, preExpressionId=disabledPre.id, postExpressionId=self.stub.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okPartial)
     self.assertEqual(len(modifiers), 0)
コード例 #17
0
ファイル: testModLoc.py プロジェクト: oneillkza/Eos
 def testEffCategoryArea(self):
     effect = self.ch.effect(categoryId=3, preExpressionId=self.eAddMod.id, postExpressionId=self.eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.error)
     self.assertEqual(len(modifiers), 0)
コード例 #18
0
ファイル: testIncomplete.py プロジェクト: oneillkza/Eos
 def testPost(self):
     eRmMod = self.ch.expression(expressionId=8, operandId=58, arg1Id=self.eOptrTgt.id, arg2Id=self.eSrcAttr.id)
     effect = self.ch.effect(categoryId=0, preExpressionId=self.stub.id, postExpressionId=eRmMod.id)
     modifiers, status = ModifierBuilder.build(effect, Logger())
     self.assertEqual(status, EffectBuildStatus.okPartial)
     self.assertEqual(len(modifiers), 0)