Skip to content

Commit

Permalink
Merge pull request #284 from MrDave1999/feat/issue-278
Browse files Browse the repository at this point in the history
feat: allow moderators to reset the flag to its base position
  • Loading branch information
MrDave1999 authored Jan 9, 2025
2 parents f251e00 + eb41c39 commit faafcf8
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
18 changes: 18 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.

6 changes: 6 additions & 0 deletions src/Application/Common/Resources/Messages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
<data name="InvalidAddCoins" xml:space="preserve">
<value>Coins must be between 1 to 100</value>
</data>
<data name="InvalidFlagColor" xml:space="preserve">
<value>Invalid color. Only 'red' and 'blue' are valid options for this command</value>
</data>
<data name="InvalidInterval" xml:space="preserve">
<value>The interval must be between 0 to {Max}</value>
</data>
Expand Down Expand Up @@ -420,6 +423,9 @@
<data name="ReportToAnotherPlayer" xml:space="preserve">
<value>{CurrentPlayer} reported to {TargetPlayer} [Reason: {Reason}]</value>
</data>
<data name="ResetFlagPosition" xml:space="preserve">
<value>{PlayerName} has reset the {ColorName} flag to its base position</value>
</data>
<data name="ResetPlayerStats" xml:space="preserve">
<value>{PlayerName} has reset their stats, such as score, kills and deaths</value>
</data>
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Beware! Enemies will see flag carriers on their radar as well!</value>
<data name="Moderator" xml:space="preserve">
<value>{Color1}/maps: {Color2}Displays a list of available maps in the game.
{Color1}/settimeleft: {Color2}Sets the remaining time for the current game session.
{Color1}/resetflag: {Color2}Resets the flag of a specific team to its base position.
{Color1}/startrt: {Color2}Starts the rotation timer for the current map.
{Color1}/stoprt: {Color2}Stops the rotation timer for the current map.
{Color1}/showrm: {Color2}Allows to show flag carriers on the radar map.
Expand Down
49 changes: 49 additions & 0 deletions src/Application/Teams/Flags/Systems/ResetFlagSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace CTF.Application.Teams.Flags.Systems;

public class ResetFlagSystem(
IWorldService worldService,
TeamPickupService teamPickupService,
TeamSoundsService teamSoundsService,
FlagAutoReturnTimer flagAutoReturnTimer) : ISystem
{
[PlayerCommand("resetflag")]
public void ResetToBasePosition(
Player player,
[CommandParameter(Name = "red/blue")]string color)
{
if (player.HasLowerRoleThan(RoleId.Moderator))
return;

Team team = color.ToLower() switch
{
"red" => Team.Alpha,
"blue" => Team.Beta,
_ => null
};

if (team is null)
{
player.SendClientMessage(Color.Red, Messages.InvalidFlagColor);
return;
}

ResetFlagPosition(player, team);
}

private void ResetFlagPosition(Player player, Team team)
{
var message = Smart.Format(Messages.ResetFlagPosition, new
{
PlayerName = player.Name,
team.ColorName
});
team.IsFlagAtBasePosition = true;
team.Flag.RemoveCarrier();
teamPickupService.CreateFlagFromBasePosition(team);
teamPickupService.DestroyExteriorMarker(team);
teamSoundsService.PlayFlagReturnedSound(team);
flagAutoReturnTimer.Stop(team);
worldService.GameText($"~n~~n~~n~{team.GameText}{team.ColorName} flag returned!", 5000, 3);
worldService.SendClientMessage(Color.Yellow, message);
}
}

0 comments on commit faafcf8

Please sign in to comment.