Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
More Exception wrapping, add Sponsor, small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Soneliem committed Jun 30, 2022
1 parent 78910e0 commit 8d71178
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 114 deletions.
13 changes: 13 additions & 0 deletions WAIUA/Controls/OverlayControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@
</Button>
</StackPanel>
</Border>
<Ellipse Height="55"
Width="55"
Margin="10"
ToolTipService.InitialShowDelay="0"
ToolTip="Mango">
<Ellipse.Effect>
<DropShadowEffect BlurRadius="5" ShadowDepth="3" />
</Ellipse.Effect>
<Ellipse.Fill>
<ImageBrush
ImageSource="https://cdn.discordapp.com/avatars/875346957432938556/c9c93e480b244db630e34879a330ead1.webp" />
</Ellipse.Fill>
</Ellipse>
<Ellipse Height="55"
Width="55"
Margin="10"
Expand Down
138 changes: 70 additions & 68 deletions WAIUA/Helpers/LiveMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,42 +141,42 @@ public async Task<List<Player>> LiveMatchOutputAsync(UpdateProgress updateProgre

foreach (var riotPlayer in matchIdInfo.AllyTeam.Players)
{
try
{

async Task<Player> GetPlayerInfo()
{
Player player = new();
try
{
var t1 = GetCardAsync(riotPlayer.PlayerIdentity.PlayerCardId, index);
var t3 = GetMatchHistoryAsync(riotPlayer.Subject);
var t4 = GetPlayerHistoryAsync(riotPlayer.Subject, seasonData);
// var t5 = GetPreSkinInfoAsync(index);
var t6 = GetPresenceInfoAsync(riotPlayer.Subject, presencesResponse);

var t1 = GetCardAsync(riotPlayer.PlayerIdentity.PlayerCardId, index);
var t3 = GetMatchHistoryAsync(riotPlayer.Subject);
var t4 = GetPlayerHistoryAsync(riotPlayer.Subject, seasonData);
// var t5 = GetPreSkinInfoAsync(index);
var t6 = GetPresenceInfoAsync(riotPlayer.Subject, presencesResponse);

await Task.WhenAll(t1, t3, t4, t6).ConfigureAwait(false);

player.IdentityData = t1.Result;
player.MatchHistoryData = t3.Result;
player.RankData = t4.Result;
// player.SkinData = t5.Result;
player.PlayerUiData = t6.Result;
player.IgnData = await GetIgcUsernameAsync(riotPlayer.Subject, riotPlayer.PlayerIdentity.Incognito, player.PlayerUiData.PartyUuid).ConfigureAwait(false);
player.AccountLevel = !riotPlayer.PlayerIdentity.HideAccountLevel ? riotPlayer.PlayerIdentity.AccountLevel.ToString() : "-";
player.TeamId = "Blue";
player.Active = Visibility.Visible;
await Task.WhenAll(t1, t3, t4, t6).ConfigureAwait(false);

player.IdentityData = t1.Result;
player.MatchHistoryData = t3.Result;
player.RankData = t4.Result;
// player.SkinData = t5.Result;
player.PlayerUiData = t6.Result;
player.IgnData = await GetIgcUsernameAsync(riotPlayer.Subject, riotPlayer.PlayerIdentity.Incognito, player.PlayerUiData.PartyUuid).ConfigureAwait(false);
player.AccountLevel = !riotPlayer.PlayerIdentity.HideAccountLevel ? riotPlayer.PlayerIdentity.AccountLevel.ToString() : "-";
player.TeamId = "Blue";
player.Active = Visibility.Visible;
}
catch(Exception e)
{
Constants.Log.Error("GetPlayerInfo() (PRE) failed for player {index}: {e}", index, e);
}
return player;
}

playerTasks.Add(GetPlayerInfo());
}
catch(Exception e)
{
Constants.Log.Error("GetPlayerInfo() (PRE) failed for player {index}: {e}", index, e);
}
finally
{
index++;
}


index++;

}

var gamePodId = matchIdInfo.GamePodId;
Expand All @@ -197,14 +197,14 @@ async Task<Player> GetPlayerInfo()

foreach (var riotPlayer in matchIdInfo.Players)
{
try
{
if (!riotPlayer.IsCoach)

if (riotPlayer.IsCoach) continue;

async Task<Player> GetPlayerInfo()
{
async Task<Player> GetPlayerInfo()
Player player = new();
try
{
Player player = new();

var t1 = GetAgentInfoAsync(riotPlayer.CharacterId);
// var t2 = GetCompHistoryAsync(riotPlayer.Subject);
var t3 = GetPlayerHistoryAsync(riotPlayer.Subject, seasonData);
Expand All @@ -224,20 +224,19 @@ async Task<Player> GetPlayerInfo()
player.AccountLevel = !riotPlayer.PlayerIdentity.HideAccountLevel ? riotPlayer.PlayerIdentity.AccountLevel.ToString() : "-";
player.TeamId = riotPlayer.TeamId;
player.Active = Visibility.Visible;
return player;
}

playerTasks.Add(GetPlayerInfo());
catch (Exception e)
{
Constants.Log.Error("GetPlayerInfo() (CORE) failed for player {index}: {e}", index, e);
}
return player;
}
}
catch (Exception e)
{
Constants.Log.Error("GetPlayerInfo() (CORE) failed for player {index}: {e}", index, e);
}
finally
{
index++;
}

playerTasks.Add(GetPlayerInfo());


index++;

}

var gamePodId = matchIdInfo.GamePodId;
Expand Down Expand Up @@ -278,9 +277,9 @@ async Task<Player> GetPlayerInfo()
for (var i = 0; i < playerList.Count; i++) playerList[i].PlayerUiData.PartyColour = newArray[i];
updateProgress(100);
}
catch (Exception)
catch (Exception e)
{
Constants.Log.Error("LiveMatchOutputAsync() party colour failed.");
Constants.Log.Error("LiveMatchOutputAsync() party colour failed: {e}", e);
}

return playerList;
Expand Down Expand Up @@ -386,22 +385,17 @@ private static async Task<IdentityData> GetAgentInfoAsync(Guid agentid)

private static async Task<IdentityData> GetCardAsync(Guid cardid, sbyte index)
{
IdentityData identityData = new();
if (cardid != Guid.Empty)
{
var cards = JsonSerializer.Deserialize<Dictionary<Guid, Uri>>(await File.ReadAllTextAsync(Constants.LocalAppDataPath + "\\ValAPI\\cards.txt").ConfigureAwait(false));
cards.TryGetValue(cardid, out var card);
identityData.Image = card;
identityData.Name = Resources.Player + " " + (index + 1);
}
else
{
Constants.Log.Error("GetCardAsync Failed: CardID is empty");
identityData.Image = null;
identityData.Name = "";
return new IdentityData()
{
Image = card, Name = Resources.Player + " " + (index + 1)
};
}

return identityData;
Constants.Log.Error("GetCardAsync Failed: CardID is empty");
return new IdentityData();
}

private static async Task<SkinData> GetMatchSkinInfoAsync(sbyte playerno)
Expand All @@ -411,15 +405,23 @@ private static async Task<SkinData> GetMatchSkinInfoAsync(sbyte playerno)
true).ConfigureAwait(false);
if (response.IsSuccessful)
{
var content = JsonSerializer.Deserialize<MatchLoadoutsResponse>(response.Content);
var vandalchroma = content.Loadouts[playerno].Loadout
.Items["9c82e19d-4575-0200-1a81-3eacf00cf872"].Sockets["3ad1b2b2-acdb-4524-852f-954a76ddae0a"]
.Item.Id;
var phantomchroma = content.Loadouts[playerno].Loadout
.Items["ee8e8d15-496b-07ac-e5f6-8fae5d4c7b1a"].Sockets["3ad1b2b2-acdb-4524-852f-954a76ddae0a"]
.Item.Id;

return await GetSkinInfoAsync(phantomchroma, vandalchroma);
try
{
var content = JsonSerializer.Deserialize<MatchLoadoutsResponse>(response.Content);
var vandalchroma = content.Loadouts[playerno].Loadout
.Items["9c82e19d-4575-0200-1a81-3eacf00cf872"].Sockets["3ad1b2b2-acdb-4524-852f-954a76ddae0a"]
.Item.Id;
var phantomchroma = content.Loadouts[playerno].Loadout
.Items["ee8e8d15-496b-07ac-e5f6-8fae5d4c7b1a"].Sockets["3ad1b2b2-acdb-4524-852f-954a76ddae0a"]
.Item.Id;

return await GetSkinInfoAsync(phantomchroma, vandalchroma);
}
catch (Exception e)
{
Constants.Log.Error("GetMatchSkinInfoAsync Failed: " + e.Message);
return new SkinData();
}
}

Constants.Log.Error("GetMatchSkinInfoAsync Failed: {e}", response.ErrorException);
Expand Down
14 changes: 11 additions & 3 deletions WAIUA/Helpers/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ public static async Task<string> GetNameServiceGetUsernameAsync(Guid puuid)
var response = await client.ExecutePutAsync(request).ConfigureAwait(false);
if (response.IsSuccessful)
{
var incorrectContent = response.Content.Replace("[", string.Empty).Replace("]", string.Empty).Replace("\n", string.Empty);
var content = JsonSerializer.Deserialize<NameServiceResponse>(incorrectContent);
return content.GameName + "#" + content.TagLine;
try
{
var incorrectContent = response.Content.Replace("[", string.Empty).Replace("]", string.Empty).Replace("\n", string.Empty);
var content = JsonSerializer.Deserialize<NameServiceResponse>(incorrectContent);
return content.GameName + "#" + content.TagLine;
}
catch (Exception e)
{
Constants.Log.Error("GetNameServiceGetUsernameAsync Failed: {e}", e);
return "";
}
}

Constants.Log.Error("GetNameServiceGetUsernameAsync Failed: {e}", response.ErrorException);
Expand Down
82 changes: 40 additions & 42 deletions WAIUA/Objects/RiotAPIObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class XpResponse
{
[JsonPropertyName("Version")] public long Version { get; set; }

[JsonPropertyName("Subject")] public Guid Subject { get; set; }
[JsonPropertyName("Subject")] public string Subject { get; set; }

[JsonPropertyName("Progress")] public Progress Progress { get; set; }

Expand All @@ -24,7 +24,7 @@ public class XpResponse

public class History
{
[JsonPropertyName("ID")] public Guid Id { get; set; }
[JsonPropertyName("ID")] public string Id { get; set; }

[JsonPropertyName("MatchStart")] public string MatchStart { get; set; }

Expand Down Expand Up @@ -394,17 +394,17 @@ public class CompetitiveUpdatesResponse

[JsonPropertyName("Subject")] public Guid Subject { get; set; }

[JsonPropertyName("Matches")] public CompetitiveUpdatesMatch[] Matches { get; set; }
[JsonPropertyName("Matches")] public CompetitiveUpdates[] Matches { get; set; }
}

public class CompetitiveUpdatesMatch
public class CompetitiveUpdates
{
[JsonPropertyName("MatchID")] public Guid MatchId { get; set; }

[JsonPropertyName("MapID")] public string MapId { get; set; }

[JsonPropertyName("SeasonID"), JsonIgnore]
public Guid? SeasonId { get; set; }
public string? SeasonId { get; set; }

[JsonPropertyName("MatchStartTime")] public long MatchStartTime { get; set; }

Expand Down Expand Up @@ -442,7 +442,7 @@ public class MmrResponse
[JsonPropertyName("QueueSkills")] public QueueSkills QueueSkills { get; set; }

[JsonPropertyName("LatestCompetitiveUpdate")]
public LatestCompetitiveUpdate LatestCompetitiveUpdate { get; set; }
public CompetitiveUpdates LatestCompetitiveUpdate { get; set; }

[JsonPropertyName("IsLeaderboardAnonymized")]
public bool IsLeaderboardAnonymized { get; set; }
Expand All @@ -451,37 +451,37 @@ public class MmrResponse
public bool IsActRankBadgeHidden { get; set; }
}

public class LatestCompetitiveUpdate
{
[JsonPropertyName("MatchID")] public Guid MatchId { get; set; }

[JsonPropertyName("MapID")] public string MapId { get; set; }

[JsonPropertyName("SeasonID")] public Guid SeasonId { get; set; }

[JsonPropertyName("MatchStartTime")] public long MatchStartTime { get; set; }

[JsonPropertyName("TierAfterUpdate")] public int TierAfterUpdate { get; set; }

[JsonPropertyName("TierBeforeUpdate")] public int TierBeforeUpdate { get; set; }

[JsonPropertyName("RankedRatingAfterUpdate")]
public int RankedRatingAfterUpdate { get; set; }

[JsonPropertyName("RankedRatingBeforeUpdate")]
public int RankedRatingBeforeUpdate { get; set; }

[JsonPropertyName("RankedRatingEarned")]
public int RankedRatingEarned { get; set; }

[JsonPropertyName("RankedRatingPerformanceBonus")]
public int RankedRatingPerformanceBonus { get; set; }

[JsonPropertyName("CompetitiveMovement")]
public string CompetitiveMovement { get; set; }

[JsonPropertyName("AFKPenalty")] public int AfkPenalty { get; set; }
}
// public class LatestCompetitiveUpdate
// {
// [JsonPropertyName("MatchID")] public Guid MatchId { get; set; }
//
// [JsonPropertyName("MapID")] public string MapId { get; set; }
//
// [JsonPropertyName("SeasonID")] public Guid SeasonId { get; set; }
//
// [JsonPropertyName("MatchStartTime")] public long MatchStartTime { get; set; }
//
// [JsonPropertyName("TierAfterUpdate")] public int TierAfterUpdate { get; set; }
//
// [JsonPropertyName("TierBeforeUpdate")] public int TierBeforeUpdate { get; set; }
//
// [JsonPropertyName("RankedRatingAfterUpdate")]
// public int RankedRatingAfterUpdate { get; set; }
//
// [JsonPropertyName("RankedRatingBeforeUpdate")]
// public int RankedRatingBeforeUpdate { get; set; }
//
// [JsonPropertyName("RankedRatingEarned")]
// public int RankedRatingEarned { get; set; }
//
// [JsonPropertyName("RankedRatingPerformanceBonus")]
// public int RankedRatingPerformanceBonus { get; set; }
//
// [JsonPropertyName("CompetitiveMovement")]
// public string CompetitiveMovement { get; set; }
//
// [JsonPropertyName("AFKPenalty")] public int AfkPenalty { get; set; }
// }

public class QueueSkills
{
Expand Down Expand Up @@ -528,7 +528,7 @@ public class SeasonalInfoBySeasonId

public class ActInfo
{
[JsonPropertyName("SeasonID")] public Guid SeasonId { get; set; }
[JsonPropertyName("SeasonID")] public string SeasonId { get; set; }

[JsonPropertyName("NumberOfWins")] public int NumberOfWins { get; set; }

Expand Down Expand Up @@ -647,8 +647,7 @@ public class Event

[JsonPropertyName("DevelopmentOnly")] public bool DevelopmentOnly { get; set; }

[JsonPropertyName("Type")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("Type"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Type { get; set; }
}

Expand Down Expand Up @@ -697,8 +696,7 @@ public class Presence

[JsonPropertyName("summary")] public string Summary { get; set; }

[JsonPropertyName("time")]
[JsonIgnore]
[JsonPropertyName("time"), JsonIgnore]
public long Time { get; set; }
}

Expand Down
2 changes: 1 addition & 1 deletion WAIUA/VersionInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<version>2.0.0.2</version>
<url>https://github.com/Soneliem/WAIUA/releases/latest/download/WAIUA.exe</url>
<changelog>https://github.com/Soneliem/WAIUA/releases/latest</changelog>
<mandatory>true</mandatory>
<mandatory>false</mandatory>
</item>
Loading

0 comments on commit 8d71178

Please sign in to comment.