diff --git a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs index 8398d28793a..069c8deec23 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Fax.Components; using Content.Shared.GameTicking; using Content.Shared.Paper; +using Robust.Server.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -16,6 +17,7 @@ public sealed class StationGoalPaperSystem : EntitySystem [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly FaxSystem _faxSystem = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; public override void Initialize() { @@ -31,7 +33,18 @@ private void OnRoundStarted(RoundStartedEvent ev) public bool SendRandomGoal() { var availableGoals = _prototypeManager.EnumeratePrototypes().ToList(); - var goal = _random.Pick(availableGoals); + var playerCount = _playerManager.PlayerCount; + + var validGoals = availableGoals.Where(goal => + (!goal.MinPlayers.HasValue || playerCount >= goal.MinPlayers.Value) && + (!goal.MaxPlayers.HasValue || playerCount <= goal.MaxPlayers.Value)).ToList(); + + if (!validGoals.Any()) + { + return false; + } + + var goal = _random.Pick(validGoals); return SendStationGoal(goal); } diff --git a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs b/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs index 79d945f5be6..a0e95b6893f 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs @@ -5,8 +5,17 @@ namespace Content.Server.Corvax.StationGoal [Serializable, Prototype("stationGoal")] public sealed class StationGoalPrototype : IPrototype { - [IdDataFieldAttribute] public string ID { get; } = default!; + [IdDataFieldAttribute] + public string ID { get; } = default!; + + [DataField("text")] + public string Text { get; set; } = string.Empty; + + [DataField("minPlayers")] + public int? MinPlayers = null; + + [DataField("maxPlayers")] + public int? MaxPlayers = null; - [DataField("text")] public string Text { get; set; } = string.Empty; } }