Skip to content

Commit

Permalink
Merge pull request #29 from xivapi/linkshells
Browse files Browse the repository at this point in the history
Add support for linkshells and CWLS
  • Loading branch information
Koenari authored Dec 23, 2024
2 parents c46511f + 7dfb708 commit 677d904
Show file tree
Hide file tree
Showing 33 changed files with 1,952 additions and 432 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET Core SDK 6.0.x
uses: actions/setup-dotnet@v1.7.2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Setup .NET Core SDK 3.1.x
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '3.1.x'
dotnet-version: |
8.0.x
6.0.x
3.1.x
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/manual-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
EXPECTED_VERSION: ${{inputs.version }}
EXPECTED_LUMINA_VERSION: ${{inputs.lumina-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ jobs:
EXPECTED_VERSION: ${{needs.tag.outputs.version }}
EXPECTED_LUMINA_VERSION: ${{needs.tag-lumina.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions NetStone.Test/NetStone.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
</ItemGroup>

Expand Down
149 changes: 147 additions & 2 deletions NetStone.Test/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using NetStone.Model.Parseables.Character;
using NetStone.Search.Character;
using NetStone.Search.FreeCompany;
using NetStone.Search.Linkshell;
using NetStone.StaticData;
using NUnit.Framework;
using SortKind = NetStone.Search.Character.SortKind;
Expand All @@ -18,6 +19,8 @@ public class Tests

private const string TestCharacterIdFull = "24471319";
private const string TestCharacterIdEureka = "14556736";
private const string TestLinkshell = "18577348462979918";
private const string TestCWLS = "097b99377634f9980eb0cf0b4ff6cf86807feb2c";
private const string TestCharacterIdEureka2 = "6787158";
private const string TestCharacterIdBare = "9426169";
private const string TestCharacterIdDoH = "42256897";
Expand Down Expand Up @@ -176,7 +179,7 @@ public async Task CheckFreeCompanyRecruiting()
Assert.AreEqual("Immortal Flames", fc.GrandCompany);
Assert.AreEqual("Bedge Lords", fc.Name);
Assert.AreEqual("«BEDGE»", fc.Tag);
Assert.AreEqual("Friendly FC with 24/7 buffs, events and a large FC house in Goblet. LF more new amiable Bedgers to join us! Check our Lodestone & come chat for details.", fc.Slogan);
Assert.IsTrue(fc.Slogan.StartsWith("Friendly FC with"));
Assert.AreEqual(new DateTime(2022, 12, 04, 19, 47, 07), fc.Formed);
Assert.GreaterOrEqual(fc.ActiveMemberCount, 50);
Assert.AreEqual(30, fc.Rank);
Expand Down Expand Up @@ -227,7 +230,7 @@ public async Task CheckFreeCompanyRecruiting()
Assert.IsTrue(fc.Focus.Dungeons.IsEnabled);

Assert.AreEqual("Guildhests", fc.Focus.Guildhests.Name);
Assert.IsTrue(fc.Focus.Guildhests.IsEnabled);
Assert.IsFalse(fc.Focus.Guildhests.IsEnabled);

Assert.AreEqual("Trials", fc.Focus.Trials.Name);
Assert.IsTrue(fc.Focus.Trials.IsEnabled);
Expand Down Expand Up @@ -559,4 +562,146 @@ public async Task CheckCharacterCollectableNotFound()
var minions = await this.lodestone.GetCharacterMinion("0");
Assert.IsNull(minions);
}

[Test]
public async Task CheckCrossworldLinkShell()
{
var cwls = await this.lodestone.GetCrossworldLinkshell(TestCWLS);
Assert.IsNotNull(cwls);
Assert.AreEqual("COR and Friends", cwls.Name);
Assert.AreEqual("Light", cwls.DataCenter);
Assert.AreEqual(2, cwls.NumPages);
while (cwls is not null)
{
foreach (var member in cwls.Members)
{
Console.WriteLine($"{member.Name} ({member.Rank}) {member.RankIcon}\n" +
$"\tId: {member.Id}\n" +
$"\tAvatar: {member.Avatar}\n" +
$"\tServer: {member.Server}\n" +
$"\tLS Rank: {member.LinkshellRank}\n" +
$"\tLS Rank Icon: {member.LinkshellRankIcon}");
}
cwls = await cwls.GetNextPage();
}
}

[Test]
public async Task CheckCrossworldLinkShellSearch()
{
var emptyQuery = new CrossworldLinkshellSearchQuery()
{
Name = "abcedfas",
};
var emptyResult = await this.lodestone.SearchCrossworldLinkshell(emptyQuery);
Assert.IsNotNull(emptyResult);
//Assert.False(emptyResult.HasResults);
var query = new CrossworldLinkshellSearchQuery()
{
Name = "Hell",
ActiveMembers = LinkshellSizeCategory.ElevenToThirty,
DataCenter = "Chaos",
Sorting = LinkshellSortKind.MemberCountDesc,
};
bool first = true;
var results = await this.lodestone.SearchCrossworldLinkshell(query);
Assert.IsNotNull(results);
Assert.True(results.HasResults);
Assert.AreEqual(2, results.NumPages);
while (results is not null)
{
foreach (var result in results.Results)
{
if (first)
{
first = false;
var shell = await result.GetCrossworldLinkshell();
Assert.IsNotNull(shell);
Assert.AreEqual(result.Name, shell.Name);
}
Console.WriteLine($"{result.Name} ({result.Id}): {result.ActiveMembers}\n");
}
results = await results.GetNextPage();
}
}

[Test]
public async Task CheckLinkshell()
{
var ls = await this.lodestone.GetLinkshell(TestLinkshell);
Assert.IsNotNull(ls);
Assert.AreEqual("CORshell", ls.Name);
Assert.AreEqual(2, ls.NumPages);
while (ls is not null)
{
foreach (var member in ls.Members)
{
Console.WriteLine($"{member.Name} ({member.Rank}) {member.RankIcon}\n" +
$"Id: {member.Id}\n" +
$"Avatar: {member.Avatar}\n" +
$"Server: {member.Server}\n" +
$"LS Rank: {member.LinkshellRank}\n" +
$"LS Rank Icon: {member.LinkshellRankIcon}");

}
ls = await ls.GetNextPage();
}

}

[Test]
public async Task CheckLinkShellSearch()
{
var emptyQuery = new LinkshellSearchQuery()
{
Name = "abcedfas",
};
var emptyResult = await this.lodestone.SearchLinkshell(emptyQuery);
Assert.IsNotNull(emptyResult);
Assert.False(emptyResult.HasResults);
var query = new LinkshellSearchQuery()
{
Name = "Hell",
ActiveMembers = LinkshellSizeCategory.ElevenToThirty,
DataCenter = "Chaos",
};
bool first = true;
var results = await this.lodestone.SearchLinkshell(query);
Assert.IsNotNull(results);
Assert.True(results.HasResults);
Assert.AreEqual(2, results.NumPages);
while (results is not null)
{
foreach (var result in results.Results)
{
if (first)
{
first = false;
var shell = await result.GetLinkshell();
Assert.IsNotNull(shell);
Assert.AreEqual(result.Name, shell.Name);
}
Console.WriteLine($"{result.Name} ({result.Id}): {result.ActiveMembers}\n");
}
results = await results.GetNextPage();
}
query = new LinkshellSearchQuery()
{
Name = "Hell",
ActiveMembers = LinkshellSizeCategory.ElevenToThirty,
HomeWorld = "Spriggan",
};
results = await this.lodestone.SearchLinkshell(query);
Assert.IsNotNull(results);
Assert.True(results.HasResults);
Assert.AreEqual(1, results.NumPages);
while (results is not null)
{
foreach (var result in results.Results)
{
Console.WriteLine($"{result.Name} ({result.Id}): {result.ActiveMembers}\n");
}
results = await results.GetNextPage();
}
}
}
32 changes: 32 additions & 0 deletions NetStone/Definitions/DefinitionsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Threading.Tasks;
using NetStone.Definitions.Model;
using NetStone.Definitions.Model.Character;
using NetStone.Definitions.Model.CWLS;
using NetStone.Definitions.Model.FreeCompany;
using NetStone.Definitions.Model.Linkshell;

namespace NetStone.Definitions;

Expand Down Expand Up @@ -83,6 +85,36 @@ public abstract class DefinitionsContainer : IDisposable
/// Definitions for Free company search
/// </summary>
public PagedDefinition<FreeCompanySearchEntryDefinition> FreeCompanySearch { get; protected set; }

/// <summary>
/// Definitions for cross world link shells
/// </summary>
public CrossworldLinkshellDefinition CrossworldLinkshell { get; protected set; }

/// <summary>
/// Definitions for cross world link shell members
/// </summary>
public PagedDefinition<CrossworldLinkshellMemberEntryDefinition> CrossworldLinkshellMember { get; protected set; }

/// <summary>
/// Definitions for cross world link shell searches
/// </summary>
public PagedDefinition<CrossworldLinkshellSearchEntryDefinition> CrossworldLinkshellSearch { get; protected set; }

/// <summary>
/// Definitions for link shells
/// </summary>
public LinkshellDefinition Linkshell { get; protected set; }

/// <summary>
/// Definitions for link shell members
/// </summary>
public PagedDefinition<LinkshellMemberEntryDefinition> LinkshellMember { get; protected set; }

/// <summary>
/// Definitions for link-shell searches
/// </summary>
public PagedDefinition<LinkshellSearchEntryDefinition> LinkshellSearch { get; protected set; }

#endregion

Expand Down
21 changes: 21 additions & 0 deletions NetStone/Definitions/Model/CWLS/CrossworldLinkshellDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Newtonsoft.Json;

namespace NetStone.Definitions.Model.CWLS;

/// <summary>
/// Definitions for cross world link shell
/// </summary>
public class CrossworldLinkshellDefinition : IDefinition
{
/// <summary>
/// Name
/// </summary>
[JsonProperty("NAME")]
public DefinitionsPack Name { get; set; }

/// <summary>
/// Name
/// </summary>
[JsonProperty("DC")]
public DefinitionsPack DataCenter { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Newtonsoft.Json;

namespace NetStone.Definitions.Model.CWLS;


/// <summary>
///
/// </summary>
public class CrossworldLinkshellMemberEntryDefinition : PagedEntryDefinition
{
/// <summary>
/// Avatar
/// </summary>
[JsonProperty("AVATAR")] public DefinitionsPack Avatar { get; set; }

/// <summary>
/// ID
/// </summary>
[JsonProperty("ID")] public DefinitionsPack Id { get; set; }

/// <summary>
/// Name
/// </summary>
[JsonProperty("NAME")] public DefinitionsPack Name { get; set; }

/// <summary>
/// Rank
/// </summary>
[JsonProperty("RANK")] public DefinitionsPack Rank { get; set; }

/// <summary>
/// Rank Icon
/// </summary>
[JsonProperty("RANK_ICON")] public DefinitionsPack RankIcon { get; set; }

/// <summary>
/// Linkshell rank
/// </summary>
[JsonProperty("LINKSHELL_RANK")] public DefinitionsPack LinkshellRank { get; set; }

/// <summary>
/// Linkshell rank Icon
/// </summary>
[JsonProperty("LINKSHELL_RANK_ICON")] public DefinitionsPack LinkshellRankIcon { get; set; }

/// <summary>
/// Server
/// </summary>
[JsonProperty("SERVER")] public DefinitionsPack Server { get; set; }
}
Loading

0 comments on commit 677d904

Please sign in to comment.