Fool players with decoy presets (#40053)
* added secret gamepresets * cut down on alias * remove all secret presets * change the command to allow for a secret argument * update test * moved the secret argument after the number of rounds argument * added completions * localization and use of CompletionHelper.Booleans * command now has a option for a decoy preset * fixed decoy message in the end * ops * clean up * hint 2 * improve localization --------- Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com>
This commit is contained in:
@@ -20,9 +20,9 @@ namespace Content.Server.GameTicking.Commands
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (!args.Length.InRange(1, 2))
|
||||
if (!args.Length.InRange(1, 3))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-need-between-arguments", ("lower", 1), ("upper", 2), ("currentAmount", args.Length)));
|
||||
shell.WriteError(Loc.GetString("shell-need-between-arguments", ("lower", 1), ("upper", 3), ("currentAmount", args.Length)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,32 +36,39 @@ namespace Content.Server.GameTicking.Commands
|
||||
|
||||
var rounds = 1;
|
||||
|
||||
if (args.Length == 2 && !int.TryParse(args[1], out rounds))
|
||||
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())));
|
||||
GamePresetPrototype? decoy = null;
|
||||
|
||||
if (args.Length == 3 && !ticker.TryFindGamePreset(args[2], out decoy))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("set-game-preset-decoy-error", ("preset", args[2])));
|
||||
return;
|
||||
}
|
||||
|
||||
ticker.SetGamePreset(preset, false, decoy, rounds);
|
||||
if (decoy == null)
|
||||
shell.WriteLine(Loc.GetString("set-game-preset-preset-set-finite", ("preset", preset.ID), ("rounds", rounds.ToString())));
|
||||
else
|
||||
shell.WriteLine(Loc.GetString("set-game-preset-preset-set-finite-with-decoy", ("preset", preset.ID), ("rounds", rounds.ToString()), ("decoy", decoy.ID)));
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
return args.Length switch
|
||||
{
|
||||
var gamePresets = _prototype.EnumeratePrototypes<GamePresetPrototype>()
|
||||
.OrderBy(p => p.ID);
|
||||
var options = new List<string>();
|
||||
foreach (var preset in gamePresets)
|
||||
{
|
||||
options.Add(preset.ID);
|
||||
options.AddRange(preset.Alias);
|
||||
}
|
||||
1 => CompletionResult.FromHintOptions(CompletionHelper.PrototypeIDs<GamePresetPrototype>(),
|
||||
Loc.GetString("set-game-preset-command-hint-1")),
|
||||
2 => CompletionResult.FromHint(Loc.GetString("set-game-preset-command-hint-2")),
|
||||
3 => CompletionResult.FromHintOptions(CompletionHelper.PrototypeIDs<GamePresetPrototype>(),
|
||||
Loc.GetString("set-game-preset-command-hint-3")),
|
||||
|
||||
return CompletionResult.FromHintOptions(options, "<id>");
|
||||
}
|
||||
return CompletionResult.Empty;
|
||||
_ => CompletionResult.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user