-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
229 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@page "/player/{guid}" | ||
@using System.ComponentModel | ||
@using Humanizer | ||
@using Shared | ||
@inject HttpClient Http | ||
@inject NavigationManager NavigationManager | ||
@attribute [StreamRendering] | ||
|
||
<PageTitle>Player info</PageTitle> | ||
|
||
@if (playerData is null) | ||
{ | ||
<p>Loading...</p> | ||
} | ||
else | ||
{ | ||
<h1>@playerData.PlayerData.Username</h1> | ||
|
||
<p><b>Total estimated playtime:</b> @playerData.TotalEstimatedPlaytime.Humanize()</p> | ||
<p><small>Calculated by adding up the total time for each round played by the player.</small></p> | ||
<p><b>Total rounds played:</b> @playerData.TotalRoundsPlayed</p> | ||
<p><b>Total antag rounds played:</b> @playerData.TotalAntagRoundsPlayed</p> | ||
<p><b>Last seen:</b> @playerData.LastSeen.Humanize()</p> | ||
|
||
<h2>Characters</h2> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Character Name</th> | ||
<th>Times played</th> | ||
<th>Last played</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var character in playerData.Characters) | ||
{ | ||
if (character.CharacterName == "Unknown") | ||
{ | ||
continue; | ||
} | ||
|
||
// If this character contains a paranthesis, it's likely a ghost role like mouse (253), so we'll skip it. | ||
if (character.CharacterName.Contains("(")) | ||
{ | ||
continue; | ||
} | ||
|
||
<tr> | ||
<td>@character.CharacterName</td> | ||
<td>@character.RoundsPlayed</td> | ||
<td>@character.LastPlayed.Humanize()</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code{ | ||
[Parameter] public string Guid { get; set; } = string.Empty; | ||
|
||
private CollectedPlayerData? playerData; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
playerData = await Http.GetFromJsonAsync<CollectedPlayerData>($"api/Data/player-data?guid={Guid}"); | ||
playerData.Characters = playerData.Characters.OrderByDescending(x => x.RoundsPlayed).ToList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace Shared; | ||
|
||
/// <summary> | ||
/// Represents a player's data over all replays. | ||
/// </summary> | ||
public class CollectedPlayerData | ||
{ | ||
public PlayerData PlayerData { get; init; } = new(); | ||
|
||
/// <summary> | ||
/// Characters played by the player | ||
/// </summary> | ||
public List<CharacterData> Characters { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// Represents the estimated total playtime of the player. This is calculated by summing the roundtime of all replays the player has played. | ||
/// </summary> | ||
public TimeSpan TotalEstimatedPlaytime { get; init; } | ||
|
||
/// <summary> | ||
/// Represents the total amount of rounds the player has played. | ||
/// </summary> | ||
public int TotalRoundsPlayed { get; init; } | ||
|
||
/// <summary> | ||
/// Represents the total amount of antag rounds the player has played. | ||
/// </summary> | ||
public int TotalAntagRoundsPlayed { get; init; } | ||
|
||
public DateTime LastSeen { get; set; } = DateTime.MinValue; | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
if (obj is not CollectedPlayerData other) | ||
{ | ||
return false; | ||
} | ||
|
||
return PlayerData.Equals(other.PlayerData); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return PlayerData.GetHashCode(); | ||
} | ||
} | ||
|
||
public class CharacterData | ||
{ | ||
public string CharacterName { get; init; } | ||
public DateTime LastPlayed { get; set; } = DateTime.MinValue; | ||
public int RoundsPlayed { get; set; } | ||
} |