-
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 #284 from MrDave1999/feat/issue-278
feat: allow moderators to reset the flag to its base position
- Loading branch information
Showing
5 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
5 changes: 2 additions & 3 deletions
5
src/Application/Players/GeneralCommands/Resources/DetailedCommandInfo.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,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); | ||
} | ||
} |