Commit Graph
65 Commits
Author SHA1 Message Date
f3e5363c13 Fix SummonToken tile-filter validation: reject bad picks before costs are paid
Three bugs fixed for abilities like Demonate Leviathan (SummonToken + TileFilter):

1. Server: AbilityUsesThisTurn was incremented (and costs paid) before effect-level
   TileFilter validation ran. Added PreValidateClientTileTargets() called before the
   use-count increment so an invalid tile pick wastes no uses and no sacrificed tokens.

2. Server: SummonToken silently break'd when TileFilter or token-affinity check failed,
   giving the client no error. Changed both to throw GameException("INVALID_TILE").

3. Client: tile_passes_filters() only checked the target selector's filters, not the
   effect-level TileFilter (e.g. SummonToken.tileFilter). Added _collect_effect_tile_filters()
   and TileAffinityMatches handling so invalid tiles are never highlighted or accepted.

Also includes: Art2dUrl/ModelUrl deltas in GameStateDiffer/GameMessages/GameEngine,
unit_mesh_builder token-model URL fallback + shader/tint helpers, ModelCache v3 bump,
Game.gd unit delta merging for art2dUrl/modelUrl.

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>
2026-05-12 07:06:54 -04:00
f7fc4fbdd3 Re-apply aura effects at turn start for units already in range
ModifyMP(Current) and similar per-turn aura bonuses were only applied
once when a unit entered the aura range. The CurrentMp reset at turn
start wiped the bonus without re-applying it.

Added ReapplyAurasAtTurnStart which strips stale tracked effects
(without reversal — the stat reset already undid them) and re-applies
ApplyAuraEffects for active-player units still in range. Called in
NextTurn after the Mp/Defense restore and ExpireActiveEffects.

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>
2026-05-07 14:58:00 -04:00
5482dedcbe fix(game): centralize death resolution, reorder UnitAttack trigger, clear Position on zone transitions
- FireTrigger(UnitAttack) now fires BEFORE ApplyDamage so triggered abilities
  can modify attacker/target stats before damage lands
- AbilitySystem.KillUnit is now leader-aware: killing an ArchSpirit (in field
  or ArchSpirit slot) calls GameEngine.EliminatePlayer instead of silently failing
- MoveToDiscard and RemoveFromAllZones both clear Position = null on zone transitions
- RemoveFromAllZones guards against direct ArchSpirit removal (throws InvalidOperationException)
- EliminatePlayer made internal for cross-class access from AbilitySystem
- Client: improved JSON parsing error handling in Network.gd; debug_output enabled in Game.gd

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>
2026-05-05 15:58:45 -04:00
dingo ee21346fb0 Client fixes, and ability fixes 2026-04-30 19:27:52 -04:00
b985445ae9 fix(game): revert UntilEndOfTurn effects on ArchSpirit targets; add action-level duration to ability builder
- ApplyReversal and TickActiveEffects were searching p.Field/Hand/Deck/Discard
  but not p.ArchSpirit, so effects applied to an ArchSpirit (e.g. SetCanBeAttacked=false
  from "Branch Between Fangs") were never reverted — the tracking entry was removed
  but CanBeAttacked stayed false permanently
- Fixes by adding p.ArchSpirit to the target lookup in both functions, matching
  the existing pattern in FindTargetByRef
- AbilityBuilder: add action-level Duration field to ActionDraft, compile/parse it
  in CompileActionNode/ParseActionNode, and expose a UI dropdown on each action
- ClearOnLeave now defaults to true in AbilityDefinition and AbilityBuilder
- Instinct/Repentance card click now correctly enters ABILITY_TARGET mode

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>
2026-04-29 07:20:51 -04:00
2575d700f4 fix(ability): apply cost.Filters to interactive pick candidates and resume validation
PayCosts now filters rawCandidates through FiltersMatch before building
CandidatesJson, so only eligible cards are offered to the picker.

ResumeCostPick now deserialises FiltersJson, resolves the source unit early
for a complete filter context, and validates each client-selected card against
the stored filters before executing the cost — rejecting invalid selections
with INVALID_COST_PICK_SELECTION.

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>
2026-04-21 17:28:20 -04:00
7a917cf93b fix(ability-prompts): fix 3 client wiring gaps
1. JSON case normalization
   Parse CostGroupJson, ActionGroupJson, BranchesJson, RevealedCardsJson
   through _normalize_keys in game_screen.gd — server serialises these
   inner payloads with _jsonOpts (no naming policy = PascalCase), but the
   client was reading lowercase keys, producing empty option lists.

2. Cost pick candidate list
   - Add CandidatesJson to PendingCostPick; populated in AbilitySystem.PayCosts
     with the actor's eligible cards (hand for DiscardFromHand, field spirits
     for SendSpiritFromBattlefieldToDiscard / DealDamageToOwnSpirit).
   - Thread CandidatesJson through CostPickRequestPush → GameHandlerBase push.
   - Client _on_cost_pick_request now uses candidatesJson from the push instead
     of Game.get_my_player().hand, fixing opponent-pick and battlefield-cost UIs.

3. Reconnect recovery via game.get_state
   - Extract all pending-prompt pushes into static PushPendingPromptsAsync in
     GameHandlerBase (called from PushStateToPlayersAsync as before).
   - Inject IClientPush into GameGetStateHandler; call PushPendingPromptsAsync
     after building the reply so any active pause prompt is re-sent to the
     chooser on manual state sync / reconnect.

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>
2026-04-21 17:13:04 -04:00
473e5b075e fix(abilities): nested pause during intra-action replay captures correct remainder
When ApplyIntraActionContinuation replays IntraActionStep items and a step's
effect itself pauses (emitting PendingTilePick / PendingPlayerPick /
PendingRevealChoicePick), the new pause model may already have an
IntraActionContinuationJson written by BuildIntraActionContinuationJson.
That value is wrong in the replay context because BuildIntraActionContinuationJson
assumes all remaining targets get the same homogeneous effect list, whereas
IntraActionStep items each carry their own per-step effect list.

Fix: convert ApplyIntraActionContinuation loops to indexed, set ctx position
fields (CurrentEffectIndex, CurrentActionAllEffects, CurrentActionTargets,
CurrentTargetIndex, CurrentActionDuration) per iteration for consistency, then
after any nested pause override the IntraActionContinuationJson directly via
new SetPendingIntraActionContinuation helper.  The override is built from the
precise remaining slice:
  - remaining effects on the current step's target  (effects[(ei+1)..])
  - all remaining steps as-is                       (steps[(si+1)..])
This is correct regardless of whether different steps have different effect lists.

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>
2026-04-21 11:30:01 -04:00
0b7742f724 fix(abilities): general intra-action continuation for effect-level pauses
Previously, pausing effects (CloneSpiritAsToken/TargetTile,
ChannelCardFromZone/TargetTile+Choice, StackDeck interactive) only stored
the outer action-sequence continuation. Any effects after the pausing one on
the same target, and any remaining targets in the same action, were silently
dropped on resume. This commit makes pause/resume fully general.

Mechanism:
- New IntraActionStep private class: { TargetRef, EffectsJson }
- BuildIntraActionContinuationJson(currentTarget, ctx) captures:
    • remaining effects on the paused target (effects[effectIndex+1..])
    • all effects applied to each remaining target (targets[targetIndex+1..])
- ApplyIntraActionContinuation applies those steps at resume time before
  the outer continuation actions
- FindTargetByRef / GetTargetRef round-trip any resolved target type
  (FieldCard, CardInstance, PlayerState, Coord) through a string ref

AbilityContext gains 5 per-iteration tracking fields set by ExecuteSingleAction:
  CurrentEffectIndex, CurrentTargetIndex, CurrentActionTargets,
  CurrentActionAllEffects, CurrentActionDuration

ExecuteSingleAction target/effect loops converted from foreach to indexed
for-loops so ctx position fields stay in sync with each ExecuteEffect call.

IntraActionContinuationJson added to PendingTilePick, PendingPlayerPick,
and PendingRevealChoicePick. All three pause-emitting cases (CloneSpiritAsToken,
ChannelCardFromZone x2, StackDeck) populate it. All three resume methods
(ResumeTilePick, ResumePlayerPick, ResumeRevealChoicePick) call
ApplyIntraActionContinuation before executing outer continuation.

ChannelCardFromZone player-pick-to-tile-pick chain now forwards
IntraActionContinuationJson so it survives a double-pause sequence.

The "DESIGN CONSTRAINT: pausing effects must be terminal" comment is removed
as it is no longer true.

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>
2026-04-21 11:12:57 -04:00
ac0215fab3 fix(abilities): pause/resume ordering and continuation correctness
Issue 1 — ActionGroup AND continuation ordering:
  The old code prepended `all` (preceding AND-group actions) into
  ContinuationActionsJson, so resume ran [chosen, preceding, outer] instead
  of the correct [preceding, chosen, outer].  Fix: add PrecedingActionsJson
  to PendingActionGroupPick; AND-case stores preceding there (prepending to
  any inner-group preceding); ResumeActionGroupPick reads it and uses
  preceding.Concat(chosen).Concat(continuation) for final execution.
  Nested remaining-group pauses also accumulate preceding correctly.

Issue 2 — Effect-level pause terminal contract:
  Documented as a design constraint: pausing effects (CloneSpiritAsToken
  TargetTile, ChannelCardFromZone TargetTile/Choice) must be last in their
  action's Effects list.  Remaining effects / remaining targets are silently
  dropped on pause.  No functional change; constraint is now explicit in code.

Issue 3 — StackDeck pause loses continuation:
  PendingRevealChoicePick already had ContinuationActionsJson/RangeJson/
  ForceDurationJson fields but StackDeckEffect never populated them and
  ResumeRevealChoicePick never executed them.  Both are now fixed: pause
  stores ctx.ContinuationActions + ctx.ActivationRange + duration; resume
  runs ExecuteActions on the stored continuation after ordering the deck.

Issue 4 — ResumeTargetPick ActionIndex=0 contract:
  Added a clear CONTRACT comment: the paused action replays at index 0, so
  the client must submit targets with ActionIndex=0 in its response.

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>
2026-04-21 07:43:22 -04:00
0e85441fa1 feat(phase10): ChannelCardFromZone, ObstructMovementType, and pause-model completions
- Implement ChannelCardFromZoneEffect: zone lookup, dest-player resolution
  (Self/Target/Opponent/Ally/Random/Choice), channel-range tile selection,
  affinity check, cost deduction, KeepInZone, TargetTile pause, board
  placement with aura/passive hooks and Channeled trigger
- Add PendingPlayerPick.EffectType="ChannelCardFromZone" dispatch in
  ResumePlayerPick: random-tile path + chained PendingTilePick for
  TargetTile=true
- Add ResumeTilePick case "ChannelCardFromZone": place card at chosen tile
  under DestPlayerAccountId, affinity/cost/KeepInZone-aware
- Implement ObstructMovementTypeEffect: stores ActiveEffect marker;
  ApplyReversal is no-op (duration:null guard); BuildBlockedSet extended
  via AbilitySystem.GetUnitsObstructingMovementType to honour obstructors
  for pathfinding (e.g. Walk unit blocking Flight paths)
- Add PendingTilePick.DestPlayerAccountId and .EffectJson fields
- Add PendingPlayerPick.EffectJson field
- Thread ctx.ContinuationActions + ctx.ActivationRange through
  AbilityContext so ExecuteEffect can populate pause models without an
  extra method parameter

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>
2026-04-21 07:34:17 -04:00
95c01cffb5 feat(phase9): ability system gap fixes -- pause propagation, handlers, chooser, aura actions
- Fix pause propagation: ExecuteActions for-loop breaks on HasPendingInteraction();
  effect loop in ExecuteSingleAction also stops when any pending state is set
- Add HasPendingInteraction() helper to GameState covering all 7 pending types
- Create 4 missing handlers: GameCostGroupPickHandler, GameActionGroupPickHandler,
  GameBranchPickHandler, GameRevealChoicePickHandler + register in ServiceRegistration
- Add corresponding request/response records to GameMessages.cs
- Fix ActionNeedsClientTargets: short-circuit false when Chooser == Random
- Add ChooserActorId to PendingTriggeredTarget; FireTrigger sets it to opponent/ally
  when Chooser.Opponent/Ally; GameHandlerBase pushes to ChooserActorId
- ResumeTriggeredAbility validates against ChooserActorId (falls back to ActorId)
- Fix ApplyOnEventEffect: Action[] -> ActionGroup?; PendingDeferredEffect gains
  ActionGroupJson field; deferred firing uses ResolveActionGroup + ExecuteActions
- Wire OnEnterAuraActions / OnLeaveAuraActions into FireAuraTransition (one-shot,
  restricted to the entering/leaving unit)

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>
2026-04-21 06:09:32 -04:00
80b92b17b9 feat(phase8): complete remaining 3 gaps -- pending types, StackDeck interactive, canvas builder
Pending interaction coverage:
- Add PendingTilePick model (tile-select pause for effects like CloneSpiritAsToken TargetTile)
- Add PendingPlayerPick model (player-select pause for ChannelCardFromZone UnderControlOf: Choice)
- Add PendingRevealChoicePick model (reveal-and-order pause for StackDeck interactive path)
- Add all three as nullable properties on GameState

StackDeckEffect interactive flow:
- Replace random-shuffle fallback with chooser-aware branching
- Self/Opponent chooser: remove top N from deck, emit PendingRevealChoicePick pause
- Random/empty chooser: random shuffle fallback (unchanged)
- Add ResumeRevealChoicePick(): restore deck in chooser's ordered indices; unspecified
  cards placed beneath chosen cards preserving relative order

Canvas AbilityBuilder (Phase 4 spec):
- Add @inject IJSRuntime + @implements IAsyncDisposable to AbilityBuilder.razor
- Add sorAdmin.abilityBuilder JS shim in admin.js: non-passive wheel listener (zoom),
  pinch-to-zoom via touch distance delta, cleanup on dispose
- Canvas mode toggle button in form toolbar ("Visual Canvas")
- Full canvas layout: left panel (ability list + node palette), main canvas, right inspector
- Dark canvas background (#111827), CSS transform pan+zoom (translate then scale)
- SVG bezier edge overlay connecting node flow (Meta→Range/Trigger→Cost→Cond→ActionGroup
  →Actions→Effects, ActionGroup→SubGroups→their Actions→their Effects)
- Node types: Meta (blue), Range (teal), Trigger (purple), Cost (amber), Conditions (yellow),
  ActionGroup (dark green), Action (green), Effect (red), SubGroup (dark green), SubGroupAction,
  SubGroupEffect -- each draggable, click-to-select
- Inspector panel: inline editing for all node types (type/name/desc, range fields, trigger
  event, group logic op, action target selector, effect type picker)
- AutoLayoutAbility() positions nodes on first focus; SetPos() preserves drag positions
- Zoom/pan: toolbar +/- buttons + scroll wheel (via JS) + middle-mouse drag
- OnCanvasWheel [JSInvokable] + DisposeAsync cleanup
- Form view toggle restores full form; JSON preview always visible

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>
2026-04-20 20:27:20 -04:00
1d5ae4aa20 feat(phase7): complete ability revamp gap items 1-11
- Fix [PolyType] attribute placement bug in Effects.cs (silent poly-deser failure)
- Add SpiritToken guard to BazaarBuyPrebuiltDeck and CollectionSelectStarterDeck handlers
- Wire CostGroup payment into ActivateAbility with PendingCostGroupPick pause support
- Add PendingActionGroupPick, PendingCostGroupPick, PendingBranchPick models + GameState props
- Add Phase 5 engine switch cases: ModifyChannelRange, RelocateRuin, ActivateRuinAbility,
  DisableRuinForDuration, CloneSpiritAsToken, DestroyToken, SkipTurn, ModifyCardsDrawnThisTurn,
  StackDeck, SearchAndPlace, ChangeAttackType, ObstructMovement, AscendFromZone stubs
- Add ActionGroup recursion (ResolveActionGroup AND-flatten / OR-XOR interactive pick)
- Add ResumeActionGroupPick, ResumeCostGroupPick, ResumeBranchPick methods
- Add ChooseOne ChooserRole branching + TargetSelector.Chooser (Random early-return)
- Change SearchDeckEffect.ThenAction → ThenGroup: ActionGroup?
- Change ApplyOnEventEffect.Effects → Actions: Action[]
- Add SOR.Tools console project with cutover-abilities command (EffectsJsonCutover)
- AbilityBuilder: add ActionGroupDraft, SubGroups, Compile Groups[], ParseJson Groups[],
  CompileActionNode/ParseActionNode helpers, nested sub-group UI section
- Add Tile.RuinDisabledUntilTurn, PlayerState.SkipTurnCount/CardsDrawnThisTurnBonus,
  CardInstance.AttackType nullable override
- Add SOR.Tools to solution

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>
2026-04-20 19:47:38 -04:00
178f5612a8 feat(phase5+6): engine ActionGroup compat, new conditions, Ruin bug fixes
Phase 5.1a — ActionGroup backward-compat in AbilitySystem:
- Add GetEffectiveActions(def): prefers ActionGroup.Actions (AND=sequential,
  OR/XOR=random pick); falls back to obsolete def.Actions for pre-Phase-1 rows.
- Wire all FireAbility, FireCardEffects, FireTrigger, FireRuinAbilities call
  sites to use GetEffectiveActions instead of def.Actions directly.

Phase 5.9 — 12 new EvaluateCondition cases (§6.6):
UnitTypeIs, OwnershipIs, IsThisCard, UnitPropertyCompare, PlayerPropertyCompare,
HandContainsCount, CardDefinitionCountInZone, IsInRangeOfUnit, TileOccupant,
SurroundingTile, SPAccumulationCompare, CostOfCardsInHand.
Add CompareInt(Comparator, int, int) helper to DRY up comparator switch.

Phase 6-D — Fix double-fire of source Ruin's OnRuinActivation abilities:
Insert source-skip guard in FireTrigger after TriggerMatches check:
skip OnRuinActivationTrigger on the card whose InstanceId == occurrence.Data.SourceId.
FireRuinAbilities already executed the chosen ability directly; the subsequent
FireTrigger is only for observer cards.

Phase 6-C — Ruin tile placement must not overwrite existing Ruins (GameEngine.cs):
Add `&& t.RuinId == null` to the validTiles Where clause.
Change error code NO_VALID_TILE → NO_VALID_RUIN_TILE for this path.

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>
2026-04-20 13:57:15 -04:00
768dfcee86 feat(phase2): ability revamp DB migration -- add SpiritToken, drop EffectsJson
- Add CardType.SpiritToken enum value (stored as text, no Postgres enum change)
- Drop catalog.card_definitions.effects column (migration 20260419170135)
  with safety-pass to copy any remaining effects -> abilities before drop
- Remove CardDefinition.EffectsJson property and CatalogDbContext mapping
- Remove CardInstance.EffectsJson snapshot from GameState/GameEngine
- Remove EffectsJson from all DTOs: UnitDelta, CardUpdateDto, ContentCardDto
- Remove EffectsJson from GameStateDiffer, ContentDtoMapper, CardEditor, CardReport
- Simplify AbilitySystem.FireCardEffects to use AbilitiesJson only (no fallback)
- Enforce SpiritToken exclusion in CollectionAddCardHandler (deck builds)
- Enforce SpiritToken exclusion in BazaarBuyBoosterPackHandler (pack draws)

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>
2026-04-19 13:02:24 -04:00
3b8de2deac 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>
2026-04-19 12:35:55 -04:00
8f3911e881 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>
2026-04-18 20:15:13 -04:00
b4062d8179 feat: add active effects inspector to tile drawer
- Track active effects with human-readable labels in AbilitySystem
  (LabelFromReversal/LabelFromTick for stat mods, status flags, DOT/HOT)
- Add ActiveEffectDto to GameStateDto and GameStateDelta; delta now
  always includes the full effects list so clients are never stale
- Add ResolveLabelFromEffectJson fallback for effects stored before the
  Label field was introduced (old game sessions show correct labels)
- Client _append_active_effect_lines helper filters activeEffects by
  targetRef and appends formatted lines to the tile drawer for spirits,
  archspirits, spirit tokens, and ruins

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>
2026-04-14 11:52:37 -04:00
515bfaabdf Implement triggered ability target prompting (Option D)
When a Triggered ability fires and any of its actions require a human target
pick, the server now pauses execution instead of auto-resolving:

Server:
- AbilitySystem.FireTrigger detects actions needing client input via
  ActionNeedsClientTargets(); stores PendingTriggeredTarget in GameState and
  returns early rather than executing the ability
- PushStateToPlayersAsync (GameHandlerBase) checks for PendingTriggeredTarget
  after every state push and sends a game.ability.triggered_target_request push
  to the owning player carrying the action definition and range
- New GameTriggeredTargetHandler (game.triggered_target) receives the player's
  picks, calls AbilitySystem.ResumeTriggeredAbility, and broadcasts the result
- PendingTriggeredTarget model stored in GameState.PendingTriggeredTarget (JSONB)

Client:
- Game.gd handles the triggered_target_request push and emits a signal
- game_screen.gd connects the signal, re-uses the existing ABILITY_TARGET mode
  and _start_ability_targeting() flow, then sends game.triggered_target instead
  of game.activate_ability when done
- A brief banner ("Triggered: <name> — select a target") informs the player

"Warrant Cover" (OnChanneled, Owner unit pick) will now correctly prompt the
player to select which friendly unit gains +1 Defense.

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>
2026-03-28 18:50:48 -04:00
2e3e284023 Fix ability targeting gaps: multi-target, UpTo, ChooseOne, LinearOnly, RequiresLos
- AbilityTarget: add BranchIndex for ChooseOne branch selection
- Action: add ChooseOne? property; when set the action is a branch selector
- AbilitySystem: ExecuteSingleAction handles ChooseOne — reads BranchIndex
  from client targets, executes chosen branch actions (auto-resolved)
- game_screen.gd: count.N > 1 — input handler now accumulates targets until
  N collected before advancing to next action
- game_screen.gd: count.UpTo — show "Done Selecting" confirm button so player
  can finish with fewer than N targets
- game_screen.gd: ChooseOne — detect chooseone key in action dict, show branch
  panel with labelled buttons, record branchIndex in target payload
- game_screen.gd: LinearOnly — _is_linear() filter applied to both tile and
  unit highlights when ability range has linearonly=true
- game_screen.gd: RequiresLos — _client_has_los() supercover DDA (matches
  server LineOfSight.HasLos) applied to highlights when requireslos=true

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>
2026-03-28 16:27:47 -04:00
Shard 8f0ed9d68f Implement phase-3 adjacency, movement-state, and tile-control ability primitives 2026-03-27 17:58:02 +00:00
Shard e887a8c670 Implement phase-2 prevention/replacement triggers and sequence duration 2026-03-27 17:44:31 +00:00
Shard 9e4fbd12a7 Add phase-1 ability primitives and builder support 2026-03-27 15:40:57 +00:00
Shard 84284be4d0 Fix active ability target gating for server-resolved ownership scopes 2026-03-26 14:32:31 +00:00
f700fd5de6 Implement multiplayer extension: 2-10 players FFA/Team/Multi-Team
Core engine:
- Add SeatIndex, TeamIndex, IsEliminated to PlayerState
- Add SeatOrder, GameMode to GameState with helpers: ActiveSeats(),
  GetNextActiveSeat(), GetEnemyIds(), AreAllies()
- Add StartingZones to Board for per-seat placement validation
- Add BoardShape, PlayerCount to GameRules
- New BoardShapeGenerator: Rectangle (up to 4 seats) + Cross shapes
- N-player Initialize() overload; old 2-player overload delegates to it
- EndTurn uses GetNextActiveSeat() instead of hardcoded GetOpponentId()
- Attack finds target across all enemy players; EliminatePlayer() helper
  allows multi-player elimination without immediate game over
- PlaceArchSpirit validates via StartingZones (legacy row fallback preserved)
- AbilitySystem.Own() uses AreAllies() for team-aware ownership checks

Database:
- GameSession: +player_count, +game_mode, +additional_players_json
- CustomLobby: +game_mode, +team_count, +additional_players_json
- EF migration: AddMultiplayerSlots (applied)

Handlers:
- GameCreateCustomLobbyHandler: honours MaxPlayers/GameMode/TeamCount from request
- GameJoinCustomLobbyHandler: multi-slot join up to MaxPlayers
- GameLobbyReadyHandler: N-player all-ready check; seats/team assignment by mode
- GameReadyHandler: builds N-player list from AdditionalPlayersJson
- GameHandlerBase.LoadActiveSessionAsync: recognises additional players

Client:
- Game.gd: get_opponents() returns all non-local players;
  get_opponent() kept as backward-compat alias returning first opponent

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>
2026-03-25 23:57:36 -04:00
c692d8ec64 Implement UnitSentToDiscard trigger — enables Bloodlust abilities
New TriggerEventKind.UnitSentToDiscard fires whenever a unit is moved to the
discard pile, carrying SourceId = the killer unit's instance ID and
ActorId = the victim's player — consistent with UnitDeath convention.

Wired in 4 paths:
- GameEngine.cs attack: attacker killed by counterattack (SourceId = target)
- GameEngine.cs attack: target killed by attacker (SourceId = attacker)
- AbilitySystem KillUnit: ability/effect-driven death (SourceId = ctx.Source)
- AbilitySystem SendToDiscardEffect: direct discard effect (SourceId = ctx.Source)

OnUnitSentToDiscardTrigger is now matched in TriggerMatches. CausedBy field
acts as killer ownership scope; CausedBy="ExactSelf" checks SourceId == this
unit's InstanceId via the existing Own() helper, enabling:

  Bloodlust Aggression:
    { type:"OnUnitSentToDiscard", unitType:"Spirit", ownership:"Enemy",
      causedBy:"ExactSelf" }
    → ModifyDamageEffect { Amount:1 }, Duration: PermanentInMatch

  Bloodlust Vitality:
    { type:"OnUnitSentToDiscard", unitType:"Spirit", ownership:"Enemy",
      causedBy:"ExactSelf" }
    → ModifyMPEffect { Amount:1, StatTarget:"Max" }, Duration: UntilEndOfTurn

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>
2026-03-25 21:14:44 -04:00
2a15bd2eb3 Fix crashes, add ModifyAttackRange effects, ArchSpirit swap in deck editor
- Bazaar Deck tab crash: null-safe float conversion for usdPrice in store_item_row.gd
- Leaderboard crash: freed-object guard in _on_leaderboard_ok (is_instance_valid check)
- Add ModifyMinAttackRangeEffect / ModifyMaxAttackRangeEffect with clamp-to-0 and correct reversal tracking
- AbilityBuilder: add new range effects to Stat Modification group + _amountOnlyTypes
- collection.set_arch_spirit: new handler, request record, and service registration
- Deck editor: show Tier-1 commander row with Change button + ArchSpirit picker panel

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>
2026-03-25 11:25:44 -04:00
9c42e5c1c8 Aura: self-apply Actions + ClearOnLeave / LingerDuration on leave
Previously, Aura abilities only fired OnEnterAuraRange / OnLeaveAuraRange
trigger events — their own Actions were never executed. Auras now directly
apply their Actions to any unit that enters range (using WhileSourceOnBattlefield
by default) and handle departure via three modes:

- Persist (default): effects expire at their configured Duration unchanged
- ClearOnLeave: effects are reverted immediately when the unit leaves range
- LingerDuration: effects switch to the specified duration when leaving range,
  allowing them to outlive the aura's reach (and the source if it leaves)

Server:
- AbilityDefinition: add ClearOnLeave (bool) and LingerDuration (DurationModel?)
- AbilitySystem: add ApplyAuraEffects + HandleAuraLeave helpers;
  refactor FireAuraTransition to take FieldCard + AbilityDefinition and call
  both helpers; update all six call sites in EvaluateAuraTransitions /
  EvaluateAurasOnEnter / EvaluateAurasOnLeave to use the unified path

Admin:
- AbilityBuilder: add AuraClearOnLeave / AuraLingerDurationStr / N draft fields;
  parse + compile round-trip; 3-radio On Leave UI + optional Linger duration select;
  update Aura help row to describe the new behaviour

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>
2026-03-24 21:11:56 -04:00
afb083093a Hill Training: ExactSelf trigger + TileAffinityMatches FieldCard fix
- AbilitySystem: add TileAffinityMatchesCondition case for FieldCard subject
  so activation conditions check the tile the unit is currently standing on
  (previously only handled Coord subjects; triggered abilities pass FieldCard)
- AbilityBuilder: add "ExactSelf" to OwnershipValues dropdown for trigger events
  so designers can restrict triggers to only this specific unit instance
- AbilityBuilder help section: add Trigger Ownership table documenting all
  ownership values including ExactSelf with clear explanation of instance-level scope

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>
2026-03-23 14:23:30 -04:00
dingo 2b7b6aa2ba Fixed but in AbilitySystem for resolving affinity 2026-03-23 13:55:36 -04:00
a870f2391b Add AffinitySystem.Decompose + fix SetAffinity for non-basic affinities
SetAffinity previously hardcoded Base1=Void which is only correct for
basic affinities. Non-basics like Jungle need (Forest,Forest), Island
needs (Lake,Hill), etc. — Void+Jungle would fall through to PureVoid.

Added AffinitySystem.Decompose(Affinity) which reverse-maps every
resolved affinity to its canonical (Base1, Base2) pair. SetAffinity
on tiles now calls Decompose so any affinity — basic or non-basic —
is stored correctly and Resolve() returns the intended value.

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>
2026-03-23 13:04:01 -04:00
04dd457efa Fix SetAffinity tile layout: Base1=Void, Base2=affinity
Setting both slots to the same basic affinity produces the wrong
resolved value (Lake+Lake→Ocean). Basic tiles are represented as
(Void, Basic) per §8, so SetAffinity now sets Base1=Void and
Base2=newAffinity. Both original slot values are still tracked
for reversal when the duration expires.

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>
2026-03-23 13:01:08 -04:00
a768f1b27c Fix Battlefield tile targeting and SetAffinity on tiles
Bug: Battlefield/All tile targets were always empty — the tile
resolution path required client-provided coords for every case,
but board-wide abilities (Scope=Battlefield, All=true) never send
coords from the client. Added server-side enumeration of all board
tiles for this case.

Fix: SetAffinity on a tile now writes both Base1 and Base2 to
the new affinity so AffinitySystem.Resolve returns the correct
value unambiguously. Reversal tracks both slots independently so
both are restored when the duration expires.

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>
2026-03-23 12:33:03 -04:00
14609428e6 Fix three bugs blocking SetAffinity on tile targets
Bug 1 — SetAffinityEffect silently ignored for Coord targets:
ExecuteEffect had no tile case for SetAffinityEffect (only handled
CardInstance). Added case that writes to Base2 and tracks the original
value for duration reversal using a "tile:X,Y" target ref.

Bug 2 — ApplyReversal couldn't find tile targets:
The reversal lookup only searched players' card zones. Added parsing
of the "tile:X,Y" ref format to produce the Coord used to re-execute
the SetBaseAffinity2 reversal effect.

Bug 3 — TileIsOccupied / TileIsUnoccupied / TileAffinityMatches
conditions not implemented in EvaluateCondition:
All three tile condition types fell through to the default (return true),
so conditions like TileIsOccupied were silently no-ops. Implemented all
three with proper tile lookup and occupant/affinity checks.

Wavecrasher (SetAffinity Lake on occupied tiles, ForNTurns:2) now
correctly selects only occupied tiles, changes their affinity, and
reverts them automatically after two turns.

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>
2026-03-23 12:23:39 -04:00
324537ded0 SummonToken: structured admin editor + affinity enforcement + art URLs
- AbilityBuilder.razor: replace raw JSON textarea with full structured
  editor for SummonToken effects. Supports two modes:
  • Existing Card — searchable autocomplete from Spirit card catalog
  • Custom Token — inline editor for all Spirit stats (name, affinity,
    health/defense/damage, movement type/MP, attack range, LOS, all
    permission flags, genus tags, abilities JSON, 2D art URL, 3D model URL)
  Compiles TileFilter[TileAffinityMatchesFilter] when affinity is non-Void,
  enabling client-side tile highlighting to match server enforcement.

- AbilitySystem.cs (SummonTokenEffect): validate that the target tile's
  affinity is compatible with the token's affinity before placing.

- GameState.cs (CardInstance): add Art2dUrl + ModelUrl so summoned tokens
  can carry visual asset references through the game state.

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>
2026-03-22 16:15:36 -04:00
23643d0934 Fix ArchSpirit ability activation + Ownership:Target auto-resolution
- AbilitySystem.cs: ActivateAbility was only searching player.Field for the
  source unit, but player.ArchSpirit is stored in a separate field and was never
  checked. Active abilities on an ArchSpirit now work correctly.

- game_screen.gd: Add "Target" to auto_ownerships so the client skips the
  player-picker UI for Ownership:Target actions. The server auto-resolves them
  from ctx.ResolvedTargets (the owner of the previously targeted card), which
  is exactly what Bounce needs: refund SP to the owner of the returned spirit
  without asking the user to choose a player.

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>
2026-03-22 10:42:56 -04:00
2c737458a8 Fix ability builder crash + implement TargetOwnership.Target for Player targets
- AbilityBuilder.razor: ReadFixed now checks if the JSON node is a JsonObject
  before calling GetValue<int>() on it. Previously, a ValueExpr like
  {"Ref":"Target.SpCost"} caused an InvalidOperationException that was swallowed
  silently by ParseJson's catch block, leaving the builder showing no abilities.

- AbilitySystem.cs: TargetOwnership.Target on Player-type selectors now resolves
  to the owner of the last CardInstance in ctx.ResolvedTargets. This enables
  abilities like Bounce: Action 1 returns a spirit to hand, Action 2 targets that
  spirit's owner (Ownership:Target) to refund its channel cost via a Ref value.

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>
2026-03-22 10:21:35 -04:00
Shard 7d572ae55c Standardize active ability execution between unit and card paths 2026-03-19 23:53:05 +00:00
Shard 7ca86ce858 Enforce CanMove and CanUseAbility suppression in game flow 2026-03-19 22:55:04 +00:00
Shard 7a90e2b8ab Unify ability schema: canonical AbilitiesJson with EffectsJson compatibility 2026-03-19 21:20:27 +00:00
e9476a3775 Fix ReturnToHandEffect: revoke passives + skip target conditions at activation
- Skip ActivationConditions with Subject=="Target" in ActivateAbility (mirrors
  AbilitiesJson code path) so conditions like IsOnTileWithAffinity{Target,Lake}
  aren't evaluated against the source unit at activation time
- Add RevokePassivesForSource call in ReturnToHandEffect before removing the
  unit from the field, matching SendToDiscardEffect pattern

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>
2026-03-19 15:49:16 -04:00
adae8cfc43 Fix: ValueExpr now resolves Target.* and ActionN.Target.* references
Extends ResolveValue to support dynamic references to the resolved target's
properties (SpCost, StCost, Damage, Health, Defense, MP). Also adds Self.SpCost
and Self.StCost.

Usage in ability JSON:
  {"Ref": "Target.SpCost"}        — current action's target's SP cost
  {"Ref": "Action0.Target.SpCost"} — cross-action: action 0's target's SP cost

Enables effects like "return target to hand and refund its channel cost":
  Action 0: Target spirit → ReturnToHand
  Action 1: Target Owner (Player) → ModifySP {"Ref": "Action0.Target.SpCost"}

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>
2026-03-18 14:32:11 -04:00
5d3ee92553 Fix: Repentance/Instinct card target selection + server active ability execution
Client: Repentance/Instinct cards with Active abilities in abilitiesJson now
enter ABILITY_TARGET mode instead of sending play_card immediately. Units on
matching tile affinities (IsOnTileWithAffinity) are highlighted in blue; the
player clicks a target unit and the card is sent with the selected unit target.

Server: FireCardEffects now also processes Active abilities from AbilitiesJson
(after the existing EffectsJson path). Source-side ActivationConditions are
checked; target-side conditions (Subject=Target) are trusted from the client.

New Game.gd helper: send_play_card_with_targets sends play_card with a targets
array so the server can route unit selections to the active ability handler.

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>
2026-03-18 14:05:49 -04:00
66452313d5 Fix: conditional passive re-evaluation + INSUFFICIENT_TARGETS crash
Issue 1 — ActivationConditions on passives were never checked:
- ApplyPassivesForSource and ApplyPassivesToNewTarget now evaluate
  ActivationConditions against the source unit before executing each
  passive ability (e.g. IsOnTileWithAffinity: Lake only grants the buff
  when the unit is actually on a Lake tile).

Issue 1 — Passives not re-evaluated on movement / tile changes:
- Added ReEvaluateConditionalPassives(state): for every unit with at
  least one conditional passive, revoke all WhileSourceOnBattlefield
  effects then reapply with conditions re-checked. Units without
  conditional passives are skipped with zero overhead.
- Called after MoveUnit (unit changes tile affinity),
  ActivateAbility (ability may change board state),
  and ChannelCard Terramorpha path (tile affinities change).

Issue 2 — INSUFFICIENT_TARGETS thrown from ApplyPassivesToNewTarget:
- ResolveTargets: when restrictTargets is set (passive-to-new-target
  mode only) and filtering produces zero candidates, return [] silently
  instead of throwing. An ExactSelf source-buff simply has no valid
  target among the new unit — that is expected, not an error.

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>
2026-03-18 11:04:03 -04:00
4f0f0e9c0f Feature: ability-level Duration override + WhileSourceOnBattlefield in duration list
AbilityDefinition gains an optional Duration property. When set it is used
as forceDuration for every ExecuteActions call that resolves that ability,
overriding whatever per-action Duration individual effects specify.

- Active abilities: def.Duration is threaded through as forceDuration
- Triggered abilities: same
- Passive abilities: def.Duration ?? WhileSourceOnBattlefield (both
  ApplyPassivesForSource and ApplyPassivesToNewTarget paths)

AbilityBuilder admin panel:
- Duration row added after type-specific fields (dropdown + N input for ForNTurns)
- "WhileSourceOnBattlefield" added to the DurationTypeValues list
- Parse and compile paths updated for the new Duration field

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>
2026-03-17 23:15:05 -04:00
0f416127b1 Fix: Genus not propagated to CardInstance/FieldCard — breaks passive conditions
DefinitionToInstance and ToFieldCard both omitted copying Genus, so
HasGenusCondition and GenusContainsFilter always evaluated against null
(returning false). All three data-flow gaps are now fixed:
- DefinitionToInstance: def.Genus?.ToList() → CardInstance.Genus
- ToFieldCard:          source.Genus?.ToList() → FieldCard.Genus
- FilterMatches:        GenusContainsFilter now handled (was falling to _ => true)

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>
2026-03-17 17:29:42 -04:00
f60457b716 Fix: implement Passive ability execution with per-target conditions
Passive abilities (e.g. 'All Merfolk +1 attack') were never executed
because AbilityType.Passive had no runtime processing.

Three root causes fixed:

1. Passive abilities are now applied when units enter the battlefield
   and reversed when they leave (new DurationType.WhileSourceOnBattlefield).
   - ApplyPassivesForSource: runs a unit's passives against all current targets
   - ApplyPassivesToNewTarget: applies existing passives to a newly-entered unit
   - RevokePassivesForSource: reverses all passive effects on source death/leave
   - Hooked into GameEngine.Channel, Transition and AbilitySystem
     ReturnToBattlefield, SummonToken, KillUnit, SendToDiscard

2. Action conditions with Subject="Target" now filter per-target instead of
   aborting the entire action (which evaluated against ctx.Source).
   Source-level conditions still gate the whole action; target-level ones
   are evaluated individually and skip non-matching targets.

3. ExecuteActions/ResolveTargets gain a restrictTargets parameter used by
   ApplyPassivesToNewTarget to avoid double-applying existing passive buffs
   to units that already received them when the passive source entered.

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>
2026-03-17 15:54:00 -04:00
dingo 92f61dcd76 Ability Range fix 2026-03-13 17:36:57 -04:00
dingo 60268fd310 Ability changes 2026-03-13 09:47:06 -04:00