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: Allow players to be in AFK mode from a command #145

Merged
merged 1 commit into from
Oct 7, 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
27 changes: 27 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.

9 changes: 9 additions & 0 deletions src/Application/Common/Resources/Messages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<data name="GiveMeCoins" xml:space="preserve">
<value>You have obtained 100 coins!</value>
</data>
<data name="HasCapturedFlag" xml:space="preserve">
<value>You cannot use this command because you are the flag carrier</value>
</data>
<data name="InsufficientCoins" xml:space="preserve">
<value>You do not have enough coins to obtain this combo</value>
</data>
Expand Down Expand Up @@ -306,6 +309,9 @@
<data name="PlayerHasChangedTeams" xml:space="preserve">
<value>Attention, team! {PlayerName} has made the switch and is now part of the {TeamName} team</value>
</data>
<data name="PlayerInSpectatorMode" xml:space="preserve">
<value>You are in spectator mode</value>
</data>
<data name="PlayerIsAlreadyInTeam" xml:space="preserve">
<value>You are already a member of that team</value>
</data>
Expand All @@ -327,6 +333,9 @@
<data name="PlayerScoreReset" xml:space="preserve">
<value>{PlayerName} has reset their score with the command {Color}/re</value>
</data>
<data name="PlayerWithInsufficientHealth" xml:space="preserve">
<value>You don't have enough health</value>
</data>
<data name="PromotedToRole" xml:space="preserve">
<value>Promoted to {RoleName} role</value>
</data>
Expand Down
31 changes: 31 additions & 0 deletions src/Application/Teams/ClassSelection/ClassSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,35 @@ public void OnPlayerDisconnect(Player player, DisconnectReason reason)
playerInfo.Team.Members.Remove(player);
teamTextDrawRenderer.UpdateTeamMembers(playerInfo.Team);
}

[PlayerCommand("afk")]
public void RedirectToClassSelection(Player player)
{
if (player.State == PlayerState.Spectating)
{
player.SendClientMessage(Color.Red, Messages.PlayerInSpectatorMode);
return;
}

PlayerInfo playerInfo = player.GetInfo();
if (playerInfo.HasCapturedFlag())
{
player.SendClientMessage(Color.Red, Messages.HasCapturedFlag);
return;
}

if (player.Health < 85)
{
player.SendClientMessage(Color.Red, Messages.PlayerWithInsufficientHealth);
return;
}

Team currentTeam = playerInfo.Team;
currentTeam.Members.Remove(player);
playerInfo.SetTeam(TeamId.NoTeam);
player.Team = (int)TeamId.NoTeam;
player.Color = Team.None.ColorHex;
player.RedirectToClassSelection();
teamTextDrawRenderer.UpdateTeamMembers(currentTeam);
}
}
Loading