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>
Server:
- Add AbilityPlaceholderVisualPush DTO (sourceInstanceId, abilityName,
sourceAffinity, targets, targetMode: Self|Unit|Tile|PlayerZone|None)
- Promote ComputeVisualTargets to GameHandlerBase (protected static)
- Add ComputeAbilityVisualTargets — extends Repentance logic with
Self/ExactSelf + All-count detection, falls back to enemy ArchSpirit
- Add ComputeAbilityTargetMode — derives mode from visual targets +
sourceInstanceId (PlayerZone when target is a player account ID)
- Add FindSourceUnit helper — searches Field + ArchSpirit across all players
- GameActivateAbilityHandler captures source unit + ability def before
ActivateAbility, skips push when Animation.AssetUrl is set
Client:
- Add ability_placeholder_visual signal and push router case in Game.gd
- New AbilityPlaceholderFx component: Self/None → radial glow burst + two
expanding rings on source; Unit/Tile/PlayerZone → orb projectile from
source unit body to resolved target, impact ring + burst motes on arrival
- Wire component in game_screen.gd (_ready, _exit_tree, 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>
High: server now computes visual targets after resolution — prefers
client-provided unit InstanceId or tile Coord, falls back to the first
live opponent ArchSpirit so targetless/server-resolved effects always
have a destination.
Medium: source ArchSpirit fallback now looks up the actor's player
in game state rather than get_my_player(), fixing opponent and
spectator views.
Medium: player color now uses teamIndex from the player DTO instead
of deriving it from seatOrder, fixing team and multiplayer modes.
Low: hasCustomAnimation check now scans all Active ability definitions
for a non-empty AssetUrl, not just abilities[0].
Low: server no longer sends the push (or the HasCustomAnimation field)
when a custom animation exists; client-side guard removed accordingly.
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>
Server:
- Add RepentancePlaceholderVisualPush DTO to GameMessages.cs
- Add BroadcastToAllViewersAsync helper on GameHandlerBase
- GamePlayCardHandler emits game.visual.repentance_placeholder to all
players and spectators after a Repentance card resolves; sets
hasCustomAnimation based on ability Animation.AssetUrl presence
Client:
- Add repentance_placeholder_visual signal and push-router case in Game.gd
- New RepentancePlaceholderFx component: resolves source/target world
positions, picks affinity + player team colors, tweens a glowing orb
projectile to target and plays a torus ring + burst-mote impact
- Wire component in game_screen.gd (_ready, _exit_tree, signal 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>
Fix 3 killed all shader tweens at the top of every rebuild_units() call.
This interrupted materialize/ascend-arrival tweens mid-animation for units
that were staying on the board. Because tween.kill() skips the completion
callback, the mi.material_override was never restored, leaving every model
permanently frozen in the reveal=0..1 shader state with no actual mesh
visible.
Tweens run to completion naturally. The WeakRef + is_instance_valid guards
inside each tween callback already handle pooled/freed nodes safely, so
there is no leak when a unit is removed while its tween is still running.
_exit_tree() still kills all tweens on scene teardown.
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 spirit is returned to hand and re-channeled, the old in-flight
ModelCache.load_model() callback could fire after the unit was pooled and
re-created, clobbering the new placeholder and causing the 3D model to
not appear. The browser logged "!is_inside_tree()" hundreds of times/sec
as a result.
Fix: add a per-unit load-generation counter (_unit_load_gen). Each call
to add_unit_mesh() increments the counter and captures it in the closure.
The callback checks on entry whether the generation still matches; if not,
it treats itself as stale, frees the downloaded model_node, and returns
without touching any scene 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>
Adds _pool_unit() / _acquire_from_pool() keyed by card_type.
_ready() creates an off-tree _pool_root node to hold retired bodies.
_pool_unit() frees MeshInstance3D children immediately then reparents
the StaticBody3D shell to _pool_root; overflows beyond _MAX_POOL_PER_TYPE
are freed() synchronously to cap memory. _acquire_from_pool() fully
resets transform, collision layers, groups and stale metadata before
reparenting back to units_root. rebuild_units() now calls _pool_unit()
instead of queue_free() for normal unit removal. add_unit_mesh() tries
the pool first; fresh allocs still get a new CollisionShape3D added once.
_exit_tree() frees _pool_root (and all pooled children) on scene teardown.
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>
Adds _active_tweens list to UnitMeshBuilder. Both materialize and
dissolve shader tweens are appended on creation and auto-erased via
CONNECT_ONE_SHOT on finish. rebuild_units() kills all tracked tweens
before diffing so ShaderMaterial refs are released immediately instead
of up to 1.35s later. _exit_tree() kills remaining tweens on scene
teardown to prevent refs surviving a mid-animation forfeit or disconnect.
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>
Adds evict_all() to ModelCache which sets _shutting_down before flushing
_pending with null callbacks, then clears _mem and _job_queue. This
prevents in-flight HTTP completions from firing into a freed game scene
and ensures each new game starts with a clean WASM heap. Called from
game_screen._exit_tree() after all signal disconnections.
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>
Caps simultaneous GLB parses and HTTP downloads at _MAX_JOBS=4 via a
shared job budget. Disk-cache hits when slots are full queue as
parse_from_disk:true and drain correctly without re-downloading. Replaces
the no-op get_signal_connection_list().clear() with CONNECT_ONE_SHOT.
Adds _shutting_down flag so evict_all() can null-out pending callbacks.
Adds debug-gated logging on all hot paths.
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>
Adds collection.get_owned endpoint that returns { definitionId → count }
for the player's entire collection in a single DB round-trip. The client
caches this map and filters/sorts entirely client-side using definitions
already in ContentCache, eliminating all pagination and "load more" UI.
- Search, type, and affinity filters now work across the full collection
instantly with no network round-trips
- deck_editor_panel: arch spirit picker also uses the owned map —
removes a separate collection.get_cards request
- cards_view: same pattern, grid rebuilds client-side on filter change
- CollectionCache: persists owned map to disk (owned.json per 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>
SceneTreeTimer callbacks captured _sync_timeout by reference rather
than by identity, so a replaced timer's closure still passed the
null-check and called _on_sync_failed even though progress was
actively arriving. Fix by capturing the timer instance in the closure
and bailing out if _sync_timeout no longer points to it.
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>
Server:
- GameMessages.cs: add push DTOs for CostGroupPick, ActionGroupPick,
BranchPick, TargetPick, TilePick, PlayerPick, RevealChoicePick
- GameHandlerBase.PushStateToPlayersAsync: push all 8 pending types
(including existing CostPick which was missing its push) to the
chooser player after every state update and on reconnect
Client:
- Game.gd: add 8 signals, 8 send functions, 8 push routes matching
game.ability.{cost,cost_group,action_group,branch,target,tile,player,
reveal_choice}_pick_request
- game_screen.gd: add handlers for all 8 types:
- cost_pick: hand-card selection panel with confirm
- cost_group_pick / action_group_pick: option-button panels
- branch_pick: same UI as local ChooseOne but sends game.branch_pick
- target_pick: reuses ABILITY_TARGET mode, flag routes to game.target_pick
- tile_pick: highlights valid tiles, click sends game.tile_pick
- player_pick: player-button panel from server-supplied validPlayerIds
- reveal_choice_pick: click-to-order card list, sends game.reveal_choice_pick
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 6-B — Preflight check in _channel_ruin():
Iterate board tiles before sending play_card; skip any tile that already
has a ruinId (non-null, non-empty) or that doesn't match the card's
affinity. If zero valid tiles exist, show an AcceptDialog
"No valid tile available for this Ruin." and abort the send.
Phase 6-A — Confirmation dialog in _confirm_channel_ruin():
After passing preflight, show ConfirmationDialog "Channel Ruin /
Ruin placement is random. Continue?" with Channel / Cancel buttons.
Only calls Game.send_play_card on explicit confirm.
Replaces the previous immediate Game.send_play_card(iid, 0, 0) on click.
Follows the existing _confirm_ascend / _confirm_transition dialog 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>
- Throttle hand scroll to one step per 150 ms so each wheel tick advances exactly one card
- Deselect selected card when clicking outside the hand area (deferred flag pattern so board clicks still play the card)
- Extend spin and click-outside deselect to cover TERRAMORPHA_SELECT and card-triggered ABILITY_TARGET (Repentance/Instinct), not just CARD_FROM_HAND
- Show Repentance/Instinct cards as visually selected in hand when in ABILITY_TARGET mode
- Drop stale spectator state_update pushes from wrong sessions
- Auto-create missing audio buses on Settings._ready to avoid bus-not-found errors
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>
- Game.state_updated (and other game signals) now connected before any UI
setup that could error. Previously they were at line ~340, after hand spin
button setup — if anything between _configure_hand_spin_buttons and those
connects threw, spectators would never receive live state pushes (no player
actions to trigger ACK-based updates as fallback)
- _rebuild_hand now uses str(raw) if raw != null else "" for IID extraction;
card.get("instanceId", "") returns null (not the default) when the key
exists with a null value, which would error on append to Array[String]
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>
- Removed the outer _is_spectating guard on _rebuild_hand; blocking it
entirely left _cached_hand_iids stale and skipped other bookkeeping
- Spectator early-exit now inside _rebuild_hand after updating the cache,
clearing the display hand cleanly
- Replaced Array[Dictionary].filter() (returns untyped Array, silent type
mismatch on reassignment) with explicit loops into typed Array[Dictionary]
- Same fix for the display_hand build: explicit typed loop instead of
hand.filter() with Variant cast
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 Settings.draw_card_popup bool (default true, persisted)
- Toggle in InGameSettings under Gameplay: "Show drawn card popup"
- _rebuild_hand detects brand-new cards and queues them in
_pending_popup_cards instead of adding to hand immediately
- _show_next_card_popup builds a CanvasLayer overlay (layer 20) with a
dimmed background + full-size card widget; click card or background to
dismiss
- _dismiss_card_popup pops the queue, adds the card to hand via
_apply_display_hand in server order, then shows the next queued popup
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>
- _rebuild_hand now diffs existing widgets against new hand: only removes
cards that left, only creates widgets for cards that arrived; everything
else stays in place with no rebuild flash
- New card widgets snap to their fan position on first layout instead of
tweening from (0,0), eliminating the slide-from-corner jitter on draw
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 widget rebuild when hand IIDs are unchanged; only refresh selection
- Store _fan_slot metadata so _restack_hand_cards can reorder children by
z-index (for correct GUI input routing) without corrupting fan positions
- Double spin arrow hit targets from 22x22 to 44x44
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>
move_child was changing child indices which _layout_hand_cards uses to
compute fan positions, causing the whole hand to shuffle on every spin
or selection. z_index alone handles draw order correctly.
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>