From ffff0dad3476e1b2c5554790f4db053875758b45 Mon Sep 17 00:00:00 2001 From: Koenari Date: Sat, 15 Jun 2024 21:49:08 +0200 Subject: [PATCH] add Race, Tribe and Gender --- NetStone.Test/Tests.cs | 4 ++ NetStone/Model/LodestoneParseable.cs | 2 +- .../Character/LodestoneCharacter.cs | 31 ++++++++- NetStone/NetStone.xml | 69 ++++++++++++------- 4 files changed, 81 insertions(+), 25 deletions(-) diff --git a/NetStone.Test/Tests.cs b/NetStone.Test/Tests.cs index b01477f..760745e 100644 --- a/NetStone.Test/Tests.cs +++ b/NetStone.Test/Tests.cs @@ -2,6 +2,7 @@ using System.IO; using System.Threading.Tasks; using NetStone.GameData.Packs; +using NetStone.Model.Parseables.Character; using NetStone.Model.Parseables.Character.Gear; using NetStone.Search.Character; using NetStone.Search.FreeCompany; @@ -229,6 +230,9 @@ public async Task CheckCharacterFull() Assert.AreEqual(chara.ToString(), "Arcane Disgea on Leviathan"); Assert.AreEqual(chara.Server, "Leviathan"); Assert.AreEqual(chara.Name, "Arcane Disgea"); + Assert.AreEqual("Miqo'te",chara.Race); + Assert.AreEqual("Seeker of the Sun", chara.Tribe); + Assert.AreEqual(LodestoneCharacter.FemaleChar, chara.Gender); Assert.True(chara.Bio.StartsWith( "This is a test of the emergency alert system.AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH")); Assert.AreEqual(chara.GuardianDeityName, "Menphina, the Lover"); diff --git a/NetStone/Model/LodestoneParseable.cs b/NetStone/Model/LodestoneParseable.cs index 7fba2ab..c80fdf5 100644 --- a/NetStone/Model/LodestoneParseable.cs +++ b/NetStone/Model/LodestoneParseable.cs @@ -20,7 +20,7 @@ public abstract class LodestoneParseable protected readonly HtmlNode RootNode; /// - /// Constructs a instance of parseable data for given node + /// Constructs an instance of parseable data for given node /// /// protected LodestoneParseable(HtmlNode rootNode) diff --git a/NetStone/Model/Parseables/Character/LodestoneCharacter.cs b/NetStone/Model/Parseables/Character/LodestoneCharacter.cs index b55fdad..a02a12f 100644 --- a/NetStone/Model/Parseables/Character/LodestoneCharacter.cs +++ b/NetStone/Model/Parseables/Character/LodestoneCharacter.cs @@ -1,4 +1,5 @@ using System; +using System.Text.RegularExpressions; using System.Threading.Tasks; using HtmlAgilityPack; using NetStone.Definitions; @@ -15,6 +16,16 @@ namespace NetStone.Model.Parseables.Character; /// public class LodestoneCharacter : LodestoneParseable { + /// + /// Unicode character used to represent female characters + /// + public const char FemaleChar = '\u2640'; + + /// + /// Unicode character used to represent male characters + /// + public const char MaleChar = '\u2642'; + private readonly LodestoneClient client; private readonly string charId; @@ -109,12 +120,30 @@ public LodestoneCharacter(LodestoneClient client, HtmlNode rootNode, Definitions /// public SocialGroup? PvPTeam => new SocialGroup(this.RootNode, this.charDefinition.PvPTeam).GetOptional(); - //TODO: parse + + private GroupCollection RaceClanGenderRegex => ParseRegex(this.charDefinition.RaceClanGender); + /// /// String containing information on clan, race and gender /// + [Obsolete("Use Race, Tribe or Gender")] public string RaceClanGender => Parse(this.charDefinition.RaceClanGender); + /// + /// Race of the character + /// + public string Race => this.RaceClanGenderRegex["Race"].Value; + + /// + /// Tribe this chacracter belongs to + /// + public string Tribe => this.RaceClanGenderRegex["Tribe"].Value; + + /// + /// Character representing the characters gender and + /// + public char Gender => this.RaceClanGenderRegex["Gender"].Value[0]; + /// /// The server/world of the character. /// diff --git a/NetStone/NetStone.xml b/NetStone/NetStone.xml index fb003eb..a1a390d 100644 --- a/NetStone/NetStone.xml +++ b/NetStone/NetStone.xml @@ -124,49 +124,44 @@ HTML attribute that holds information. Only set if data is not in the inner text - + - Models the definition of one achievement entry for a character + Models the definition of the achievement list - + - Root node of entry + Total number of achievements earned by this character - + - Achievement name + Total achievement points earned by this character - + - Id of this achievement - - - - - Time when this achievement was earned + Full text displayed for this achievement - + - Info about pages + Models the definition of one achievement entry for a character - + - Total number of achievements earned by this character + Achievement name - + - Total achievement points earned by this character + Id of this achievement - + - Full text displayed for this achievement + Time when this achievement was earned @@ -1712,7 +1707,7 @@ - Constructs a instance of parseable data for given node + Constructs an instance of parseable data for given node @@ -1762,6 +1757,14 @@ Indicates to not parse attributes Text inside node + + + Get the inner html of a node + + Definition of node + Indicates to not parse attributes + Text inside node + Parse the InnerText via selector, then parse out regex groups. @@ -1874,7 +1877,7 @@ Holds information about a characters unlocked achievements - + Creates a new instance retrieving information about a characters unlocked achievements @@ -2505,6 +2508,16 @@ Container class holding information about a character and facilitating retrieval of further information. + + + Unicode character used to represent female characters + + + + + Unicode character used to represent male characters + + Container class for a parseable character page. @@ -2584,6 +2597,16 @@ String containing information on clan, race and gender + + + Race of the character + + + + + Character representing the characters gender and + + The server/world of the character.