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:
Putnam3145 2022-05-21 20:55:19 -07:00 committed by GitHub
parent 2785a51916
commit 29bc6bf552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -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>();
}

View File

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