Allow game presets to have min/max players (#8327)
Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,12 @@ namespace Content.Server.GameTicking.Presets
|
||||
[DataField("showInVote")]
|
||||
public bool ShowInVote { get; } = false;
|
||||
|
||||
[DataField("minPlayers")]
|
||||
public int? MinPlayers { get; } = null;
|
||||
|
||||
[DataField("maxPlayers")]
|
||||
public int? MaxPlayers { get; } = null;
|
||||
|
||||
[DataField("rules", customTypeSerializer:typeof(PrototypeIdListSerializer<GameRulePrototype>))]
|
||||
public IReadOnlyList<string> Rules { get; } = Array.Empty<string>();
|
||||
}
|
||||
|
||||
@@ -110,6 +110,12 @@ namespace Content.Server.Voting.Managers
|
||||
if(!preset.ShowInVote)
|
||||
continue;
|
||||
|
||||
if(_playerManager.PlayerCount < (preset.MinPlayers ?? int.MinValue))
|
||||
continue;
|
||||
|
||||
if(_playerManager.PlayerCount > (preset.MaxPlayers ?? int.MaxValue))
|
||||
continue;
|
||||
|
||||
presets[preset.ID] = preset.ModeTitle;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user