Example #1
0
        public void EntityTestModifierStatusEffectsMultiple()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            string expression = $"{LConstants.ADD_MOD_F}(STR,$0)";

            MeNode[]       statuses = Engine.GetSanitizer().SplitAndConvert(expression);
            int            duration = 5;
            StatusTemplate test     = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build("0", Engine), Type = StackingType.Independent, MaxStacks = TreeConverter.Build("0", Engine)
            };

            test.Key = "shonen_powerup";
            double[] values = { 10 };

            double expected        = ent.GetProperty("STR").Value + values[0] * 2;
            double removedExpected = ent.GetProperty("STR").Value;

            ent.ApplyStatus(test, ent, duration, values);
            ent.ApplyStatus(test, ent, duration, values);
            MockTimer timer = (MockTimer)Engine.GetTimer();

            ent.Update();
            Assert.AreEqual(expected, ent.GetProperty("STR").Value);
            for (int i = 0; i <= duration; ++i)
            {
                timer.ForceTick();
            }
            ent.Update();
            Assert.AreEqual(removedExpected, ent.GetProperty("STR").Value);
        }
Example #2
0
        public void EntityTestHarmStatusIntervalIsFormula()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            double damage     = 10;
            string expression = $"{LConstants.HARM_F}({LConstants.TargetKeyword},{LConstants.TargetKeyword},T,{damage})";

            MeNode[]       statuses           = Engine.GetSanitizer().SplitAndConvert(expression);
            string         intervalExpression = $"10-{LConstants.GET_PROP_F}({LConstants.SourceKeyword},INT)*2";
            MeNode         intervalNode       = TreeConverter.Build(intervalExpression, Engine);
            StatusTemplate test = new StatusTemplate(statuses)
            {
                Interval = intervalNode
            };

            test.Key = "TEST_STATUS_KEY2";
            ent.ApplyStatus(test, ent, 5, null);
            double    expectedHp  = ent.GetProperty(Entity.HP_KEY).Value - damage;
            double    expectedHp2 = ent.GetProperty(Entity.HP_KEY).Value - damage * 2;
            MockTimer timer       = (MockTimer)Engine.GetTimer();

            ent.Update();
            timer.ForceTick();
            Assert.AreEqual(expectedHp, ent.GetProperty(Entity.HP_KEY).Value);

            ent.Update();
            Assert.AreEqual(expectedHp2, ent.GetProperty(Entity.HP_KEY).Value);
        }
Example #3
0
        public void EntityTestModifierHarmTickrate()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };

            int[]  timeValues = { 10, 5 };
            string expression = $"{LConstants.HARM_F}({LConstants.TargetKeyword},{LConstants.TargetKeyword},T,$0)";

            MeNode[]       statuses = Engine.GetSanitizer().SplitAndConvert(expression);
            StatusTemplate test     = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build(timeValues[0].ToString(), Engine)
            };

            test.Key = "TEST_STATUS_KEY4";
            double[] values = { 20 };
            ent.ApplyStatus(test, ent, timeValues[0], values);
            double    expectedHp = ent.GetProperty(Entity.HP_KEY).Value - values[0];
            MockTimer timer      = (MockTimer)Engine.GetTimer();

            ent.Update();
            Assert.AreEqual(expectedHp, ent.GetProperty(Entity.HP_KEY).Value);

            timer.ForceTick();
            timer.ForceTick();
            ent.Update();

            Assert.AreEqual(expectedHp, ent.GetProperty(Entity.HP_KEY).Value);
        }
Example #4
0
        public void EntityTestModifierAndHarm()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            string expression = $"{LConstants.HARM_F}({LConstants.TargetKeyword},{LConstants.TargetKeyword},T,$0);{LConstants.ADD_MOD_F}(STR,$1)";

            MeNode[]       statuses = Engine.GetSanitizer().SplitAndConvert(expression);
            StatusTemplate test     = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build("0", Engine)
            };

            test.Key = "TEST_STATUS_KEY3";
            double[] values     = { 20, 10 };
            double   expectedHp = ent.GetProperty(Entity.HP_KEY).Value - values[0];
            double   expected   = ent.GetProperty("STR").Value + values[1];

            ent.ApplyStatus(test, ent, 5, values);
            ent.Update();

            Assert.AreEqual(expectedHp, ent.GetProperty(Entity.HP_KEY).Value);
            Assert.AreEqual(expected, ent.GetProperty("STR").Value);
        }
Example #5
0
        public void EntityTestModifierMultipleStatusEffects()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            string expression = $"{LConstants.ADD_MOD_F}(STR,$0);{LConstants.ADD_MOD_F}(AGI,$1)";

            MeNode[] statuses = Engine.GetSanitizer().SplitAndConvert(expression);

            StatusTemplate test = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build("0", Engine)
            };

            test.Key = "TEST_STATUS_KEY5";
            double[] values = { 10, 5 };

            double expectedStr = ent.GetProperty("STR").Value + values[0];
            double expetedDex  = ent.GetProperty("AGI").Value + values[1];

            ent.ApplyStatus(test, ent, 5, values);
            MockTimer timer = (MockTimer)Engine.GetTimer();

            ent.Update();
            Assert.AreEqual(expectedStr, ent.GetProperty("STR").Value);
            Assert.AreEqual(expetedDex, ent.GetProperty("AGI").Value);
        }
Example #6
0
        public void EntityTestHarmStatusEffect()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            double damage     = 10;
            string expression = $"{LConstants.HARM_F}({LConstants.TargetKeyword},{LConstants.TargetKeyword},T,{damage})";

            MeNode[]       statuses = Engine.GetSanitizer().SplitAndConvert(expression);
            StatusTemplate test     = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build("0", Engine)
            };

            test.Key = "TEST_STATUS_KEY";
            ent.ApplyStatus(test, ent, 5, null);
            double expectedHp = ent.GetProperty(Entity.HP_KEY).Value - damage;

            ent.Update();
            Assert.AreEqual(expectedHp, ent.GetProperty(Entity.HP_KEY).Value);
        }
Example #7
0
        public void EntityTestModifierStatusEffect()
        {
            BaseEntity ent = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            string expression = $"{LConstants.ADD_MOD_F}(STR,$0)";

            MeNode[]       statuses = Engine.GetSanitizer().SplitAndConvert(expression);
            StatusTemplate test     = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build("0", Engine)
            };

            test.Key = "TEST_STATUS_KEY6";
            double[] values = { 10 };

            double expected = ent.GetProperty("STR").Value + 10;

            ent.ApplyStatus(test, ent, 5, values);
            ent.Update();
            Assert.AreEqual(expected, ent.GetProperty("STR").Value);
        }