Skip to content

Commit

Permalink
feat: send message to all players when a headshot is made (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 authored Dec 27, 2024
1 parent c802541 commit 4b754cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/Application/Common/Resources/Messages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Application/Common/Resources/Messages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
<data name="HasCapturedFlag" xml:space="preserve">
<value>You cannot use this command because you are the flag carrier</value>
</data>
<data name="HeadshotToPlayer" xml:space="preserve">
<value>{PlayerName1} landed a headshot with a sniper at {PlayerName2}</value>
</data>
<data name="InsufficientCoins" xml:space="preserve">
<value>You do not have enough coins to obtain this combo</value>
</data>
Expand Down
12 changes: 9 additions & 3 deletions src/Application/Players/HeadShotSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace CTF.Application.Players;

public class HeadShotSystem(IPlayerRepository playerRepository) : ISystem
public class HeadShotSystem(
IPlayerRepository playerRepository,
IWorldService worldService) : ISystem
{
/// <summary>
/// This callback is called when a player takes damage.
Expand Down Expand Up @@ -37,9 +39,13 @@ public void OnPlayerTakeDamage(Player player, Player issuer, float amount, Weapo
issuerInfo.AddHeadShots();
issuerInfo.StatsPerRound.AddCoins(5);
playerRepository.UpdateHeadShots(issuerInfo);
issuer.GameText("Headshot +1", 3000, 3);
issuer.SendClientMessage(Color.Yellow, "Headshot +1");
player.Health = 0;
var message = Smart.Format(Messages.HeadshotToPlayer, new
{
PlayerName1 = issuer.Name,
PlayerName2 = player.Name
});
worldService.SendClientMessage(Color.Yellow, message);
}
}
}

0 comments on commit 4b754cc

Please sign in to comment.