]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Localize, cleanup, and LEC round control commands. (#38812)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Wed, 3 Sep 2025 10:49:34 +0000 (06:49 -0400)
committerGitHub <noreply@github.com>
Wed, 3 Sep 2025 10:49:34 +0000 (12:49 +0200)
* commit-progress

* commit

Content.Server/GameTicking/Commands/DelayStartCommand.cs
Content.Server/GameTicking/Commands/EndRoundCommand.cs
Content.Server/GameTicking/Commands/RestartRoundCommand.cs
Content.Server/GameTicking/Commands/StartRoundCommand.cs
Resources/Locale/en-US/commands/delaystart-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/commands/endround-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/commands/restartround-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/commands/startround-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/shell.ftl

index 6e101d93a320f57edaebbd3ad1670dcdb8af713f..7c7eb9c7f1f2573d0c646a8eafde2ef0fe109d7b 100644 (file)
@@ -2,50 +2,44 @@
 using Content.Shared.Administration;
 using Robust.Shared.Console;
 
-namespace Content.Server.GameTicking.Commands
+namespace Content.Server.GameTicking.Commands;
+
+[AdminCommand(AdminFlags.Round)]
+public sealed class DelayStartCommand : LocalizedEntityCommands
 {
-    [AdminCommand(AdminFlags.Round)]
-    sealed class DelayStartCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _e = default!;
+    [Dependency] private readonly GameTicker _gameTicker = default!;
 
-        public string Command => "delaystart";
-        public string Description => "Delays the round start.";
-        public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
+    public override string Command => "delaystart";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
         {
-            var ticker = _e.System<GameTicker>();
-            if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
-            {
-                shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
-                return;
-            }
-
-            if (args.Length == 0)
-            {
-                var paused = ticker.TogglePause();
-                shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown.");
-                return;
-            }
+            shell.WriteLine(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
+            return;
+        }
 
-            if (args.Length != 1)
-            {
-                shell.WriteLine("Need zero or one arguments.");
+        switch (args.Length)
+        {
+            case 0:
+                var paused = _gameTicker.TogglePause();
+                shell.WriteLine(Loc.GetString(paused ? "cmd-delaystart-paused" : "cmd-delaystart-unpaused"));
                 return;
-            }
-
-            if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
-            {
-                shell.WriteLine($"{args[0]} isn't a valid amount of seconds.");
+            case 1:
+                break;
+            default:
+                shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
                 return;
-            }
+        }
 
-            var time = TimeSpan.FromSeconds(seconds);
-            if (!ticker.DelayStart(time))
-            {
-                shell.WriteLine("An unknown error has occurred.");
-            }
+        if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
+        {
+            shell.WriteLine(Loc.GetString("cmd-delaystart-invalid-seconds", ("value", args[0])));
+            return;
         }
+
+        var time = TimeSpan.FromSeconds(seconds);
+        if (!_gameTicker.DelayStart(time))
+            shell.WriteLine(Loc.GetString("cmd-delaystart-too-late"));
     }
 }
index c6a8ddbf5370f6b912f318bc95e9033f893b24b7..2f8ca54144485015b983fab77a625816e4bc8528 100644 (file)
@@ -2,28 +2,23 @@
 using Content.Shared.Administration;
 using Robust.Shared.Console;
 
-namespace Content.Server.GameTicking.Commands
+namespace Content.Server.GameTicking.Commands;
+
+[AdminCommand(AdminFlags.Round)]
+public sealed class EndRoundCommand : LocalizedEntityCommands
 {
-    [AdminCommand(AdminFlags.Round)]
-    sealed class EndRoundCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _e = default!;
+    [Dependency] private readonly GameTicker _gameTicker = default!;
 
-        public string Command => "endround";
-        public string Description => "Ends the round and moves the server to PostRound.";
-        public string Help => String.Empty;
+    public override string Command => "endround";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (_gameTicker.RunLevel != GameRunLevel.InRound)
         {
-            var ticker = _e.System<GameTicker>();
-
-            if (ticker.RunLevel != GameRunLevel.InRound)
-            {
-                shell.WriteLine("This can only be executed while the game is in a round.");
-                return;
-            }
-
-            ticker.EndRound();
+            shell.WriteLine(Loc.GetString("shell-can-only-run-while-round-is-active"));
+            return;
         }
+
+        _gameTicker.EndRound();
     }
 }
index e4ea3fa53c36ccc963431a386a3fa2c62367e11b..6811df4e2e4e20ec66a97914ad0ad2856a8137f5 100644 (file)
@@ -3,43 +3,37 @@ using Content.Server.RoundEnd;
 using Content.Shared.Administration;
 using Robust.Shared.Console;
 
-namespace Content.Server.GameTicking.Commands
+namespace Content.Server.GameTicking.Commands;
+
+[AdminCommand(AdminFlags.Round)]
+public sealed class RestartRoundCommand : LocalizedEntityCommands
 {
-    [AdminCommand(AdminFlags.Round)]
-    public sealed class RestartRoundCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _e = default!;
+    [Dependency] private readonly GameTicker _gameTicker = default!;
+    [Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
 
-        public string Command => "restartround";
-        public string Description => "Ends the current round and starts the countdown for the next lobby.";
-        public string Help => string.Empty;
+    public override string Command => "restartround";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (_gameTicker.RunLevel != GameRunLevel.InRound)
         {
-            var ticker = _e.System<GameTicker>();
-
-            if (ticker.RunLevel != GameRunLevel.InRound)
-            {
-                shell.WriteLine("This can only be executed while the game is in a round - try restartroundnow");
-                return;
-            }
-
-            _e.System<RoundEndSystem>().EndRound();
+            shell.WriteLine(Loc.GetString("shell-can-only-run-while-round-is-active"));
+            return;
         }
+
+        _roundEndSystem.EndRound();
     }
+}
 
-    [AdminCommand(AdminFlags.Round)]
-    public sealed class RestartRoundNowCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _e = default!;
+[AdminCommand(AdminFlags.Round)]
+public sealed class RestartRoundNowCommand : LocalizedEntityCommands
+{
+    [Dependency] private readonly GameTicker _gameTicker = default!;
 
-        public string Command => "restartroundnow";
-        public string Description => "Moves the server from PostRound to a new PreRoundLobby.";
-        public string Help => String.Empty;
+    public override string Command => "restartroundnow";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
-        {
-            _e.System<GameTicker>().RestartRound();
-        }
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        _gameTicker.RestartRound();
     }
 }
index 432cdd23e35f5e137d0e311903476a84822d5d37..6579800ca3518d00b2c8e67cb3c9be831fdbc9c5 100644 (file)
@@ -2,28 +2,23 @@
 using Content.Shared.Administration;
 using Robust.Shared.Console;
 
-namespace Content.Server.GameTicking.Commands
+namespace Content.Server.GameTicking.Commands;
+
+[AdminCommand(AdminFlags.Round)]
+public sealed class StartRoundCommand : LocalizedEntityCommands
 {
-    [AdminCommand(AdminFlags.Round)]
-    sealed class StartRoundCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _e = default!;
+    [Dependency] private readonly GameTicker _gameTicker = default!;
 
-        public string Command => "startround";
-        public string Description => "Ends PreRoundLobby state and starts the round.";
-        public string Help => String.Empty;
+    public override string Command => "startround";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
         {
-            var ticker = _e.System<GameTicker>();
-
-            if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
-            {
-                shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
-                return;
-            }
-
-            ticker.StartRound();
+            shell.WriteLine(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
+            return;
         }
+
+        _gameTicker.StartRound();
     }
 }
diff --git a/Resources/Locale/en-US/commands/delaystart-command.ftl b/Resources/Locale/en-US/commands/delaystart-command.ftl
new file mode 100644 (file)
index 0000000..e5189a7
--- /dev/null
@@ -0,0 +1,7 @@
+cmd-delaystart-desc = Delays the round start.
+cmd-delaystart-help = Usage: delaystart [seconds]
+                      If no arguments are passed, the round will be paused or resumed accordingly.
+cmd-delaystart-invalid-seconds = {$value} isn't a valid amount of seconds.
+cmd-delaystart-paused = Paused the countdown.
+cmd-delaystart-unpaused = Resumed the countdown.
+cmd-delaystart-too-late = Round start could not be delayed in time!
diff --git a/Resources/Locale/en-US/commands/endround-command.ftl b/Resources/Locale/en-US/commands/endround-command.ftl
new file mode 100644 (file)
index 0000000..3b322b5
--- /dev/null
@@ -0,0 +1,2 @@
+cmd-endround-desc = Ends the round and moves the server to PostRound.
+cmd-endround-help = Usage: endround
diff --git a/Resources/Locale/en-US/commands/restartround-command.ftl b/Resources/Locale/en-US/commands/restartround-command.ftl
new file mode 100644 (file)
index 0000000..22bf074
--- /dev/null
@@ -0,0 +1,5 @@
+cmd-restartround-desc = Ends the current round and starts the countdown for the next lobby.
+cmd-restartround-help = Usage: restartround
+
+cmd-restartroundnow-desc = Moves the server from PostRound to a new PreRoundLobby.
+cmd-restartroundnow-help = Usage: restartroundnow
diff --git a/Resources/Locale/en-US/commands/startround-command.ftl b/Resources/Locale/en-US/commands/startround-command.ftl
new file mode 100644 (file)
index 0000000..51e85e8
--- /dev/null
@@ -0,0 +1,2 @@
+cmd-startround-desc = Ends PreRoundLobby state and starts the round.
+cmd-startround-help = Usage: startround
index 3edc43bd74876a8db5847ba4dd166e16bd17a483..36bebeae35bc798f7292ac65fb909afeb57f3890 100644 (file)
@@ -5,6 +5,8 @@
 shell-command-success = Command successful
 shell-invalid-command = Invalid command.
 shell-invalid-command-specific = Invalid {$commandName} command.
+shell-can-only-run-from-pre-round-lobby = You can only run this command while the game is in the pre-round lobby.
+shell-can-only-run-while-round-is-active = You can only run this command while the game is in a round.
 shell-cannot-run-command-from-server = You cannot run this command from the server.
 shell-only-players-can-run-this-command = Only players can run this command.
 shell-must-be-attached-to-entity = You must be attached to an entity to run this command.