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

feat: Add a command to show player statistics #49

Merged
merged 3 commits into from
Sep 2, 2024
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
7 changes: 7 additions & 0 deletions src/Application/Common/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace CTF.Application.Common.Extensions;

public static class DateTimeExtensions
{
public static string GetDateWithStandardFormat(this DateTime dateTime)
=> dateTime.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
}
30 changes: 30 additions & 0 deletions src/Application/Players/Accounts/Systems/PlayerStatsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace CTF.Application.Players.Accounts.Systems;

public class PlayerStatsSystem(IDialogService dialogService) : ISystem
{
[PlayerCommand("stats")]
public void ShowStats(Player player)
{
PlayerInfo playerInfo = player.GetComponent<AccountComponent>().PlayerInfo;
var content =
$"""
Kills for Round: {playerInfo.StatsPerRound.Kills}
Deaths for Round: {playerInfo.StatsPerRound.Deaths}
Killing Spree for Round: {playerInfo.StatsPerRound.KillingSpree}
Points: {playerInfo.StatsPerRound.Points}/100
Max Killing Spree: {playerInfo.MaxKillingSpree}
Total Kills: {playerInfo.TotalKills}
Total Deaths: {playerInfo.TotalDeaths}
Brought Flags: {playerInfo.BroughtFlags}
Captured Flags: {playerInfo.CapturedFlags}
Dropped Flags: {playerInfo.DroppedFlags}
Returned Flags: {playerInfo.ReturnedFlags}
HeadShots: {playerInfo.HeadShots}
Role: {playerInfo.RoleId}
Rank: {playerInfo.RankId}
Registration Date: {playerInfo.CreatedAt.GetDateWithStandardFormat()}
""";
var dialog = new MessageDialog($"Stats: {playerInfo.Name}", content, "Close");
dialogService.ShowAsync(player, dialog);
}
}
1 change: 1 addition & 0 deletions src/Application/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
global using CTF.Application.Common.NativeObjects;
global using CTF.Application.Common.Services;
global using CTF.Application.Common.Resources;
global using CTF.Application.Common.Extensions;
global using CTF.Application.Players.Accounts;
global using CTF.Application.Players.Ranks;
global using CTF.Application.Teams;
Expand Down
Loading