namespace SOR.Game.Abilities.Models; using SOR.Database.Enums; // ── Condition base ──────────────────────────────────────────────────────────── /// /// A boolean predicate evaluated against a subject entity. /// The default subject is Self (the source unit or ability owner). /// Override with Subject = "Target" to evaluate against the current action's resolved target. /// // Composite [PolyType(typeof(AndCondition), "AND")] [PolyType(typeof(OrCondition), "OR")] [PolyType(typeof(XorCondition), "XOR")] // Unit (§6.1) [PolyType(typeof(HealthBelowCondition), "HealthBelow")] [PolyType(typeof(HealthAboveCondition), "HealthAbove")] [PolyType(typeof(DefenseIsCondition), "DefenseIs")] [PolyType(typeof(HasGenusCondition), "HasGenus")] [PolyType(typeof(HasAbilityCondition), "HasAbility")] [PolyType(typeof(IsOnTileWithAffinityCondition), "IsOnTileWithAffinity")] [PolyType(typeof(IsAdjacentToCondition), "IsAdjacentTo")] [PolyType(typeof(WithinRangeOfCondition), "WithinRangeOf")] [PolyType(typeof(MovementTypeIsCondition), "MovementTypeIs")] // Player (§6.2) [PolyType(typeof(SPAtLeastCondition), "SPAtLeast")] [PolyType(typeof(SPAtMostCondition), "SPAtMost")] [PolyType(typeof(STAtLeastCondition), "STAtLeast")] [PolyType(typeof(STAtMostCondition), "STAtMost")] [PolyType(typeof(HandSizeAtLeastCondition), "HandSizeAtLeast")] [PolyType(typeof(HandSizeAtMostCondition), "HandSizeAtMost")] [PolyType(typeof(DeckSizeAtLeastCondition), "DeckSizeAtLeast")] [PolyType(typeof(DiscardSizeAtLeastCondition), "DiscardSizeAtLeast")] // Tile (§6.3) [PolyType(typeof(TileAffinityMatchesCondition), "TileAffinityMatches")] [PolyType(typeof(TileIsOccupiedCondition), "TileIsOccupied")] [PolyType(typeof(TileIsUnoccupiedCondition), "TileIsUnoccupied")] // Turn/timing (§6.4) [PolyType(typeof(IsOwnTurnCondition), "IsOwnTurn")] [PolyType(typeof(IsOpponentTurnCondition), "IsOpponentTurn")] [PolyType(typeof(IsAllyTurnCondition), "IsAllyTurn")] [PolyType(typeof(IsActivePlayerTurnCondition), "IsActivePlayerTurn")] // Battlefield (§6.5) [PolyType(typeof(UnitCountOnBattlefieldCondition), "UnitCountOnBattlefield")] [PolyType(typeof(CardInZoneCondition), "CardInZone")] public abstract class Condition { /// /// Which entity to evaluate this condition against. /// "Self" (default) = the source unit / ability owner. /// "Target" = the current action's resolved target. /// public string Subject { get; set; } = "Self"; } // ── Composite conditions ────────────────────────────────────────────────────── public sealed class AndCondition : Condition { public Condition[] Conditions { get; set; } = []; } public sealed class OrCondition : Condition { public Condition[] Conditions { get; set; } = []; } public sealed class XorCondition : Condition { public Condition[] Conditions { get; set; } = []; } // ── Unit conditions (§6.1) ──────────────────────────────────────────────────── public sealed class HealthBelowCondition : Condition { public int N { get; set; } } public sealed class HealthAboveCondition : Condition { public int N { get; set; } } public sealed class DefenseIsCondition : Condition { public int N { get; set; } } public sealed class HasGenusCondition : Condition { public string Tag { get; set; } = string.Empty; } /// Unit must have an ability with the given reference name. public sealed class HasAbilityCondition : Condition { public string AbilityRef { get; set; } = string.Empty; } public sealed class IsOnTileWithAffinityCondition : Condition { public Affinity Affinity { get; set; } } public sealed class IsAdjacentToCondition : Condition { public string UnitType { get; set; } = "Unit"; public string Ownership { get; set; } = "Any"; } public sealed class WithinRangeOfCondition : Condition { /// Reference to another action's target, e.g. "Action1.Target". public string Target { get; set; } = string.Empty; public int Min { get; set; } = 1; public int Max { get; set; } = 1; } public sealed class MovementTypeIsCondition : Condition { public MovementType MovementType { get; set; } } // ── Player conditions (§6.2) ────────────────────────────────────────────────── public sealed class SPAtLeastCondition : Condition { public int N { get; set; } } public sealed class SPAtMostCondition : Condition { public int N { get; set; } } public sealed class STAtLeastCondition : Condition { public int N { get; set; } } public sealed class STAtMostCondition : Condition { public int N { get; set; } } public sealed class HandSizeAtLeastCondition : Condition { public int N { get; set; } } public sealed class HandSizeAtMostCondition : Condition { public int N { get; set; } } public sealed class DeckSizeAtLeastCondition : Condition { public int N { get; set; } } public sealed class DiscardSizeAtLeastCondition : Condition { public int N { get; set; } } // ── Tile conditions (§6.3) ──────────────────────────────────────────────────── public sealed class TileAffinityMatchesCondition : Condition { public Affinity Affinity { get; set; } } public sealed class TileIsOccupiedCondition : Condition { public string? UnitType { get; set; } } public sealed class TileIsUnoccupiedCondition : Condition { } // ── Turn/timing conditions (§6.4) ──────────────────────────────────────────── public sealed class IsOwnTurnCondition : Condition { } public sealed class IsOpponentTurnCondition : Condition { } public sealed class IsAllyTurnCondition : Condition { } public sealed class IsActivePlayerTurnCondition : Condition { public string Ownership { get; set; } = "Owner"; } // ── Battlefield conditions (§6.5) ───────────────────────────────────────────── public enum Comparator { Equal, NotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual } public sealed class UnitCountOnBattlefieldCondition : Condition { public string Ownership { get; set; } = "Enemy"; public string UnitType { get; set; } = "Unit"; public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual; public int N { get; set; } } public sealed class CardInZoneCondition : Condition { /// Reference to a specific card instance ID or definition ID. public string CardRef { get; set; } = string.Empty; public string Zone { get; set; } = "Hand"; }