public void SkillReaderTestDefaultValues() { string key = "TEST_STATUS"; string jsonStr = $"{{\"{GcConstants.General.KEY}\":\"{key}\","; jsonStr += $"\"{GcConstants.Skills.VALUES_BY_LEVEL}\":["; jsonStr += "{"; jsonStr += $"\"{GcConstants.General.FORMULA}\":"; jsonStr += $"\"{LConstants.HARM_F}({LConstants.TargetKeyword},{LConstants.SourceKeyword},T,10)\""; jsonStr += "}"; jsonStr += "]}"; JObject json = JObject.Parse(jsonStr); SkillTemplate skill = Reader.FromJson(json); Assert.AreEqual(skill.Key, key); Assert.AreEqual(1, skill.Aliases.Count); Assert.AreEqual(key, skill.Aliases[0]); Assert.AreEqual(skill.Type, SkillType.Cast); Assert.AreEqual(1, skill.ByLevel.Count); SkillLevelTemplate levelTemplate = skill.ByLevel[0]; Assert.AreEqual(double.Parse(GcConstants.Skills.DEFAULT_COST_VALUE), levelTemplate.Cost.Amount.Value.ToDouble()); Assert.AreEqual(Entity.HP_KEY, levelTemplate.Cost.Resource.Key); Assert.AreEqual(GcConstants.Skills.DEFAULT_NEEDED_LEVEL, levelTemplate.NeededLevel); Assert.AreEqual(double.Parse(GcConstants.Skills.DEFAULT_CAST_DURATION), levelTemplate.Duration.Value.ToDouble()); Assert.AreEqual(double.Parse(GcConstants.Skills.DEFAULT_COOLDOWN), levelTemplate.Cooldown.Value.ToDouble()); Assert.AreEqual(GcConstants.Core.DEFAULT_THREAT, levelTemplate.SkillThreat.Value.ToDouble()); Assert.IsNull(levelTemplate.Interval); Assert.AreEqual(GcConstants.Skills.DEFAULT_INTERRUPT, levelTemplate.PushBack.Value.ToBoolean()); Assert.AreEqual(GcConstants.Skills.DEFAULT_PUSHBACK, levelTemplate.Interruptible.Value.ToBoolean()); Assert.AreEqual(1, levelTemplate.Formulas.Count); Assert.IsNotNull(levelTemplate.Formulas[0]); }
public void LoadSkillsFromFile(string path) { JArray skillJson = FileHandler.FromPath <JArray>(path); SkillReader reader = new SkillReader(Engine); foreach (JToken skillValue in skillJson) { if (skillValue.Type != JTokenType.Object) { throw new MeException($"Expected a json object \"{path}\"at \"{skillValue}\"."); } SkillTemplate newSkill = reader.FromJson(skillValue.ToObject <JObject>()); AddSkill(newSkill); } }