feat(ability): implement AbilityBuilderR3 + engine additions

Engine:
- AbilityDefinition: add SourceZoneGate (zone-restricted triggers) and TriggerLimitPerGame
- Effects: add StatModOperator (Add/Subtract/Multiply/Divide/Percent) on all stat mod effects; reversal stored as delta
- Action/CostEntry: add CostPickMode enum (Random/SelfPick/EnemySeePick/EnemyRandomPick/EnemyPick)
- PendingCostPick: new model for interactive cost pause/resume (mirrors PendingTriggeredTarget)
- GameState: PendingCostPick field
- GameMessages: CostPickRequestPush, GameCostPickRequest, GameCostPickResponse records
- AbilitySystem: FireTrigger scans Hand/Discard/Deck when SourceZoneGate set; per-game trigger limit tracking; ApplyStatOperator helper; PayCosts/ResumeCostPick for interactive cost flow
- GameCostPickHandler + ServiceRegistration wiring

Admin:
- AbilityBuilderR3.razor: full ability builder at /cards/ability-builder-r3 (39 triggers, 69 effects, 32 conditions, form/canvas/mermaid modes, compiles to engine-native $type JSON)
- AbilityBuilderR2-Draft.razor: fix switch expression no-best-type error

Docs:
- BuilderR3.md: master plan document

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-18 20:15:13 -04:00
co-authored by Claude Happy
parent 26fa4c810d
commit 8f3911e881
20 changed files with 5290 additions and 133 deletions
+27 -3
View File
@@ -113,16 +113,40 @@ public enum CostType
DealDamageToOwnSpirit,
}
/// <summary>
/// How the player(s) resolve the selection for an interactive cost (e.g. DiscardFromHand).
/// Null / absent: server auto-resolves (picks first N valid candidates).
/// </summary>
public enum CostPickMode
{
/// <summary>Server picks randomly from valid candidates.</summary>
Random,
/// <summary>Controlling player sees and picks which cards to pay.</summary>
SelfPick,
/// <summary>Opponent picks on behalf of the controlling player (sees all options).</summary>
EnemySeePick,
/// <summary>Opponent picks randomly from the controlling player's valid candidates.</summary>
EnemyRandomPick,
/// <summary>Opponent has free choice of which cards the controlling player pays.</summary>
EnemyPick,
}
/// <summary>
/// A single cost element for an Active ability.
/// Multiple CostEntry items must all be paid simultaneously before the ability resolves.
/// </summary>
public sealed class CostEntry
{
public CostType Type { get; set; }
public int Amount { get; set; } = 1;
public CostType Type { get; set; }
public int Amount { get; set; } = 1;
/// <summary>Optional filter for targeted costs (e.g. "Discard a Spirit card from hand").</summary>
public Filter[]? Filters { get; set; }
public Filter[]? Filters { get; set; }
/// <summary>
/// When set, the cost resolution is interactive: a player (controlling or opponent)
/// is prompted to pick which specific cards/units satisfy the cost.
/// Null = auto-resolve (engine picks first N matching candidates).
/// </summary>
public CostPickMode? PickMode { get; set; }
}
// ── Ability range ─────────────────────────────────────────────────────────────