Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DOTA2/MatchPlayer & Test (Issue-120) #121

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/Steam.Models/DOTA2/MatchPlayerAdditionalUnitModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Steam.Models.DOTA2
{
public class MatchPlayerAdditionalUnitModel
{
public string Unitname { get; set; }

public uint Item0 { get; set; }

public uint Item1 { get; set; }

public uint Item2 { get; set; }

public uint Item3 { get; set; }

public uint Item4 { get; set; }

public uint Item5 { get; set; }

public uint Backpack0 { get; set; }

public uint Backpack1 { get; set; }

public uint Backpack2 { get; set; }

public uint ItemNeutral { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/Steam.Models/DOTA2/MatchPlayerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public class MatchPlayerModel

public uint GoldSpent { get; set; }

public uint NetWorth { get; set; }

public uint AghanimsScepter { get; set; }

public uint AghanimsShard { get; set; }

public uint Moonshard { get; set; }

public uint HeroDamage { get; set; }

public uint ScaledHeroDamage { get; set; }
Expand All @@ -65,5 +73,7 @@ public class MatchPlayerModel
public uint Level { get; set; }

public IReadOnlyCollection<MatchPlayerAbilityUpgradeModel> AbilityUpgrades { get; set; }

public IReadOnlyCollection<MatchPlayerAdditionalUnitModel> AdditionalUnits { get; set; }
}
}
11 changes: 8 additions & 3 deletions src/Steam.UnitTests/DOTA2MatchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ public async Task GetLiveLeagueGamesAsync_Should_Succeed()
[Fact]
public async Task GetMatchDetailsAsync_Should_Succeed()
{
var response = await steamInterface.GetMatchDetailsAsync(5327512468);
Assert.NotNull(response);
Assert.NotNull(response.Data);
//Old game without some params
var responseOld = await steamInterface.GetMatchDetailsAsync(5327512468);
//game played - 31.10.2021
var responseNew = await steamInterface.GetMatchDetailsAsync(6249820594);
Assert.NotNull(responseOld);
Assert.NotNull(responseOld.Data);
Assert.NotNull(responseNew);
Assert.NotNull(responseNew.Data);
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion src/Steam.UnitTests/SteamUserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using SteamWebAPI2.Utilities;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -80,7 +81,9 @@ public async Task ResolveVanityUrlAsync_Should_Succeed()
[Fact]
public async Task GetCommunityProfileAsync_Should_Succeed()
{
var response = await steamInterface.GetCommunityProfileAsync(76561198050013009);
//for other cultures (for example ru) automaper will not be able to convert floating point numbers and will throw an error
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("en");
var response = await steamInterface.GetCommunityProfileAsync(76561198064401017);
Assert.NotNull(response);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/SteamWebAPI2/Mappings/DOTA2MatchProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public DOTA2MatchProfile()
CreateMap<MatchDetailResult, MatchDetailModel>()
.ForMember(dest => dest.StartTime, opts => opts.MapFrom(src => src.StartTime.ToDateTime()));
CreateMap<MatchPlayer, MatchPlayerModel>();
CreateMap<MatchPlayerAdditionalUnit, MatchPlayerAdditionalUnitModel>();
CreateMap<MatchPlayerAbilityUpgrade, MatchPlayerAbilityUpgradeModel>();
CreateMap<MatchPickBan, MatchPickBanModel>();
CreateMap<MatchDetailResultContainer, MatchDetailModel>().ConvertUsing((src, dest, context) =>
Expand Down
49 changes: 49 additions & 0 deletions src/SteamWebAPI2/Models/DOTA2/MatchDetailResultContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,41 @@ internal class MatchPlayerAbilityUpgrade
public uint Level { get; set; }
}

internal class MatchPlayerAdditionalUnit
{
public string Unitname { get; set; }

[JsonProperty(PropertyName = "item_0")]
public uint Item0 { get; set; }

[JsonProperty(PropertyName = "item_1")]
public uint Item1 { get; set; }

[JsonProperty(PropertyName = "item_2")]
public uint Item2 { get; set; }

[JsonProperty(PropertyName = "item_3")]
public uint Item3 { get; set; }

[JsonProperty(PropertyName = "item_4")]
public uint Item4 { get; set; }

[JsonProperty(PropertyName = "item_5")]
public uint Item5 { get; set; }

[JsonProperty(PropertyName = "backpack_0")]
public uint Backpack0 { get; set; }

[JsonProperty(PropertyName = "backpack_1")]
public uint Backpack1 { get; set; }

[JsonProperty(PropertyName = "backpack_2")]
public uint Backpack2 { get; set; }

[JsonProperty(PropertyName = "item_neutral")]
public uint ItemNeutral { get; set; }
}

internal class MatchPlayer
{
[JsonProperty(PropertyName = "account_id")]
Expand Down Expand Up @@ -74,6 +109,17 @@ internal class MatchPlayer
[JsonProperty(PropertyName = "gold_spent")]
public uint GoldSpent { get; set; }

[JsonProperty(PropertyName = "net_worth")]
public uint NetWorth { get; set; }

[JsonProperty(PropertyName = "aghanims_scepter")]
public uint AghanimsScepter { get; set; }

[JsonProperty(PropertyName = "aghanims_shard")]
public uint AghanimsShard { get; set; }

public uint Moonshard { get; set; }

[JsonProperty(PropertyName = "hero_damage")]
public uint HeroDamage { get; set; }

Expand All @@ -96,6 +142,9 @@ internal class MatchPlayer

[JsonProperty(PropertyName = "ability_upgrades")]
public IList<MatchPlayerAbilityUpgrade> AbilityUpgrades { get; set; }

[JsonProperty(PropertyName = "additional_units")]
public IList<MatchPlayerAdditionalUnit> AdditionalUnits { get; set; }
}

internal class MatchPickBan
Expand Down