Esempio n. 1
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);
        }
Esempio n. 2
0
        public void DeathTestReviveLater()
        {
            BaseEntity player = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };
            long reviveDuration = 10;

            player.ReviveDuration = new MeNode(reviveDuration);
            player.RefreshProperties();
            player.Kill();
            MockTimer timer = (MockTimer)Engine.GetTimer();

            for (int i = 0; i < reviveDuration; ++i)
            {
                player.Update();
                timer.ForceTick();
                Assert.AreEqual(true, player.IsDead);
            }
            player.Update();
            Assert.AreEqual(false, player.IsDead);
            ResourceInstance hp = player.GetResource(Entity.HP_KEY);

            Assert.AreEqual(hp.MaxAmount * hp.Modifier, hp.Value);
        }
Esempio n. 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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public void CastTestInterrupt()
        {
            BaseEntity mob = new MockEntity(Engine);


            double expectedMobHealth = mob.GetProperty(Entity.HP_KEY).Value;

            _testPlayer.Cast(mob, _testSkill.Key);
            _testPlayer.InterruptCasting();

            MockTimer timer = (MockTimer)Engine.GetTimer();

            MeNode duration = _unpushable.ByLevel[0].Duration;

            duration = Sanitizer.ReplaceTargetAndSource(duration, _testPlayer, _testPlayer);
            long skillDuration = duration.Resolve().Value.ToLong();

            for (int i = 0; i < skillDuration; ++i)
            {
                timer.ForceTick();
                _testPlayer.Update();
                mob.Update();
            }

            timer.ForceTick();
            _testPlayer.Update();
            mob.Update();
            Assert.AreEqual(expectedMobHealth, mob.GetProperty(Entity.HP_KEY).Value);
        }
Esempio n. 6
0
        public void CastTestPushbackChannelSkill()
        {
            long       delay = 10;
            BaseEntity mob   = new MockEntity(Engine);

            double expectedMobHealth = mob.GetProperty(Entity.HP_KEY).Value - 50;

            _testPlayer.Cast(mob, _testChannelSkill.Key);
            _testPlayer.AddPushback(delay);

            MockTimer timer = (MockTimer)Engine.GetTimer();

            MeNode duration = _testChannelSkill.ByLevel[0].Duration;

            duration = Sanitizer.ReplaceTargetAndSource(duration, _testPlayer, _testPlayer);
            long skillDuration = duration.Resolve().Value.ToLong();

            for (int i = 0; i < skillDuration; ++i)
            {
                timer.ForceTick();
                _testPlayer.Update();
                mob.Update();
            }

            timer.ForceTick();
            _testPlayer.Update();
            mob.Update();
            Assert.AreEqual(expectedMobHealth, mob.GetProperty(Entity.HP_KEY).Value);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public void DeathTestRevive()
        {
            BaseEntity player = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };

            player.Kill();
            player.Update();
            Assert.AreEqual(true, player.IsDead);
            player.Update();
            Assert.AreEqual(false, player.IsDead);
            ResourceInstance hp = player.GetResource(Entity.HP_KEY);

            Assert.AreEqual(hp.MaxAmount * hp.Modifier, hp.Value);
        }
Esempio n. 10
0
        public void DeathTestKill()
        {
            BaseEntity player = new MockEntity(Engine)
            {
                Name = "MOCK_PLAYER", Key = "MOCK_KEY"
            };

            player.Kill();
            player.Update();
            Assert.AreEqual(true, player.IsDead);
        }
Esempio n. 11
0
        public void CastTestResourceNotEnoughMana()
        {
            BaseEntity mob = new MockEntity(Engine);
            double     expectedMobHealth = mob.GetProperty(Entity.HP_KEY).Value - 10;

            _testPlayer.Cast(mob, _costly.Key);
            Assert.AreEqual(0, _testPlayer.ResourceMap["MP"].Value);

            MockTimer timer = (MockTimer)Engine.GetTimer();

            timer.ForceTick();
            _testPlayer.Update();
            mob.Update();
            Assert.AreEqual(expectedMobHealth, mob.GetProperty(Entity.HP_KEY).Value);


            bool secondRes = _testPlayer.Cast(mob, _costly.Key);

            Assert.AreEqual(false, secondRes);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }