feat(phase1): ability model expansion -- ActionGroup, CostGroup, new conditions/effects/filters

Action.cs:
  - TargetChooser enum (Self/Opponent/Ally/Random) + TargetSelector.Chooser field
    separates "whose entities qualify" from "who makes the selection"
  - ActionGroup { LogicOp(And/Or/Xor), ChooserRole, Actions[], Groups[] }
    replaces flat Action[] on AbilityDefinition; supports recursive AND/OR/XOR
  - ActionGroupLogicOp enum
  - CostGroup { LogicOp(And/Or/Xor), ChooserRole, Entries[], Groups[] }
    replaces flat CostEntry[] on AbilityDefinition
  - CostGroupLogicOp enum
  - ChooseOne.ChooserRole (within-action effect branching chooser)

AbilityDefinition.cs:
  - ActionGroup? (replaces Actions[]; old field kept [Obsolete] for migration reads)
  - CostGroup? (replaces Cost[]; old field kept [Obsolete] for migration reads)
  - OnEnterAuraActions / OnLeaveAuraActions (ActionGroup? each)

Triggers.cs:
  - OnChanneledTrigger.CardDefinitionId (specific card filter)
  - OnRuinActivationTrigger.OccupantFilters / OnUnitOccupyRuinTrigger.OccupantFilters
  - AmountComparator (Comparator enum) on OnDamageDealtTrigger, OnDamagePreventedTrigger,
    OnHealedTrigger, BeforeDamageAppliedTrigger, OnUnitMPSpentTrigger

Conditions.cs: 12 new condition types (UnitTypeIs, OwnershipIs, IsThisCard,
  UnitPropertyCompare, PlayerPropertyCompare, HandContainsCount,
  CardDefinitionCountInZone, IsInRangeOfUnit, TileOccupant, SurroundingTile,
  SPAccumulationCompare, CostOfCardsInHand)

Effects.cs: 16 new effect types across ArchSpirit zone ops (AscendFromZone,
  TransitionFromZone, ModifyChannelRange), Ruin ops (RelocateRuin,
  ActivateRuinAbility, DisableRuinForDuration), enhanced channeling
  (ChannelCardFromZone), token/spirit (CloneSpiritAsToken, DestroyToken,
  ModifySacrificeTokenReturn), player (SkipTurn, ModifyCardsDrawnThisTurn),
  zone (StackDeck, SearchAndPlace), unit (ChangeAttackType, ObstructMovementType).
  PreventDeathEffect + PreventNextDamageEffect extended with new fields.

Filters.cs: 3 new filter types (Ownership, UnitProperty, TileOccupancy)

AbilitySystem.cs + ActionCandidateGenerator.cs: #pragma disable CS0618 --
  authorized readers of backwards-compat obsolete fields

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-04-19 12:35:55 -04:00
co-authored by Claude Happy
parent 2d02567baa
commit 3b8de2deac
8 changed files with 539 additions and 20 deletions
@@ -1,3 +1,4 @@
#pragma warning disable CS0618 // Authorized reader of obsolete Actions/Cost fields for backwards-compat
namespace SOR.Ai.Heuristics;
using SOR.Ai.Core;
@@ -1,3 +1,4 @@
#pragma warning disable CS0618 // AbilitySystem is the authorized reader of obsolete Actions/Cost fields for backwards-compat migration
namespace SOR.Game.Abilities;
using System.Text.Json;
@@ -24,9 +24,25 @@ public sealed class AbilityDefinition
{
public AbilityType Type { get; set; }
public Condition[]? ActivationConditions { get; set; }
/// <summary>
/// Logical grouping of action steps (AND/OR/XOR). Replaces <see cref="Actions"/>.
/// If null at read-time, the engine wraps <see cref="Actions"/> in an And group automatically.
/// </summary>
public ActionGroup? ActionGroup { get; set; }
/// <summary>Flat action list. Replaced by <see cref="ActionGroup"/>; kept for migration reads only.</summary>
[System.Obsolete("Use ActionGroup instead. This field is read for backwards-compat only.")]
public Action[] Actions { get; set; } = [];
// ── Active only ──────────────────────────────────────────────────────────
/// <summary>
/// Logical cost grouping (AND/OR/XOR). Replaces <see cref="Cost"/>.
/// If null, the engine falls back to <see cref="Cost"/> for migration reads.
/// </summary>
public CostGroup? CostGroup { get; set; }
/// <summary>Flat cost array. Replaced by <see cref="CostGroup"/>; kept for migration reads only.</summary>
[System.Obsolete("Use CostGroup instead. This field is read for backwards-compat only.")]
public CostEntry[]? Cost { get; set; }
public AbilityRange? Range { get; set; }
/// <summary>How many times this Active ability may be used per turn (default 1).</summary>
@@ -46,6 +62,16 @@ public sealed class AbilityDefinition
/// Null means effects expire at their own configured Duration.
/// </summary>
public DurationModel? LingerDuration { get; set; }
/// <summary>
/// Actions fired once for each unit that enters this aura's range.
/// The entering unit is the resolved target for these actions.
/// </summary>
public ActionGroup? OnEnterAuraActions { get; set; }
/// <summary>
/// Actions fired once for each unit that leaves this aura's range.
/// The leaving unit is the resolved target for these actions.
/// </summary>
public ActionGroup? OnLeaveAuraActions { get; set; }
// ── Triggered only ───────────────────────────────────────────────────────
/// <summary>The event that fires this ability. Must be set for Triggered type.</summary>
+80 -3
View File
@@ -34,6 +34,12 @@ public enum TargetScope { Hand, Deck, Discard, Battlefield, Player, AnyZone
public enum TargetType { Unit, ArchSpirit, Spirit, SpiritToken, Ruin, Tile, Card, Player }
public enum TargetOwnership { Self, ExactSelf, Owner, Ally, Enemy, Any, Random, Target }
/// <summary>
/// Who makes the selection from the valid target pool.
/// Distinct from <see cref="TargetOwnership"/>, which filters whose entities qualify.
/// </summary>
public enum TargetChooser { Self, Opponent, Ally, Random }
public sealed class TargetCount
{
/// <summary>Exact number of targets; or the maximum when UpTo=true.</summary>
@@ -52,7 +58,14 @@ public sealed class TargetSelector
{
public TargetScope Scope { get; set; }
public TargetType Type { get; set; }
/// <summary>Filters whose entities qualify as valid targets.</summary>
public TargetOwnership Ownership { get; set; }
/// <summary>
/// Who makes the selection from the valid target pool.
/// Self/Opponent/Ally emits a <c>PendingTargetPick</c> to the appropriate client.
/// Random resolves immediately server-side with no client prompt.
/// </summary>
public TargetChooser Chooser { get; set; } = TargetChooser.Self;
public TargetCount Count { get; set; } = new();
public Filter[]? Filters { get; set; }
}
@@ -84,13 +97,19 @@ public sealed class Action
// ── ChooseOne ─────────────────────────────────────────────────────────────────
/// <summary>
/// Presents the controlling player with a set of mutually exclusive action branches.
/// Exactly one branch is selected and its actions resolve; other branches are skipped.
/// ChooseOne may appear anywhere an Action[] is accepted.
/// Within a single action step (target already resolved), presents a set of mutually
/// exclusive effect branches. Exactly one branch is selected; others are skipped.
/// Use for "deal damage OR push the same target." For grouping distinct action steps
/// with different targets, use <see cref="ActionGroup"/> instead.
/// </summary>
public sealed class ChooseOne
{
public Branch[] Branches { get; set; } = [];
/// <summary>
/// Who selects the branch.
/// "Self" = controlling player, "Opponent" = opposing player, "Random" = server picks.
/// </summary>
public string ChooserRole { get; set; } = "Self";
}
public sealed class Branch
@@ -99,6 +118,35 @@ public sealed class Branch
public Action[] Actions { get; set; } = [];
}
// ── ActionGroup ───────────────────────────────────────────────────────────────
/// <summary>
/// Logical grouping of ability-level action steps with AND / OR / XOR semantics.
/// Replaces the flat <c>Action[]</c> on <see cref="AbilityDefinition"/>.
///
/// AND — all children execute sequentially (same as the old flat list).
/// OR — the chooser picks exactly one child (leaf Action or nested group) to execute;
/// emits <c>PendingActionGroupPick</c> when ChooserRole is Self or Opponent.
/// XOR — same resolution as OR; signals mutually-exclusive design intent.
///
/// Groups can nest arbitrarily. The engine descends recursively.
/// </summary>
public sealed class ActionGroup
{
public ActionGroupLogicOp LogicOp { get; set; } = ActionGroupLogicOp.And;
/// <summary>
/// For OR/XOR: who selects which child executes.
/// "Self" / "Opponent" emits PendingActionGroupPick. "Random" resolves server-side.
/// </summary>
public string ChooserRole { get; set; } = "Self";
/// <summary>Leaf action steps in this group.</summary>
public Action[] Actions { get; set; } = [];
/// <summary>Nested child groups. Evaluated after leaf Actions in AND mode; same pool as Actions in OR/XOR.</summary>
public ActionGroup[] Groups { get; set; } = [];
}
public enum ActionGroupLogicOp { And, Or, Xor }
// ── Cost entry ────────────────────────────────────────────────────────────────
public enum CostType
@@ -149,6 +197,35 @@ public sealed class CostEntry
public CostPickMode? PickMode { get; set; }
}
// ── CostGroup ─────────────────────────────────────────────────────────────────
/// <summary>
/// Logical grouping of ability costs with AND / OR / XOR semantics.
/// Replaces the flat <c>CostEntry[]</c> on <see cref="AbilityDefinition"/>.
///
/// AND — all entries must be paid (same as the old flat array).
/// OR — the chooser selects one entry or child group to pay;
/// emits <c>PendingCostGroupPick</c> when ChooserRole is Self or Opponent.
/// XOR — same resolution as OR; signals mutually-exclusive design intent.
///
/// Groups can nest arbitrarily. Example: (pay 2 SP AND discard 1 card) OR (pay 6 SP).
/// </summary>
public sealed class CostGroup
{
public CostGroupLogicOp LogicOp { get; set; } = CostGroupLogicOp.And;
/// <summary>
/// For OR/XOR: who selects which option is paid.
/// "Self" / "Opponent" emits PendingCostGroupPick. "Random" resolves server-side.
/// </summary>
public string ChooserRole { get; set; } = "Self";
/// <summary>Leaf cost entries in this group.</summary>
public CostEntry[] Entries { get; set; } = [];
/// <summary>Nested child groups. In AND mode all pay; in OR/XOR the chooser picks one.</summary>
public CostGroup[] Groups { get; set; } = [];
}
public enum CostGroupLogicOp { And, Or, Xor }
// ── Ability range ─────────────────────────────────────────────────────────────
public sealed class AbilityRange
@@ -52,6 +52,19 @@ using SOR.Database.Enums;
[PolyType(typeof(UnitCountOnBattlefieldCondition), "UnitCountOnBattlefield")]
[PolyType(typeof(CardInZoneCondition), "CardInZone")]
[PolyType(typeof(ControlledTileCountWithAffinityCondition), "ControlledTileCountWithAffinity")]
// Extended unit (§6.6)
[PolyType(typeof(UnitTypeIsCondition), "UnitTypeIs")]
[PolyType(typeof(OwnershipIsCondition), "OwnershipIs")]
[PolyType(typeof(IsThisCardCondition), "IsThisCard")]
[PolyType(typeof(UnitPropertyCompareCondition), "UnitPropertyCompare")]
[PolyType(typeof(PlayerPropertyCompareCondition), "PlayerPropertyCompare")]
[PolyType(typeof(HandContainsCountCondition), "HandContainsCount")]
[PolyType(typeof(CardDefinitionCountInZoneCondition),"CardDefinitionCountInZone")]
[PolyType(typeof(IsInRangeOfUnitCondition), "IsInRangeOfUnit")]
[PolyType(typeof(TileOccupantCondition), "TileOccupant")]
[PolyType(typeof(SurroundingTileCondition), "SurroundingTile")]
[PolyType(typeof(SPAccumulationCompareCondition), "SPAccumulationCompare")]
[PolyType(typeof(CostOfCardsInHandCondition), "CostOfCardsInHand")]
public abstract class Condition
{
/// <summary>
@@ -151,3 +164,129 @@ public sealed class ControlledTileCountWithAffinityCondition : Condition
public int N { get; set; }
public string Ownership { get; set; } = "Owner";
}
// ── §6.6 Extended unit conditions ─────────────────────────────────────────────
/// <summary>Subject unit's CardType must match. Values: "Spirit", "ArchSpirit", "SpiritToken".</summary>
[PolyType(typeof(UnitTypeIsCondition), "UnitTypeIs")]
public sealed class UnitTypeIsCondition : Condition
{
public string UnitType { get; set; } = "Spirit";
}
/// <summary>Subject unit is owned by the specified player group.</summary>
[PolyType(typeof(OwnershipIsCondition), "OwnershipIs")]
public sealed class OwnershipIsCondition : Condition
{
/// <summary>"Self" | "Ally" | "Opponent" | "Owner"</summary>
public string Ownership { get; set; } = "Owner";
}
/// <summary>Subject is the exact card instance that owns this ability (by InstanceId).</summary>
[PolyType(typeof(IsThisCardCondition), "IsThisCard")]
public sealed class IsThisCardCondition : Condition { }
/// <summary>
/// Generic numeric comparison against a named unit property.
/// PropertyName values: "Damage", "Defense", "MaxDefense", "Health", "MaxHealth",
/// "MovementPoints", "MaxMovementPoints", "MinAttackRange", "MaxAttackRange",
/// "MinChannelRange", "MaxChannelRange", "Tier".
/// </summary>
[PolyType(typeof(UnitPropertyCompareCondition), "UnitPropertyCompare")]
public sealed class UnitPropertyCompareCondition : Condition
{
public string PropertyName { get; set; } = string.Empty;
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int Value { get; set; }
}
/// <summary>
/// Generic numeric comparison against a named player resource.
/// PropertyName values: "SP", "ST", "SPAccumulation", "HandSize", "DeckSize", "DiscardSize".
/// Subject field ("Self", "Owner", "Ally", "Opponent") identifies which player.
/// </summary>
[PolyType(typeof(PlayerPropertyCompareCondition), "PlayerPropertyCompare")]
public sealed class PlayerPropertyCompareCondition : Condition
{
public string PropertyName { get; set; } = "SP";
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int Value { get; set; }
}
/// <summary>The specified player's hand contains at least N cards of the given type and/or affinity.</summary>
[PolyType(typeof(HandContainsCountCondition), "HandContainsCount")]
public sealed class HandContainsCountCondition : Condition
{
public string? CardType { get; set; } // null = any
public Affinity? Affinity { get; set; } // null = any
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int N { get; set; } = 1;
}
/// <summary>
/// X copies of the source card's definition exist in the given zone(s) for the given ownership.
/// </summary>
[PolyType(typeof(CardDefinitionCountInZoneCondition), "CardDefinitionCountInZone")]
public sealed class CardDefinitionCountInZoneCondition : Condition
{
/// <summary>"Hand" | "Deck" | "Discard" | "Battlefield"</summary>
public string Zone { get; set; } = "Hand";
/// <summary>"Self" | "Ally" | "Opponent" | "Any"</summary>
public string Ownership { get; set; } = "Any";
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int N { get; set; } = 1;
}
/// <summary>Subject unit is within [Min, Max] Manhattan distance of a unit matching type + ownership.</summary>
[PolyType(typeof(IsInRangeOfUnitCondition), "IsInRangeOfUnit")]
public sealed class IsInRangeOfUnitCondition : Condition
{
public int Min { get; set; } = 1;
public int Max { get; set; } = 1;
public string UnitType { get; set; } = "Unit";
public string Ownership { get; set; } = "Any";
public Filter[]? UnitFilters { get; set; }
}
/// <summary>The tile the subject unit occupies is occupied by a unit matching the given type/ownership/filters.</summary>
[PolyType(typeof(TileOccupantCondition), "TileOccupant")]
public sealed class TileOccupantCondition : Condition
{
public string UnitType { get; set; } = "Unit";
public string Ownership { get; set; } = "Any";
public Filter[]? UnitFilters { get; set; }
}
/// <summary>At least N surrounding tiles within [Min, Max] distance match the given affinity/occupancy filters.</summary>
[PolyType(typeof(SurroundingTileCondition), "SurroundingTile")]
public sealed class SurroundingTileCondition : Condition
{
public int Min { get; set; } = 1;
public int Max { get; set; } = 1;
public Comparator TileCountComparator { get; set; } = Comparator.GreaterThanOrEqual;
public int TileCount { get; set; } = 1;
public Filter[]? TileFilters { get; set; }
}
/// <summary>Compares the source player's SP accumulation per turn against a value.</summary>
[PolyType(typeof(SPAccumulationCompareCondition), "SPAccumulationCompare")]
public sealed class SPAccumulationCompareCondition : Condition
{
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int Value { get; set; }
}
/// <summary>
/// The aggregate channeling cost (SP or ST) of cards matching the given filters in the player's hand
/// meets the comparator threshold.
/// </summary>
[PolyType(typeof(CostOfCardsInHandCondition), "CostOfCardsInHand")]
public sealed class CostOfCardsInHandCondition : Condition
{
/// <summary>"SP" | "ST"</summary>
public string CostType { get; set; } = "SP";
public string? CardType { get; set; } // null = any
public Affinity? Affinity { get; set; } // null = any
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int Value { get; set; }
}
+201 -2
View File
@@ -211,8 +211,19 @@ public sealed class HealEffect : Effect { public ValueExpr Amount {
public sealed class DealDamageToSelfEffect : Effect { public ValueExpr Amount { get; set; } = new(); public bool BypassDefense { get; set; } }
public sealed class DOTEffect : Effect { public ValueExpr Amount { get; set; } = new(); public DurationModel Duration { get; set; } = DurationModel.EndOfTurn; public bool BypassDefense { get; set; } }
public sealed class HOTEffect : Effect { public ValueExpr Amount { get; set; } = new(); public DurationModel Duration { get; set; } = DurationModel.EndOfTurn; }
public sealed class PreventDeathEffect : Effect { }
public sealed class PreventNextDamageEffect : Effect { public ValueExpr? MaxAmount { get; set; } }
public sealed class PreventDeathEffect : Effect
{
/// <summary>After preventing death, set the unit's HP to this value instead of leaving at 0. Null = leave at 1.</summary>
public int? DamageTakenSetToHp { get; set; }
/// <summary>When true, the lethal hit's damage is fully ignored (unit takes 0). DamageTakenSetToHp is ignored when this is true.</summary>
public bool DamageIgnored { get; set; }
}
public sealed class PreventNextDamageEffect : Effect
{
public ValueExpr? MaxAmount { get; set; }
/// <summary>How many times this shield can absorb hits before expiring. Default 1.</summary>
public int Times { get; set; } = 1;
}
public sealed class SetHealthMinimumEffect : Effect { public int Minimum { get; set; } = 1; }
public sealed class ClearPreventDeathEffect : Effect { }
public sealed class ClearPreventNextDamageEffect : Effect { }
@@ -268,8 +279,196 @@ public sealed class SummonTokenEffect : Effect
public Filter[]? TileFilter { get; set; }
}
// ── §5.13 ArchSpirit zone operations ─────────────────────────────────────────
[PolyType(typeof(AscendFromZoneEffect), "AscendFromZone")]
[PolyType(typeof(TransitionFromZoneEffect), "TransitionFromZone")]
[PolyType(typeof(ModifyChannelRangeEffect), "ModifyChannelRange")]
// ── §5.14 Ruin manipulation ───────────────────────────────────────────────────
[PolyType(typeof(RelocateRuinEffect), "RelocateRuin")]
[PolyType(typeof(ActivateRuinAbilityEffect), "ActivateRuinAbility")]
[PolyType(typeof(DisableRuinForDurationEffect), "DisableRuinForDuration")]
// ── §5.15 Enhanced channeling ─────────────────────────────────────────────────
[PolyType(typeof(ChannelCardFromZoneEffect), "ChannelCardFromZone")]
// ── §5.16 Token / spirit operations ──────────────────────────────────────────
[PolyType(typeof(CloneSpiritAsTokenEffect), "CloneSpiritAsToken")]
[PolyType(typeof(DestroyTokenEffect), "DestroyToken")]
[PolyType(typeof(ModifySacrificeTokenReturnEffect),"ModifySacrificeTokenReturn")]
// ── §5.17 Player operations ───────────────────────────────────────────────────
[PolyType(typeof(SkipTurnEffect), "SkipTurn")]
[PolyType(typeof(ModifyCardsDrawnThisTurnEffect), "ModifyCardsDrawnThisTurn")]
// ── §5.18 Zone operations ─────────────────────────────────────────────────────
[PolyType(typeof(StackDeckEffect), "StackDeck")]
[PolyType(typeof(SearchAndPlaceEffect), "SearchAndPlace")]
// ── §5.19 Unit manipulation ───────────────────────────────────────────────────
[PolyType(typeof(ChangeAttackTypeEffect), "ChangeAttackType")]
[PolyType(typeof(ObstructMovementTypeEffect), "ObstructMovementType")]
// ── §5.12 Deferred effects ────────────────────────────────────────────────────
// ── §5.13 ArchSpirit zone operations ──────────────────────────────────────────
/// <summary>Ascend the target ArchSpirit using a previous-tier card from the given zone.</summary>
public sealed class AscendFromZoneEffect : Effect
{
/// <summary>"Hand" | "Deck" | "Discard"</summary>
public string Zone { get; set; } = "Hand";
public bool IgnoreCost { get; set; }
}
/// <summary>Transition the target ArchSpirit using a same-tier card from the given zone.</summary>
public sealed class TransitionFromZoneEffect : Effect
{
/// <summary>"Hand" | "Deck" | "Discard"</summary>
public string Zone { get; set; } = "Hand";
public bool IgnoreCost { get; set; }
}
/// <summary>Modify the min and/or max channel range of the target ArchSpirit by the given deltas.</summary>
public sealed class ModifyChannelRangeEffect : Effect
{
public int MinDelta { get; set; }
public int MaxDelta { get; set; }
}
// ── §5.14 Ruin manipulation ───────────────────────────────────────────────────
/// <summary>Move the target Ruin to the tile resolved by the action's TargetSelector.</summary>
public sealed class RelocateRuinEffect : Effect { }
/// <summary>
/// Programmatically activate one of the target Ruin's OnRuinActivation abilities.
/// If Random is true, a random eligible ability is chosen (same as normal activation).
/// If AbilityRef is set, that specific ability is activated.
/// The source-skip guard in FireTrigger must be applied to avoid double-firing.
/// </summary>
public sealed class ActivateRuinAbilityEffect : Effect
{
public string? AbilityRef { get; set; }
public bool Random { get; set; } = true;
/// <summary>When true, all targets for the activated ability are chosen by the ability system rather than the player.</summary>
public bool ChooseAllTargets { get; set; }
}
/// <summary>Disable the target Ruin's abilities for the given duration.</summary>
public sealed class DisableRuinForDurationEffect : Effect
{
public DurationModel Duration { get; set; } = DurationModel.EndOfTurn;
}
// ── §5.15 Enhanced channeling ─────────────────────────────────────────────────
/// <summary>
/// Unified channel-card effect with full zone and constraint control.
/// Supersedes the minimal <see cref="ChannelCardEffect"/>.
/// </summary>
public sealed class ChannelCardFromZoneEffect : Effect
{
/// <summary>"Hand" | "Deck" | "Discard"</summary>
public string Zone { get; set; } = "Hand";
/// <summary>Who controls the channeled unit. "Self" | "Ally" | "Opponent" | "Random" | "Target"</summary>
public string UnderControlOf { get; set; } = "Self";
public bool IgnoreChannelCost { get; set; }
public bool IgnoreTurnConstraint { get; set; }
public bool IgnoreChannelRange { get; set; }
public bool IgnoreAffinity { get; set; }
/// <summary>Keep the card in its original zone after channeling (e.g. Instinct/Repentance with KeepInHand).</summary>
public bool KeepInZone { get; set; }
/// <summary>When true, the player selects the destination tile (removes random placement for Ruins).</summary>
public bool TargetTile { get; set; }
/// <summary>Card must be within the source ArchSpirit's channel range.</summary>
public bool InOwnChannelRange { get; set; }
/// <summary>Card must be within the target ArchSpirit's channel range.</summary>
public bool InTargetChannelRange { get; set; }
public Filter[]? Filters { get; set; }
}
// ── §5.16 Token / spirit operations ──────────────────────────────────────────
/// <summary>
/// Clone the target Spirit as a SpiritToken placed on an adjacent tile or within channel range.
/// </summary>
public sealed class CloneSpiritAsTokenEffect : Effect
{
/// <summary>"NeighborTile" | "RandomInChannelRange" | "TargetTile"</summary>
public string DestinationScope { get; set; } = "NeighborTile";
}
/// <summary>Destroy the target SpiritToken immediately.</summary>
public sealed class DestroyTokenEffect : Effect { }
/// <summary>Override the ST returned to the controlling player when a Spirit is sacrificed.</summary>
public sealed class ModifySacrificeTokenReturnEffect : Effect
{
public int StAmount { get; set; }
}
// ── §5.17 Player operations ───────────────────────────────────────────────────
/// <summary>The target player skips their next turn.</summary>
public sealed class SkipTurnEffect : Effect { }
/// <summary>Add or subtract from the number of cards the target player draws this turn only.</summary>
public sealed class ModifyCardsDrawnThisTurnEffect : Effect
{
public ValueExpr Amount { get; set; } = new();
}
// ── §5.18 Zone operations ─────────────────────────────────────────────────────
/// <summary>
/// Let the controlling player view and reorder the top N cards of the target player's deck.
/// </summary>
public sealed class StackDeckEffect : Effect
{
public int Count { get; set; } = 1;
/// <summary>"Self" | "Opponent" | "Random"</summary>
public string Chooser { get; set; } = "Self";
}
/// <summary>
/// Search the target player's deck for cards matching Filters, put Count of them
/// into the Destination zone, then optionally shuffle the deck.
/// </summary>
public sealed class SearchAndPlaceEffect : Effect
{
public Filter[]? Filters { get; set; }
public int Count { get; set; } = 1;
/// <summary>"Hand" | "Discard" | "Battlefield"</summary>
public string Destination { get; set; } = "Hand";
public bool ShuffleAfter { get; set; } = true;
}
// ── §5.19 Unit manipulation ───────────────────────────────────────────────────
/// <summary>Change the target unit's attack type.</summary>
public sealed class ChangeAttackTypeEffect : Effect
{
public AttackType AttackType { get; set; }
}
/// <summary>
/// Causes the target unit to obstruct a given movement type as if it had that movement type itself.
/// E.g. a ground unit blocking Fly-movement paths.
/// </summary>
public sealed class ObstructMovementTypeEffect : Effect
{
public MovementType MovementType { get; set; }
public DurationModel Duration { get; set; } = DurationModel.EndOfTurn;
}
/// <summary>
/// Schedules effects to fire once the next time the specified trigger event occurs.
/// Consumed after firing. Cancelled if source leaves battlefield before event fires.
@@ -36,6 +36,9 @@ using SOR.Database.Enums;
[PolyType(typeof(TileIsAdjacentToUnitFilter), "TileIsAdjacentToUnit")]
[PolyType(typeof(TileIsOnPlayerSideFilter), "TileIsOnPlayerSide")]
[PolyType(typeof(TileIsInArchSpiritChannelRangeFilter), "TileIsInArchSpiritChannelRange")]
[PolyType(typeof(OwnershipFilter), "Ownership")]
[PolyType(typeof(UnitPropertyFilter), "UnitProperty")]
[PolyType(typeof(TileOccupancyFilter), "TileOccupancy")]
public abstract class Filter { }
// ── Unit / card filter implementations ───────────────────────────────────────
@@ -145,3 +148,41 @@ public sealed class TileIsInArchSpiritChannelRangeFilter : Filter
{
public string Ownership { get; set; } = "Owner";
}
// ── Additional filters ────────────────────────────────────────────────────────
/// <summary>Unit must be owned by the specified player group.</summary>
[PolyType(typeof(OwnershipFilter), "Ownership")]
public sealed class OwnershipFilter : Filter
{
/// <summary>"Self" | "Ally" | "Opponent" | "Owner" | "Any"</summary>
public string Ownership { get; set; } = "Any";
}
/// <summary>Generic numeric comparison against a named unit property.</summary>
[PolyType(typeof(UnitPropertyFilter), "UnitProperty")]
public sealed class UnitPropertyFilter : Filter
{
/// <summary>
/// Property name: "Damage", "Defense", "MaxDefense", "Health", "MaxHealth",
/// "MovementPoints", "MaxMovementPoints", "MinAttackRange", "MaxAttackRange",
/// "MinChannelRange", "MaxChannelRange", "Tier".
/// </summary>
public string PropertyName { get; set; } = string.Empty;
public Comparator Comparator { get; set; } = Comparator.GreaterThanOrEqual;
public int Value { get; set; }
}
/// <summary>
/// Tile must be occupied by a unit of the given type and ownership.
/// Use instead of <see cref="TileIsOccupiedFilter"/> when ownership matters.
/// </summary>
[PolyType(typeof(TileOccupancyFilter), "TileOccupancy")]
public sealed class TileOccupancyFilter : Filter
{
/// <summary>"Spirit" | "ArchSpirit" | "SpiritToken" | "Ruin" | "Unit" (any)</summary>
public string UnitType { get; set; } = "Unit";
/// <summary>"Self" | "Ally" | "Opponent" | "Any"</summary>
public string Ownership { get; set; } = "Any";
public Filter[]? UnitFilters { get; set; }
}
@@ -72,9 +72,11 @@ public sealed class OnTurnEndTrigger : TriggerEvent { public string Player { g
public sealed class OnChanneledTrigger : TriggerEvent
{
public string CardType { get; set; } = "Spirit";
public string Ownership { get; set; } = "Owner";
public Filter? Filter { get; set; }
public string CardType { get; set; } = "Spirit";
public string Ownership { get; set; } = "Owner";
public Filter? Filter { get; set; }
/// <summary>When set, trigger only fires when this exact card definition is channeled.</summary>
public Guid? CardDefinitionId { get; set; }
}
// ── §8.3 ArchSpirit tier actions ──────────────────────────────────────────────
@@ -87,22 +89,42 @@ public sealed class OnTransitionTrigger : TriggerEvent { public string Ownership
public sealed class OnUnitMoveTrigger : TriggerEvent { public string Ownership { get; set; } = "Owner"; public Filter? Filter { get; set; } }
public sealed class OnUnitAttackTrigger : TriggerEvent { public string Ownership { get; set; } = "Owner"; public Filter? Filter { get; set; } }
public sealed class OnUnitAbilityActivatedTrigger : TriggerEvent { public string Ownership { get; set; } = "Owner"; public Filter? Filter { get; set; } }
public sealed class OnUnitMPSpentTrigger : TriggerEvent { public string Ownership { get; set; } = "Owner"; public Filter? Filter { get; set; } public int? Amount { get; set; } }
public sealed class OnUnitMPSpentTrigger : TriggerEvent { public string Ownership { get; set; } = "Owner"; public Filter? Filter { get; set; } public int? Amount { get; set; } public Comparator AmountComparator { get; set; } = Comparator.GreaterThanOrEqual; }
// ── §8.5 Damage and healing ───────────────────────────────────────────────────
public sealed class OnDamageDealtTrigger : TriggerEvent
{
public string SourceOwnership { get; set; } = "Any";
public string TargetOwnership { get; set; } = "Any";
public string DamageType { get; set; } = "Any"; // "HP" | "Defense" | "Any"
public int? Amount { get; set; }
public Filter? SourceFilter { get; set; }
public string SourceOwnership { get; set; } = "Any";
public string TargetOwnership { get; set; } = "Any";
public string DamageType { get; set; } = "Any"; // "HP" | "Defense" | "Any"
public int? Amount { get; set; }
public Comparator AmountComparator { get; set; } = Comparator.GreaterThanOrEqual;
public Filter? SourceFilter { get; set; }
}
public sealed class OnDamagePreventedTrigger : TriggerEvent
{
public string TargetOwnership { get; set; } = "Any";
public Filter? Filter { get; set; }
public int? Amount { get; set; }
public Comparator AmountComparator { get; set; } = Comparator.GreaterThanOrEqual;
}
public sealed class OnHealedTrigger : TriggerEvent
{
public string TargetOwnership { get; set; } = "Any";
public Filter? Filter { get; set; }
public int? Amount { get; set; }
public Comparator AmountComparator { get; set; } = Comparator.GreaterThanOrEqual;
}
public sealed class BeforeUnitDeathTrigger : TriggerEvent { public string UnitType { get; set; } = "Unit"; public string Ownership { get; set; } = "Any"; public Filter? Filter { get; set; } }
public sealed class BeforeDamageAppliedTrigger : TriggerEvent
{
public string SourceOwnership { get; set; } = "Any";
public string TargetOwnership { get; set; } = "Any";
public Filter? Filter { get; set; }
public int? Amount { get; set; }
public Comparator AmountComparator { get; set; } = Comparator.GreaterThanOrEqual;
}
public sealed class OnDamagePreventedTrigger : TriggerEvent { public string TargetOwnership { get; set; } = "Any"; public Filter? Filter { get; set; } }
public sealed class OnHealedTrigger : TriggerEvent { public string TargetOwnership { get; set; } = "Any"; public Filter? Filter { get; set; } public int? Amount { get; set; } }
public sealed class BeforeUnitDeathTrigger : TriggerEvent { public string UnitType { get; set; } = "Unit"; public string Ownership { get; set; } = "Any"; public Filter? Filter { get; set; } }
public sealed class BeforeDamageAppliedTrigger : TriggerEvent { public string SourceOwnership { get; set; } = "Any"; public string TargetOwnership { get; set; } = "Any"; public Filter? Filter { get; set; } }
// ── §8.6 Unit lifecycle ───────────────────────────────────────────────────────
@@ -122,8 +144,21 @@ public sealed class OnGenusChangedTrigger : TriggerEvent { public string Owners
// ── §8.8 Ruin ────────────────────────────────────────────────────────────────
public sealed class OnRuinActivationTrigger : TriggerEvent { public string RuinOwnership { get; set; } = "Any"; public string? OccupantOwnership { get; set; } }
public sealed class OnUnitOccupyRuinTrigger : TriggerEvent { public string UnitOwnership { get; set; } = "Any"; public Filter? Filter { get; set; } }
public sealed class OnRuinActivationTrigger : TriggerEvent
{
public string RuinOwnership { get; set; } = "Any";
public string? OccupantOwnership { get; set; }
/// <summary>Additional filters applied to the occupant unit at the time of Ruin activation.</summary>
public Filter[]? OccupantFilters { get; set; }
}
public sealed class OnUnitOccupyRuinTrigger : TriggerEvent
{
public string UnitOwnership { get; set; } = "Any";
public Filter? Filter { get; set; }
/// <summary>Additional filters applied to the occupying unit.</summary>
public Filter[]? OccupantFilters { get; set; }
}
// ── §8.9 Tile ────────────────────────────────────────────────────────────────