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")]
|
[DataField("showInVote")]
|
||||||
public bool ShowInVote { get; } = false;
|
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>))]
|
[DataField("rules", customTypeSerializer:typeof(PrototypeIdListSerializer<GameRulePrototype>))]
|
||||||
public IReadOnlyList<string> Rules { get; } = Array.Empty<string>();
|
public IReadOnlyList<string> Rules { get; } = Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,12 @@ namespace Content.Server.Voting.Managers
|
|||||||
if(!preset.ShowInVote)
|
if(!preset.ShowInVote)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(_playerManager.PlayerCount < (preset.MinPlayers ?? int.MinValue))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(_playerManager.PlayerCount > (preset.MaxPlayers ?? int.MaxValue))
|
||||||
|
continue;
|
||||||
|
|
||||||
presets[preset.ID] = preset.ModeTitle;
|
presets[preset.ID] = preset.ModeTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user