Skip to content

Commit

Permalink
setgamepreset command rework (space-wizards#30756)
Browse files Browse the repository at this point in the history
* gameticker.gamepreset namespace

* setgamepreset now has a finite duration

* comments, cleanup
  • Loading branch information
Errant-4 authored and themias committed Aug 9, 2024
1 parent 83a7253 commit f269f66
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 228 deletions.
17 changes: 13 additions & 4 deletions Content.Server/GameTicking/Commands/SetGamePresetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Administration;
using Content.Server.GameTicking.Presets;
using Content.Shared.Administration;
using Linguini.Shared.Util;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;

Expand All @@ -19,9 +20,9 @@ public sealed class SetGamePresetCommand : IConsoleCommand

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
if (!args.Length.InRange(1, 2))
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific", ("properAmount", 1), ("currentAmount", args.Length)));
shell.WriteError(Loc.GetString("shell-need-between-arguments", ("lower", 1), ("upper", 2), ("currentAmount", args.Length)));
return;
}

Expand All @@ -33,8 +34,16 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

ticker.SetGamePreset(preset);
shell.WriteLine(Loc.GetString("set-game-preset-preset-set", ("preset", preset.ID)));
var rounds = 1;

if (args.Length == 2 && !int.TryParse(args[1], out rounds))
{
shell.WriteError(Loc.GetString("set-game-preset-optional-argument-not-integer"));
return;
}

ticker.SetGamePreset(preset, false, rounds);
shell.WriteLine(Loc.GetString("set-game-preset-preset-set-finite", ("preset", preset.ID), ("rounds", rounds.ToString())));
}

public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
Expand Down
Loading

0 comments on commit f269f66

Please sign in to comment.