Localize, cleanup, and LEC round control commands. (#38812)

* commit-progress

* commit
This commit is contained in:
Kyle Tyo
2025-09-03 06:49:34 -04:00
committed by GitHub
parent d3731395b6
commit 0e884da5eb
9 changed files with 108 additions and 112 deletions

View File

@@ -2,50 +2,44 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands namespace Content.Server.GameTicking.Commands;
{
[AdminCommand(AdminFlags.Round)] [AdminCommand(AdminFlags.Round)]
sealed class DelayStartCommand : IConsoleCommand public sealed class DelayStartCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntityManager _e = default!; [Dependency] private readonly GameTicker _gameTicker = default!;
public string Command => "delaystart"; public override 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 void Execute(IConsoleShell shell, string argStr, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = _e.System<GameTicker>(); if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{ {
shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); shell.WriteLine(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
return; return;
} }
if (args.Length == 0) switch (args.Length)
{ {
var paused = ticker.TogglePause(); case 0:
shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown."); var paused = _gameTicker.TogglePause();
shell.WriteLine(Loc.GetString(paused ? "cmd-delaystart-paused" : "cmd-delaystart-unpaused"));
return; return;
} case 1:
break;
if (args.Length != 1) default:
{ shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
shell.WriteLine("Need zero or one arguments.");
return; return;
} }
if (!uint.TryParse(args[0], out var seconds) || seconds == 0) if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
{ {
shell.WriteLine($"{args[0]} isn't a valid amount of seconds."); shell.WriteLine(Loc.GetString("cmd-delaystart-invalid-seconds", ("value", args[0])));
return; return;
} }
var time = TimeSpan.FromSeconds(seconds); var time = TimeSpan.FromSeconds(seconds);
if (!ticker.DelayStart(time)) if (!_gameTicker.DelayStart(time))
{ shell.WriteLine(Loc.GetString("cmd-delaystart-too-late"));
shell.WriteLine("An unknown error has occurred.");
}
}
} }
} }

View File

@@ -2,28 +2,23 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands namespace Content.Server.GameTicking.Commands;
{
[AdminCommand(AdminFlags.Round)] [AdminCommand(AdminFlags.Round)]
sealed class EndRoundCommand : IConsoleCommand public sealed class EndRoundCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntityManager _e = default!; [Dependency] private readonly GameTicker _gameTicker = default!;
public string Command => "endround"; public override string Command => "endround";
public string Description => "Ends the round and moves the server to PostRound.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = _e.System<GameTicker>(); if (_gameTicker.RunLevel != GameRunLevel.InRound)
if (ticker.RunLevel != GameRunLevel.InRound)
{ {
shell.WriteLine("This can only be executed while the game is in a round."); shell.WriteLine(Loc.GetString("shell-can-only-run-while-round-is-active"));
return; return;
} }
ticker.EndRound(); _gameTicker.EndRound();
}
} }
} }

View File

@@ -3,43 +3,37 @@ using Content.Server.RoundEnd;
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands namespace Content.Server.GameTicking.Commands;
{
[AdminCommand(AdminFlags.Round)] [AdminCommand(AdminFlags.Round)]
public sealed class RestartRoundCommand : IConsoleCommand public sealed class RestartRoundCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntityManager _e = default!; [Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
public string Command => "restartround"; public override string Command => "restartround";
public string Description => "Ends the current round and starts the countdown for the next lobby.";
public string Help => string.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = _e.System<GameTicker>(); if (_gameTicker.RunLevel != GameRunLevel.InRound)
if (ticker.RunLevel != GameRunLevel.InRound)
{ {
shell.WriteLine("This can only be executed while the game is in a round - try restartroundnow"); shell.WriteLine(Loc.GetString("shell-can-only-run-while-round-is-active"));
return; return;
} }
_e.System<RoundEndSystem>().EndRound(); _roundEndSystem.EndRound();
} }
} }
[AdminCommand(AdminFlags.Round)] [AdminCommand(AdminFlags.Round)]
public sealed class RestartRoundNowCommand : IConsoleCommand public sealed class RestartRoundNowCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntityManager _e = default!; [Dependency] private readonly GameTicker _gameTicker = default!;
public string Command => "restartroundnow"; public override string Command => "restartroundnow";
public string Description => "Moves the server from PostRound to a new PreRoundLobby.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
_e.System<GameTicker>().RestartRound(); _gameTicker.RestartRound();
}
} }
} }

View File

@@ -2,28 +2,23 @@
using Content.Shared.Administration; using Content.Shared.Administration;
using Robust.Shared.Console; using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands namespace Content.Server.GameTicking.Commands;
{
[AdminCommand(AdminFlags.Round)] [AdminCommand(AdminFlags.Round)]
sealed class StartRoundCommand : IConsoleCommand public sealed class StartRoundCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntityManager _e = default!; [Dependency] private readonly GameTicker _gameTicker = default!;
public string Command => "startround"; public override string Command => "startround";
public string Description => "Ends PreRoundLobby state and starts the round.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var ticker = _e.System<GameTicker>(); if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{ {
shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); shell.WriteLine(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
return; return;
} }
ticker.StartRound(); _gameTicker.StartRound();
}
} }
} }

View File

@@ -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!

View File

@@ -0,0 +1,2 @@
cmd-endround-desc = Ends the round and moves the server to PostRound.
cmd-endround-help = Usage: endround

View File

@@ -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

View File

@@ -0,0 +1,2 @@
cmd-startround-desc = Ends PreRoundLobby state and starts the round.
cmd-startround-help = Usage: startround

View File

@@ -5,6 +5,8 @@
shell-command-success = Command successful shell-command-success = Command successful
shell-invalid-command = Invalid command. shell-invalid-command = Invalid command.
shell-invalid-command-specific = Invalid {$commandName} 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-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-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. shell-must-be-attached-to-entity = You must be attached to an entity to run this command.