diff --git a/Content.Server/Maps/Conditions/HolidayMapCondition.cs b/Content.Server/Maps/Conditions/HolidayMapCondition.cs new file mode 100644 index 0000000000..a68057380e --- /dev/null +++ b/Content.Server/Maps/Conditions/HolidayMapCondition.cs @@ -0,0 +1,22 @@ +using System.Linq; +using Content.Server.Holiday; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Log; +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; + +namespace Content.Server.Maps.Conditions; + +public class HolidayMapCondition : GameMapCondition +{ + [DataField("holidays")] + public string[] Holidays { get; } = default!; + + public override bool Check(GameMapPrototype map) + { + var holidaySystem = EntitySystem.Get(); + + return Holidays.Any(holiday => holidaySystem.IsCurrentlyHoliday(holiday)) ^ Inverted; + } +} diff --git a/Content.Server/Maps/GameMapCondition.cs b/Content.Server/Maps/GameMapCondition.cs new file mode 100644 index 0000000000..7a9e66d054 --- /dev/null +++ b/Content.Server/Maps/GameMapCondition.cs @@ -0,0 +1,11 @@ +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Maps; + +[ImplicitDataDefinitionForInheritors] +public abstract class GameMapCondition +{ + [DataField("inverted")] + public bool Inverted { get; } + public abstract bool Check(GameMapPrototype map); +} diff --git a/Content.Server/Maps/GameMapManager.cs b/Content.Server/Maps/GameMapManager.cs index efabeeae3e..974c89057c 100644 --- a/Content.Server/Maps/GameMapManager.cs +++ b/Content.Server/Maps/GameMapManager.cs @@ -111,7 +111,9 @@ public class GameMapManager : IGameMapManager private bool IsMapEligible(GameMapPrototype map) { - return map.MaxPlayers >= _playerManager.PlayerCount && map.MinPlayers <= _playerManager.PlayerCount; + return map.MaxPlayers >= _playerManager.PlayerCount && + map.MinPlayers <= _playerManager.PlayerCount && + map.Conditions.All(x => x.Check(map)); } private bool TryLookupMap(string gameMap, [NotNullWhen(true)] out GameMapPrototype? map) diff --git a/Content.Server/Maps/GameMapPrototype.cs b/Content.Server/Maps/GameMapPrototype.cs index d64fe04192..09c0c98ab4 100644 --- a/Content.Server/Maps/GameMapPrototype.cs +++ b/Content.Server/Maps/GameMapPrototype.cs @@ -66,6 +66,9 @@ public class GameMapPrototype : IPrototype [DataField("votable")] public bool Votable { get; } = true; + [DataField("conditions")] + public List Conditions { get; } = new(); + /// /// Jobs used at round start should the station run out of job slots. /// Doesn't necessarily mean the station has infinite slots for the given jobs midround!