Beispiel #1
0
        public void CastTestNonInterrupt()
        {
            BaseEntity mob = new MockEntity(Engine);


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

            _testPlayer.Cast(mob, _unpushable.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();
            }

            timer.ForceTick();
            _testPlayer.Update();
            Assert.AreEqual(expectedMobHealth, mob.GetProperty(Entity.HP_KEY).Value);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public void EntityTestModifierStatusEffectsRemoved()
        {
            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_KEY10";
            double[] values   = { 10 };
            int      duration = 5;
            double   expected = ent.GetProperty("STR").Value + 10;

            double removedExpected = ent.GetProperty("STR").Value;

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

            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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public void CastTestResourceEnoughMana()
        {
            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();
            Assert.AreEqual(expectedMobHealth, mob.GetProperty(Entity.HP_KEY).Value);
        }
Beispiel #8
0
        public void CastTestSkillUsingStats()
        {
            BaseEntity mob = new MockEntity(Engine);
            double     expectedMobHealth = mob.GetProperty(Entity.HP_KEY).Value - _testPlayer.GetProperty("STR").Value *10 - _testPlayer.GetProperty(BASE_VALUE).Value;

            _testPlayer.Cast(mob, _skillUsingStat.Key);
            foreach (MeNode node in _skillUsingStat.ByLevel[0].Formulas)
            {
                Console.WriteLine(node.ToString());
            }
            MockTimer timer = (MockTimer)Engine.GetTimer();

            timer.ForceTick();
            _testPlayer.Update();
            Assert.AreEqual(expectedMobHealth, mob.GetProperty(Entity.HP_KEY).Value);
        }
Beispiel #9
0
        public void CastTestChannelSkill()
        {
            BaseEntity mob      = new MockEntity(Engine);
            double     expected = mob.GetProperty(Entity.HP_KEY).Value - 60;

            _testPlayer.Cast(mob, _testChannelSkill.Key);
            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();
            }

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

            Assert.AreEqual(expected, actual);
        }
Beispiel #10
0
        public void CastTestFormulaIsExecutedWithTime()
        {
            double expected = _testPlayer.GetProperty(Entity.HP_KEY).Value - 10;
            double before   = _testPlayer.GetProperty(Entity.HP_KEY).Value;

            _testPlayer.Cast(_testPlayer, _testSkill.Key);
            MockTimer timer    = (MockTimer)Engine.GetTimer();
            MeNode    duration = _testSkill.ByLevel[0].Duration;

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

            for (int i = 0; i < skillDuration; ++i)
            {
                timer.ForceTick();
                actual = _testPlayer.GetProperty(Entity.HP_KEY).Value;
                Assert.AreEqual(before, actual);
                _testPlayer.Update();
            }

            actual = _testPlayer.GetProperty(Entity.HP_KEY).Value;
            Assert.AreEqual(expected, actual);
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            const int  SLEEP_TIME = 1000;
            GameEngine engine     = new GameEngine(new DiscordLogHelper(new ConsoleLogger()));

            engine.LoadConfigFromFiles();
            MockTimer timer = (MockTimer)engine.GetTimer();

            CommandManager.Instance.Engine = engine;
            Command cmd = new Command()
            {
                UserId = 1, Name = "create", Args = new string[] { "John", "edge" }
            };
            Command cmd2 = new Command()
            {
                UserId = 2, Name = "create", Args = new string[] { "Putza", "shonen" }
            };
            Command cmd3 = new Command()
            {
                UserId = 1, Name = "duel", Args = new string[] { "challenge", "Putza" }
            };
            Command cmd4 = new Command()
            {
                UserId = 2, Name = "duel", Args = new string[] { "accept" }
            };
            Command cmd5 = new Command()
            {
                UserId = 2, Name = "autoattack", Args = new string[] {}
            };
            Command cmd6 = new Command()
            {
                UserId = 1, Name = "cast", Args = new string[] { "strike" }
            };
            Command meCmd = new Command()
            {
                UserId = 2, Name = "me", Args = new string[] {}
            };
            Command meSkills = new Command()
            {
                UserId = 2, Name = "me", Args = new string[] { "skills" }
            };

            engine.EnqueueCommand(cmd);
            engine.EnqueueCommand(cmd2);

            engine.Update();
            timer.ForceTick();
            engine.GetPlayerManager().FindPlayerById(1).Entity.AddToResource("RP", 100);

            engine.EnqueueCommand(cmd3);
            engine.EnqueueCommand(cmd4);
            engine.EnqueueCommand(cmd5);
            engine.EnqueueCommand(meCmd);
            engine.EnqueueCommand(cmd6);
            engine.EnqueueCommand(meSkills);



            while (true)
            {
                engine.Update();
                timer.ForceTick();

                Thread.Sleep(SLEEP_TIME);
            }
        }