Skip to content

Commit

Permalink
Fix parsing of active times in FC search
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenari committed Oct 20, 2024
1 parent a5f7b8c commit 74787cf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions NetStone.Test/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public async Task TestFreeCompanySearch()
{
var query = new FreeCompanySearchQuery
{
Name = "Crystal",
Name = "new",
DataCenter = "Crystal",
Housing = Housing.EstateBuilt,
GrandCompany = GrandCompany.ImmortalFlames,
};

var page = await this.lodestone.SearchFreeCompany(query);
Expand All @@ -280,7 +280,7 @@ public async Task TestFreeCompanySearch()
foreach (var searchResult in page.Results)
{
Console.WriteLine(
$"{page.CurrentPage}({cPages}) - {cResults} - {searchResult.Name} - {searchResult.Id}");
$"{page.CurrentPage}({cPages}) - {cResults} - {searchResult.Name} - {searchResult.ActiveMembers} - {searchResult.Id} - {searchResult.Server} - {searchResult.Formed} - {searchResult.Active} - {searchResult.RecruitmentOpen}");
cResults++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class FreeCompanySearchEntry : LodestoneParseable

///
public FreeCompanySearchEntry(LodestoneClient client, HtmlNode rootNode,
FreeCompanySearchEntryDefinition definition) : base(rootNode)
FreeCompanySearchEntryDefinition definition) : base(rootNode)
{
this.client = client;
this.definition = definition;
Expand Down Expand Up @@ -56,15 +56,21 @@ public FreeCompanySearchEntry(LodestoneClient client, HtmlNode rootNode,
/// <summary>
/// Active status
/// </summary>
public ActiveTimes Active => Parse(this.definition.Active) switch
public ActiveTimes Active => this.ActiveText switch
{
"Always" => ActiveTimes.Always,
"Weekends Only" => ActiveTimes.WeekendsOnly,
"Weekdays Only" => ActiveTimes.WeekdaysOnly,
"Always" => ActiveTimes.Always,
"Weekends" => ActiveTimes.WeekendsOnly,
"Weekdays" => ActiveTimes.WeekdaysOnly,
"Not specified" => ActiveTimes.All,
_ => throw new ArgumentOutOfRangeException(),
{ } s => throw new ArgumentOutOfRangeException(s),
};

/// <summary>
/// Full text of active times
/// </summary>
//ToDo: fix regex
public string ActiveText => ParseInnerText(this.definition.Active)[8..];

/// <summary>
/// Active member count
/// </summary>
Expand All @@ -86,9 +92,9 @@ public FreeCompanySearchEntry(LodestoneClient client, HtmlNode rootNode,
public Housing EstateBuild => Parse(this.definition.EstateBuilt) switch
{
"No Estate or Plot" => Housing.NoEstateOrPlot,
"Estate Built" => Housing.EstateBuilt,
"Plot Only" => Housing.PlotOnly,
_ => throw new ArgumentOutOfRangeException(),
"Estate Built" => Housing.EstateBuilt,
"Plot Only" => Housing.PlotOnly,
_ => throw new ArgumentOutOfRangeException(),
};

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions NetStone/NetStone.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74787cf

Please sign in to comment.