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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void LevelTestStatIncrease() { MockEntity ent = new MockEntity(Engine); double expected = ent.GetProperty("STR").Value + 1; Assert.AreEqual(false, ent.AssignAttributePoint("STR")); ent.AddExp(StartExp); Assert.AreEqual(1, ent.AttributePoints); Assert.AreEqual(true, ent.AssignAttributePoint("STR")); Assert.AreEqual(expected, ent.GetProperty("STR").Value); }
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); }
public void LevelTestStatIncreaseAffectsResource() { string stat = "VIT"; MockEntity ent = new MockEntity(Engine); double expected = ent.GetProperty(stat).Value + 1; ResourceInstance hp = ((ResourceInstance)ent.GetProperty(Entity.HP_KEY)); double expectedRes = hp.MaxAmount + 20; ent.AddExp(StartExp); ent.AssignAttributePoint(stat); Assert.AreEqual(expected, ent.GetProperty(stat).Value); Assert.AreEqual(expectedRes, hp.MaxAmount); }
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); }
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); }
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); }
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); }
public void EntityTestAddResource() { MockEntity ent = new MockEntity(Engine); ResourceTemplate resTemp = new ResourceTemplate(); resTemp.Formula = new MeNode(100); resTemp.RegenFormula = new MeNode(0); resTemp.RegenInterval = new MeNode(0); resTemp.StartMod = new MeNode(0); resTemp.Key = "TEST_RES"; resTemp.Name = "Test Resource"; resTemp.Description = ""; ent.AddResource(resTemp); ent.Key = "TEST_KEY"; Assert.AreEqual(0, ent.GetProperty(resTemp.Key).Value); long amount = 50; Engine.AddPlayer(ent); string fromula = $"{LConstants.ADD_TO_RESOURCE_F}({ent.Key},{resTemp.Key},{amount})"; TreeConverter.Build(fromula, Engine).Resolve(); Assert.AreEqual(amount, ent.GetProperty(resTemp.Key).Value); }