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
+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