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