Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #286 from aspriddell/add-operator-info
Browse files Browse the repository at this point in the history
add operator metadata requests and extensions
  • Loading branch information
aspriddell authored Dec 28, 2021
2 parents 03f2d41 + 795171f commit 93d6889
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
10 changes: 10 additions & 0 deletions DragonFruit.Six.Api.Tests/Data/LegacyStatsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,23 @@ public async Task TestOperatorStats(string identifier, Platform platform, string
var selectedOperator = await Client.GetLegacyOperatorStatsAsync(account).ContinueWith(t => t.Result.SingleOrDefault(y => y.OperatorId == operatorIndex));

Assert.IsNotNull(selectedOperator);

Assert.GreaterOrEqual(selectedOperator.Kills, kills);
Assert.GreaterOrEqual(selectedOperator.Wins, wins);

Assert.IsTrue(selectedOperator.Kd > 0);
Assert.IsTrue(selectedOperator.Wl > 0);
}

[Test]
public async Task TestOperatorMetadata()
{
var operatorInfo = await Client.GetLegacyOperatorInfoAsync();

Assert.IsNotNull(operatorInfo);
Assert.GreaterOrEqual(operatorInfo.Count, 50);
}

[TestCase("603fc6ba-db16-4aba-81b2-e9f9601d7d24", Platform.PC, 300)]
public async Task PlayerLevelStatsTest(string identifier, Platform platform, int level)
{
Expand Down
17 changes: 7 additions & 10 deletions DragonFruit.Six.Api/Legacy/Entities/LegacyOperatorInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,26 @@ namespace DragonFruit.Six.Api.Legacy.Entities
[Serializable]
public class LegacyOperatorInfo
{
[JsonProperty("profile")]
internal string ProfileId { get; set; }

/// <summary>
/// Operator name (from datasheet/dictionary)
/// Operator name
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// Operator Identifier (from datasheet/dictionary)
/// Operator Identifier
/// </summary>
[JsonProperty("index")]
public string Index { get; set; }
public string OperatorId { get; set; }

/// <summary>
/// Logical order (from datasheet/dictionary)
/// Logical order
/// </summary>
[JsonProperty("ord")]
public ushort Order { get; set; }

/// <summary>
/// Operator Icon (from datasheet)
/// Operator Icon
/// </summary>
[JsonProperty("img")]
public string ImageUrl { get; set; }
Expand All @@ -50,13 +47,13 @@ public class LegacyOperatorInfo
public string Organisation { get; set; }

/// <summary>
/// The subtitle, as seen underneath the operator's name in game (from datasheet)
/// The subtitle, as seen underneath the operator's name in game
/// </summary>
[JsonProperty("sub")]
public string Subtitle { get; set; }

/// <summary>
/// The operator's use, attacker/defender (from datasheet)
/// The operator's use, attacker/defender
/// </summary>
[JsonProperty("type")]
public OperatorType Type { get; set; }
Expand Down
9 changes: 9 additions & 0 deletions DragonFruit.Six.Api/Legacy/LegacyStatsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public static Task<ILookup<string, LegacyOperatorStats>> GetLegacyOperatorStatsA
return GetLegacyStatsAsync(client, accounts, a => new LegacyStatsRequest(a, LegacyStatTypes.Operators), LegacyStatsDeserializer.DeserializeOperatorStats, token);
}

/// <summary>
/// Gets a <see cref="IReadOnlyCollection{T}"/> of legacy operator metadata entries
/// </summary>
/// <param name="client">The <see cref="ApiClient"/> to use</param>
public static Task<IReadOnlyCollection<LegacyOperatorInfo>> GetLegacyOperatorInfoAsync(this ApiClient client)
{
return client.PerformAsync<IReadOnlyCollection<LegacyOperatorInfo>>(new LegacyOperatorInfoRequest());
}

/// <summary>
/// Gets the <see cref="LegacyWeaponStats"/> for the <see cref="UbisoftAccount"/> provided
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions DragonFruit.Six.Api/Legacy/Requests/LegacyOperatorInfoRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Dragon6 API Copyright DragonFruit Network <inbox@dragonfruit.network>
// Licensed under Apache-2. Refer to the LICENSE file for more info

using DragonFruit.Data;

namespace DragonFruit.Six.Api.Legacy.Requests
{
public class LegacyOperatorInfoRequest : ApiRequest
{
public override string Path => $"{Endpoints.AssetsEndpoint}/data/operators.json";
}
}

0 comments on commit 93d6889

Please sign in to comment.