diff --git a/src/Application/Common/Resources/Messages.Designer.cs b/src/Application/Common/Resources/Messages.Designer.cs index 959d863a..e0c5057d 100644 --- a/src/Application/Common/Resources/Messages.Designer.cs +++ b/src/Application/Common/Resources/Messages.Designer.cs @@ -258,6 +258,15 @@ internal static string GiveMeCoins { } } + /// + /// Looks up a localized string similar to You cannot use this command because you are the flag carrier. + /// + internal static string HasCapturedFlag { + get { + return ResourceManager.GetString("HasCapturedFlag", resourceCulture); + } + } + /// /// Looks up a localized string similar to You do not have enough coins to obtain this combo. /// @@ -627,6 +636,15 @@ internal static string PlayerHasChangedTeams { } } + /// + /// Looks up a localized string similar to You are in spectator mode. + /// + internal static string PlayerInSpectatorMode { + get { + return ResourceManager.GetString("PlayerInSpectatorMode", resourceCulture); + } + } + /// /// Looks up a localized string similar to You are already a member of that team. /// @@ -690,6 +708,15 @@ internal static string PlayerScoreReset { } } + /// + /// Looks up a localized string similar to You don't have enough health. + /// + internal static string PlayerWithInsufficientHealth { + get { + return ResourceManager.GetString("PlayerWithInsufficientHealth", resourceCulture); + } + } + /// /// Looks up a localized string similar to Promoted to {RoleName} role. /// diff --git a/src/Application/Common/Resources/Messages.resx b/src/Application/Common/Resources/Messages.resx index 91efaecd..6330694e 100644 --- a/src/Application/Common/Resources/Messages.resx +++ b/src/Application/Common/Resources/Messages.resx @@ -183,6 +183,9 @@ You have obtained 100 coins! + + You cannot use this command because you are the flag carrier + You do not have enough coins to obtain this combo @@ -306,6 +309,9 @@ Attention, team! {PlayerName} has made the switch and is now part of the {TeamName} team + + You are in spectator mode + You are already a member of that team @@ -327,6 +333,9 @@ {PlayerName} has reset their score with the command {Color}/re + + You don't have enough health + Promoted to {RoleName} role diff --git a/src/Application/Teams/ClassSelection/ClassSelectionSystem.cs b/src/Application/Teams/ClassSelection/ClassSelectionSystem.cs index 2b169f70..a750bec2 100644 --- a/src/Application/Teams/ClassSelection/ClassSelectionSystem.cs +++ b/src/Application/Teams/ClassSelection/ClassSelectionSystem.cs @@ -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); + } }