diff --git a/NetStone.Test/Tests.cs b/NetStone.Test/Tests.cs index ec35f4b..cbd236b 100644 --- a/NetStone.Test/Tests.cs +++ b/NetStone.Test/Tests.cs @@ -20,6 +20,7 @@ public class Tests private const string TestCharacterIdEureka = "14556736"; private const string TestCharacterIdEureka2 = "6787158"; private const string TestCharacterIdBare = "9426169"; + private const string TestCharacterIdDoH = "42256897"; private const string TestFreeCompany = "9232379236109629819"; private const string TestFreeCompanyRecruiting = "9232660711086374997"; @@ -289,6 +290,17 @@ public async Task TestFreeCompanySearch() } while (page != null); } + [Test] + public async Task CheckCharacterDoH() + { + var chara = await this.lodestone.GetCharacter(TestCharacterIdDoH); + Assert.NotNull(chara); + var attribs = chara.Attributes; + Assert.AreEqual(39, attribs.Craftsmanship); + Assert.AreEqual(7, attribs.Control); + Assert.AreEqual(180, attribs.MpGpCp); + } + [Test] public async Task CheckCharacterBare() { diff --git a/NetStone/Model/Parseables/Character/CharacterAttributes.cs b/NetStone/Model/Parseables/Character/CharacterAttributes.cs index a65c407..3ecb985 100644 --- a/NetStone/Model/Parseables/Character/CharacterAttributes.cs +++ b/NetStone/Model/Parseables/Character/CharacterAttributes.cs @@ -1,4 +1,5 @@ -using HtmlAgilityPack; +using System; +using HtmlAgilityPack; using NetStone.Definitions.Model.Character; namespace NetStone.Model.Parseables.Character; @@ -84,13 +85,13 @@ public CharacterAttributes(HtmlNode rootNode, CharacterAttributesDefinition defi /// This characters' Attack Magic Potency value. /// /// This value is only set for disciples of war/magic. - public int? AttackMagicPotency => MpGpCpParameterName == "MP" ? int.Parse(Parse(this.definition.AttackMagicPotency)) : null; + public int? AttackMagicPotency => IsDoWOrDoM() ? this.AttackMagicPotencyInternal : null; /// /// This characters' Healing Magic Potency value. /// /// This value is only set for disciples of war/magic. - public int? HealingMagicPotency => MpGpCpParameterName == "MP" ? int.Parse(Parse(this.definition.HealingMagicPotency)) : null; + public int? HealingMagicPotency => IsDoWOrDoM() ? this.HealingMagicPotencyInternal : null; /// /// This characters' Spell Speed value. @@ -112,25 +113,25 @@ public CharacterAttributes(HtmlNode rootNode, CharacterAttributesDefinition defi /// This characters' Craftmanship value. /// /// This value is only set for disciples of the hand. - public int? Craftmanship => MpGpCpParameterName == "CP" ? AttackMagicPotencyValue : null; + public int? Craftsmanship => IsDoH() ? this.AttackMagicPotencyInternal : null; /// /// This characters' Control value. /// /// This value is only set for disciples of the hand. - public int? Control => MpGpCpParameterName == "CP" ? HealingMagicPotencyValue : null; + public int? Control => IsDoH() ? this.HealingMagicPotencyInternal : null; /// /// This characters' Gathering value. /// /// This value is only set for disciples of the land. - public int? Gathering => MpGpCpParameterName == "GP" ? AttackMagicPotencyValue : null; + public int? Gathering => IsDoL() ? this.AttackMagicPotencyInternal : null; /// /// This characters' Perception value. /// /// This value is only set for disciples of the land. - public int? Perception => MpGpCpParameterName == "GP" ? HealingMagicPotencyValue : null; + public int? Perception => IsDoL() ? this.HealingMagicPotencyInternal : null; /// /// This characters' HP value. @@ -146,8 +147,12 @@ public CharacterAttributes(HtmlNode rootNode, CharacterAttributesDefinition defi /// Value indicating which of MP, GP, or CP is indicated by . /// public string MpGpCpParameterName => Parse(this.definition.MpGpCpParameterName); + + internal bool IsDoL() => this.MpGpCpParameterName.Equals("GP", StringComparison.InvariantCultureIgnoreCase); + internal bool IsDoWOrDoM() => this.MpGpCpParameterName.Equals("MP", StringComparison.InvariantCultureIgnoreCase); + internal bool IsDoH() => this.MpGpCpParameterName.Equals("CP", StringComparison.InvariantCultureIgnoreCase); - private int AttackMagicPotencyValue => int.Parse(Parse(this.definition.AttackMagicPotency)); - - private int HealingMagicPotencyValue => int.Parse(Parse(this.definition.HealingMagicPotency)); + internal int AttackMagicPotencyInternal => int.TryParse(Parse(this.definition.AttackMagicPotency), out var val) ? val : 0; + + internal int HealingMagicPotencyInternal => int.TryParse(Parse(this.definition.HealingMagicPotency), out var val) ? val : 0; } \ No newline at end of file diff --git a/NetStone/NetStone.xml b/NetStone/NetStone.xml index 83d3b7c..09cc189 100644 --- a/NetStone/NetStone.xml +++ b/NetStone/NetStone.xml @@ -2035,7 +2035,7 @@ This characters' Piety value. - + This characters' Craftmanship value.