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:
Samuka-C
2025-09-04 10:03:47 -03:00
committed by GitHub
parent 427e4a88ea
commit 2f3d976c33
5 changed files with 65 additions and 70 deletions

View File

@@ -20,9 +20,9 @@ namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) 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; return;
} }
@@ -36,32 +36,39 @@ namespace Content.Server.GameTicking.Commands
var rounds = 1; 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")); shell.WriteError(Loc.GetString("set-game-preset-optional-argument-not-integer"));
return; return;
} }
ticker.SetGamePreset(preset, false, rounds); 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()))); 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) public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{ {
if (args.Length == 1) return args.Length switch
{ {
var gamePresets = _prototype.EnumeratePrototypes<GamePresetPrototype>() 1 => CompletionResult.FromHintOptions(CompletionHelper.PrototypeIDs<GamePresetPrototype>(),
.OrderBy(p => p.ID); Loc.GetString("set-game-preset-command-hint-1")),
var options = new List<string>(); 2 => CompletionResult.FromHint(Loc.GetString("set-game-preset-command-hint-2")),
foreach (var preset in gamePresets) 3 => CompletionResult.FromHintOptions(CompletionHelper.PrototypeIDs<GamePresetPrototype>(),
{ Loc.GetString("set-game-preset-command-hint-3")),
options.Add(preset.ID);
options.AddRange(preset.Alias);
}
return CompletionResult.FromHintOptions(options, "<id>"); _ => CompletionResult.Empty
} };
return CompletionResult.Empty;
} }
} }
} }

View File

@@ -18,6 +18,11 @@ public sealed partial class GameTicker
/// </summary> /// </summary>
public GamePresetPrototype? Preset { get; private set; } public GamePresetPrototype? Preset { get; private set; }
/// <summary>
/// The selected preset that will be shown at the lobby screen to fool players.
/// </summary>
public GamePresetPrototype? Decoy { get; private set; }
/// <summary> /// <summary>
/// The preset that's currently active. /// The preset that's currently active.
/// </summary> /// </summary>
@@ -94,7 +99,7 @@ public sealed partial class GameTicker
SetGamePreset(LobbyEnabled ? _cfg.GetCVar(CCVars.GameLobbyDefaultPreset) : "sandbox"); SetGamePreset(LobbyEnabled ? _cfg.GetCVar(CCVars.GameLobbyDefaultPreset) : "sandbox");
} }
public void SetGamePreset(GamePresetPrototype? preset, bool force = false, int? resetDelay = null) public void SetGamePreset(GamePresetPrototype? preset, bool force = false, GamePresetPrototype? decoy = null, int? resetDelay = null)
{ {
// Do nothing if this game ticker is a dummy! // Do nothing if this game ticker is a dummy!
if (DummyTicker) if (DummyTicker)
@@ -114,6 +119,7 @@ public sealed partial class GameTicker
} }
Preset = preset; Preset = preset;
Decoy = decoy;
ValidateMap(); ValidateMap();
UpdateInfoText(); UpdateInfoText();
@@ -126,7 +132,7 @@ public sealed partial class GameTicker
public void SetGamePreset(string preset, bool force = false) public void SetGamePreset(string preset, bool force = false)
{ {
var proto = FindGamePreset(preset); var proto = FindGamePreset(preset);
if(proto != null) if (proto != null)
SetGamePreset(proto, force); SetGamePreset(proto, force);
} }

View File

@@ -72,8 +72,8 @@ namespace Content.Server.GameTicking
Loc.GetString("game-ticker-no-map-selected")); Loc.GetString("game-ticker-no-map-selected"));
} }
var gmTitle = Loc.GetString(preset.ModeTitle); var gmTitle = (Decoy == null) ? Loc.GetString(preset.ModeTitle) : Loc.GetString(Decoy.ModeTitle);
var desc = Loc.GetString(preset.Description); var desc = (Decoy == null) ? Loc.GetString(preset.Description) : Loc.GetString(Decoy.Description);
return Loc.GetString( return Loc.GetString(
RunLevel == GameRunLevel.PreRoundLobby RunLevel == GameRunLevel.PreRoundLobby
? "game-ticker-get-info-preround-text" ? "game-ticker-get-info-preround-text"
@@ -107,7 +107,7 @@ namespace Content.Server.GameTicking
private TickerLobbyInfoEvent GetInfoMsg() private TickerLobbyInfoEvent GetInfoMsg()
{ {
return new (GetInfoText()); return new(GetInfoText());
} }
private void UpdateLateJoinStatus() private void UpdateLateJoinStatus()

View File

@@ -1,7 +1,13 @@
set-game-preset-command-description = Sets the game preset for the specified number of upcoming rounds. set-game-preset-command-description = Sets the game preset for the specified number of upcoming rounds. Can also display another preset's title and description in the lobby to fool players.
set-game-preset-command-help-text = setgamepreset <id> [number of rounds, defaulting to 1] set-game-preset-command-help-text = setgamepreset <id> [number of rounds, defaulting to 1] [decoy preset]
set-game-preset-optional-argument-not-integer = If argument 2 is provided it must be a number. set-game-preset-command-hint-1 = <id>
set-game-preset-command-hint-2 = [number of rounds]
set-game-preset-command-hint-3 = [decoy preset]
set-game-preset-optional-argument-not-integer = If argument 2 is provided it must be a number.
set-game-preset-preset-error = Unable to find game preset "{$preset}" set-game-preset-preset-error = Unable to find game preset "{$preset}"
set-game-preset-decoy-error = If argument 3 is provided it must be a valid preset. Unable to find game preset "{$preset}"
#set-game-preset-preset-set = Set game preset to "{$preset}" #set-game-preset-preset-set = Set game preset to "{$preset}"
set-game-preset-preset-set-finite = Set game preset to "{$preset}" for the next {$rounds} rounds. set-game-preset-preset-set-finite = Set game preset to "{$preset}" for the next {$rounds} rounds.
set-game-preset-preset-set-finite-with-decoy = Set game preset to "{$preset}" for the next {$rounds} rounds, showing {$decoy} in the lobby.

View File

@@ -124,30 +124,6 @@
rules: rules:
- Secret - Secret
- type: gamePreset
id: SecretExtended #For Admin Use: Runs Extended but shows "Secret" in lobby.
alias:
- secretextended
name: secret-title
showInVote: false #Admin Use
description: secret-description
rules:
- BasicStationEventScheduler
- MeteorSwarmScheduler
- SpaceTrafficControlEventScheduler
- BasicRoundstartVariation
- type: gamePreset
id: SecretGreenshift #For Admin Use: Runs Greenshift but shows "Secret" in lobby.
alias:
- secretgreenshift
name: secret-title
showInVote: false #Admin Use
description: secret-description
rules:
- SpaceTrafficControlFriendlyEventScheduler
- BasicRoundstartVariation
- type: gamePreset - type: gamePreset
id: Sandbox id: Sandbox
alias: alias: