-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from MrDave1999/feat/TeamStats
feat: Allow players to view statistics of both teams (Alpha and Beta)
- Loading branch information
Showing
4 changed files
with
100 additions
and
10 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,50 @@ | ||
namespace CTF.Application.Teams.Systems; | ||
|
||
public class TeamStatsSystem( | ||
IDialogService dialogService, | ||
TeamTextDrawRenderer teamTextDrawRenderer) : ISystem | ||
{ | ||
[Event] | ||
public void OnPlayerSpawn(Player player) | ||
{ | ||
teamTextDrawRenderer.Show(player); | ||
} | ||
|
||
[Event] | ||
public void OnPlayerDeath(Player deadPlayer, Player killer, Weapon reason) | ||
{ | ||
PlayerInfo deadPlayerInfo = deadPlayer.GetInfo(); | ||
deadPlayerInfo.Team.StatsPerRound.AddDeaths(); | ||
|
||
if (killer.IsInvalidPlayer()) | ||
return; | ||
|
||
PlayerInfo killerInfo = killer.GetInfo(); | ||
killerInfo.Team.StatsPerRound.AddKills(); | ||
} | ||
|
||
[PlayerCommand("tstats")] | ||
public void ShowStats(Player player) | ||
{ | ||
Team alphaTeam = Team.Alpha; | ||
Team betaTeam = Team.Beta; | ||
var content = | ||
$""" | ||
{alphaTeam.ColorHex}>>> Alpha Team: | ||
Members: {alphaTeam.Members.Count} | ||
Score: {alphaTeam.StatsPerRound.Score} | ||
Kills: {alphaTeam.StatsPerRound.Kills} | ||
Deaths: {alphaTeam.StatsPerRound.Deaths} | ||
Flag captured by: {alphaTeam.Flag.CarrierName} | ||
{betaTeam.ColorHex}>>> Beta Team: | ||
Members: {betaTeam.Members.Count} | ||
Score: {betaTeam.StatsPerRound.Score} | ||
Kills: {betaTeam.StatsPerRound.Kills} | ||
Deaths: {betaTeam.StatsPerRound.Deaths} | ||
Flag captured by: {betaTeam.Flag.CarrierName} | ||
"""; | ||
var dialog = new MessageDialog("Team Stats", content, "Close"); | ||
dialogService.ShowAsync(player, dialog); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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