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>
Clicking a card now selects it and brings it visually to the front (via
z_index + lift boost) without re-centering the fan. Scroll arrows deselect
the active card before spinning. Hover lift and tween-based fan layout added.
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>
Each entity type (Spirit, SpiritToken, ArchSpirit, Ruin) now gets its own
"Active Effects (N)" section immediately below its stats section. The section:
- starts collapsed to keep the drawer compact
- shows a count badge in the header ("Active Effects (3)")
- scrolls when the effect list is longer than the visible area (~90 px)
- hides entirely when the entity has no active effects
Effects are no longer appended inline to the stat labels list; they live in
dedicated scrollable sections built by _create_scrollable_section /
_set_effects_section helpers.
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>
Units were facing 180° away from the nearest enemy because
modelFacingDirection defaulted to "north" (base=0) when the asset
field was absent. Blender-exported GLBs natively face +Z (south,
base=π), so the rotation formula was inverted for all models without
an explicit facing override.
Also improves _idle_rotation diagnostics: push_warning on fallback
with body/ownership counts, and tightens the XZ direction guard to
check (x != 0 or z != 0) instead of 3D length_squared which could
pass spuriously when only the Y component was non-zero.
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>
AiPlayerSession.ExecutePlacementAsync — NullReferenceException:
Sent { Coord = ... } but GamePlaceArchSpiritRequest.Position is the
field name. Changed to { Position = ... }.
GameUpdateLobbyRulesHandler — rules locked after adding AI:
GuestReady=true is set when AI joins so the game auto-starts when
host readies, but that flag was also blocking rule edits via
CANNOT_CHANGE_RULES_WHILE_READY. Fix: inject IAiAccountRegistry
(optional) and only block when a HUMAN guest is ready.
CustomLobby.gd — AI indicator not showing / rules reset on refresh:
add_ai: populate ai_slots immediately from the game.ai.add ACK
response so _refresh_display sees the AI before the push arrives.
update_rules + lobby_updated push: keep lobby["rules"] in sync so
_refresh_display() doesn't clobber _current_rules with stale data.
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>
- CustomLobby.gd: add add_ai(difficulty, strategy) method sending
game.ai.add; add ai_slots: Array state; handle game.ai.slots_changed
push updating ai_slots and emitting ai_slots_changed signal; clear
ai_slots in clear_state()
- LobbyRoomScreen.tscn: add AddAiBtn (Button, hidden by default) between
guest ready indicator and additional players container
- lobby_room_screen.gd: wire AddAiBtn (host-only, visible when guest slot
is empty and host is not ready); _on_add_ai_pressed() opens a dialog
with OptionButton for difficulty (D1 Novice - D10 Mythic) and strategy
(Balanced/Aggressive/Control/Ramp/Swarm); guest slot display renders
AI name + difficulty when an AI occupies seat 1; _ai_slot_for_seat()
helper; connect/disconnect ai_slots_changed -> _refresh_display
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>
For tri-morpha, tile 1 is adjacent to tile 2, so it must be a valid
choice for tile 3. The previous duplicate guard blocked this.
The adjacency check (_board_distance != 1) already prevents picking the
same tile back-to-back (distance 0), so the dedup was redundant and
only hurt the re-pick case. Removed both the click-handler guard and
the matching skip in the next-pick highlight loop.
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>
Movement (_bfs_path): was using 4 square directions for pathfinding,
causing units on hex grids to take indirect multi-step routes when a
single diagonal step exists. Now uses 6 hex dirs when grid is Hexagon.
Channeling (_valid_play_tiles Spirit): was using Manhattan distance
instead of hex cube distance, producing a diamond-shaped channel range
on hex boards. Now delegates to _board_distance for both grid types.
Terramorpha (three fixes):
- Initial valid-play highlights now filter by _tile_bodies so only
real tiles are highlighted (not every grid position in the bbox)
- Adjacency validation for Di/Tri multi-pick now uses _board_distance
instead of abs(dx)+abs(dy), enabling all 6 hex neighbours
- Next-pick highlight loop now uses 6 hex dirs and guards with
_tile_bodies check, consistent with the reachability BFS
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>
- TileBottomModel gains a Shape column (Square/Hex, default Square)
so admins can manage separate stalagmite pools per tile grid type
- EF migration 20260407153312_AddTileBottomModelShape adds the column
with a default of 'Square' to preserve existing data
- Admin UI splits the Tile Bottom Models section into Square and Hex
cards, each with their own Add/toggle/delete controls
- content.tile_bottoms response now returns squareUrls and hexUrls
separately; handler queries each shape independently
- ContentCache splits into _tile_bottom_urls_square / _hex and
get_random_tile_bottom_url() now takes a shape parameter
- game_screen: hex tiles with no 3D model now receive a hex stalagmite
instead of silently skipping; 3D-model path passes shape_key through
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 — JWT audience validation failing:
Keycloak does not include the client ID in the `aud` claim by default
(uses "account"). ValidateAudience=true with ValidAudience="sor-game"
rejected every token. Disabled audience validation — issuer + signature
+ realm role check is sufficient for a single-realm deployment.
Bumped JWT validation failure log to Information so it appears in default logs.
Client — DISCONNECTED instead of AUTH_FAILED on rejected auth:
When the server sends an error packet immediately followed by a close frame,
the socket transitions to STATE_CLOSING before the next _process frame.
Network.gd returned early during STATE_CLOSING without draining packets,
leaving the pending request unresolved. _on_ws_closed then failed it as
DISCONNECTED. Now drains packets during STATE_CLOSING so the error packet
is resolved with the correct error code before the close is processed.
Also added "invalid_token", "role_required", "invalid_payload",
"auth_service_unavailable", "account_creation_failed" to the close reason
→ error code mapping so they surface as AUTH_FAILED / AUTH_SERVICE_UNAVAILABLE
rather than DISCONNECTED even in the fallback 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>
PC — scene reloading on auth error:
Auth.gd's keycloak error handler called change_scene_to_file(LoginScreen)
after emitting auth_failed, which reloaded the scene and wiped the error
message before the user could see it. Removed the scene change — the
login screen is already active and handles auth_failed itself.
Web — token_received signal never handled after page redirect:
login_screen._ready() returned early when Keycloak.auth_in_progress was
true, before connecting Keycloak.token_received. When the exchange
completed nobody was listening, so the game sat frozen. Signals are now
connected before the early-return check.
Web — fragile redirect URI and sessionStorage injection:
JavaScriptBridge.eval return value could stringify as "<null>". Now uses
separate origin + pathname evals with a null check. sessionStorage items
and the final navigation use uri_encode() + decodeURIComponent() instead
of manual quote-escaping, preventing injection from PKCE values.
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>
PC native — connection lost, retrying:
_send_keycloak_auth's DISCONNECTED handler was clearing _pending_keycloak_token
(taken at top of function) without restoring it, so the next _on_network_connected
had no token to retry with. Restore it: _pending_keycloak_token = token.
Web export — could not bind a local redirect port:
Godot's HTML5 export cannot create TCP server sockets. Add a separate web
code path in Keycloak.gd:
- start_auth_flow() detects OS.get_name() == "Web" and navigates the page
to Keycloak, persisting PKCE state (verifier, state, redirect_uri) in
sessionStorage before the page leaves.
- _check_web_callback() (called in _ready()) detects the ?code= params on
return, recovers state from sessionStorage, cleans the URL via
history.replaceState, then calls _exchange_code().
- auth_in_progress flag lets login_screen show "Completing sign-in..."
while the token exchange is in flight after page reload.
Requires the web game's origin to be registered as a valid redirect URI
in the Keycloak sor-game client.
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>
The server closes idle unauthenticated connections after AuthTimeoutMs
(10 s). A user authenticating in the browser takes longer than that, so
the socket the client held while the browser was open is already dead
when token_received fires. Sending auth.keycloak on that stale
connection produces no reply and the scene never changes.
Fix: login_with_keycloak() now calls Network.force_reconnect() instead
of sending immediately. _on_network_connected() then sends auth.keycloak
as the guaranteed-first message on the fresh connection.
Also: DISCONNECTED errors in the auth.keycloak error callback no longer
clear keycloak_refresh_token, preserving silent re-auth on transient drops.
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 TeamCount, PlayerOneTeamIndex, PlayerTwoTeamIndex to GameSession so
team assignments survive the lobby→game transition without recomputation
- GameLobbyReadyHandler.StartGameAsync: apply TeamAssignmentsJson (host custom
reassignments) for all seats; store P1/P2 team indices on the session
- GameReadyHandler N-player path: use session.PlayerOneTeamIndex /
PlayerTwoTeamIndex instead of hardcoded teamCount=1 (which put both P1 and
P2 on team 0 in every non-FFA game)
- EF migration: AddGameSessionTeamFields
Client (game_screen.gd):
- _rebuild_ownership: treat same-team allies as friendly instead of enemy
- Unit color loop: use state.teamColors palette per team instead of hardcoded
blue (self) / red (everyone else)
- _on_game_over: derive i_won from player_outcomes[me].outcome == "Winner" so
a teammate's final kill correctly shows "Victory!" for the whole team
Also: skip absent hex tiles in BoardTemplateBuilder SVG render
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>
- Admin builder: SVG hex canvas renders when GridType=Hexagon (pointy-top hexagons, correct axial layout); square CSS grid otherwise
- Admin builder: ApplyHexSides / OnGridTypeChanged handle dimension/tile pruning; canvas header shows N/diameter for hex
- BoardTemplateDto now includes GridType and HexSides so clients can filter
- rules_editor_dialog: Board Width/Height/Shape hidden when hex selected; Hex Sides hidden when square; template picker filtered to matching grid type with live toggle
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>
_idle_rotation now:
- Finds the nearest enemy body in _unit_bodies by XZ distance
- Returns atan2 toward that position minus the model's base angle
- Falls back to the original north/south heuristic when no enemy exists yet
Also refreshes idle rotation for all units on every state rebuild (step 4 in
_rebuild_units), skipping any unit currently in a move tween, so rotations
stay correct as units reposition across 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>
Server - MakeHexagon starting zones:
- Zones are now corner-based instead of full-edge: each zone is the corner
tile plus (N-1)/2 tiles along each of the two edges meeting at that corner
- 2 players → opposite corners (0, 3 = right/left); 3 → every-other corner
(0,2,4); 4 → (0,1,3,4); 5 → (0-4); 6 → all 6 corners
Client - game_screen.gd:
- Add HEX_TILE_SPACING = TILE_SPACING * 0.5 constant
- _coord_to_world: use HEX_TILE_SPACING for hex world positions
- _add_tile: tile cylinder radius scaled by HEX_TILE_SPACING
- _add_highlight: highlight cylinder radius scaled by HEX_TILE_SPACING
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:
- CustomRulesOverride: add HexSides (int?) field
- CustomLobby entity: add HexSidesOverride (int?) column
- GameUpdateLobbyRulesHandler: save HexSidesOverride, include HexSides in
effective rules preview
- GameLobbyReadyHandler: set rules.HexSides from lobby.HexSidesOverride on
game start
- GameSavePresetHandler: capture BoardShape + HexSides in saved presets
- Migration 20260401222603_AddCustomLobbyHexSides: adds HexSidesOverride to
custom_lobbies; applied to pg-forge-01 via dotnet ef database update
Client:
- rules_editor_dialog: send null (not "") for boardTemplateIdOverride when no
template selected — empty string crashed Guid? deserialisation on the server
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>
Replaces burying "Hexagon" in the Board Shape list with a dedicated
Grid Type dropdown at the top of the BOARD section. When "Hexagon" is
selected, boardShape is forced to "Hexagon" on confirm; square boards
use the Board Shape field as before. Hex Sides remains visible for
the sides setting.
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 no Hex CDN model exists for an affinity, hex tiles now keep their
coloured CylinderMesh (radial_segments=6) placeholder rather than loading
a Square model or texture. Square boards are unchanged.
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>
- rules_editor_dialog: add "Hexagon" to Board Shape picker and a Hex Sides
spinner (3–10, default 5) so custom lobbies can configure hex boards
- game_screen _add_tile: has_model check now looks for Hex-shape CDN models
(falls back to Square), so hex tiles get height variance when a Hex model is
registered on the CDN instead of always using the flat placeholder height
- game_screen _try_load_tile_model: texture fallback now checks shape_key
("Hex") first, then falls back to "Square" — consistent with model loading
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>
Movement tiles (_valid_move_tiles):
- Walk: BFS blocked by all occupied tiles (can't walk through units)
- Flight: BFS blocked only by other Flight units (flies over Walk units)
- Jump: Manhattan range, unoccupied only (was already correct)
- Teleport: Manhattan range + LOS to destination
Attack highlights (_attack_range_tiles, _valid_attack_target_coords,
_valid_attack_target_ids):
- Added AttackRequiresLos field to CardInstanceDto / ToCardInstanceDto
- Client now checks _client_has_los() for LOS-required attackers
- Tiles/units blocked by occupants are no longer highlighted as targets
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, clicking an ArchSpirit showed the abilities panel AND a
separate OS-level PopupMenu for arch-spirit actions. Now everything
lives in one floating panel:
[Abilities] ← shown only if unit has active abilities
──────────
<ability buttons>
[ArchSpirit] ← shown only for friendly ArchSpirit
──────────
Sacrifice a Spirit (only when valid candidates adjacent)
Ascend (only when tier+1 card in hand)
Transition (only when tier-1 card in hand)
Removed the _show_arch_spirit_menu() PopupMenu call from _select_unit().
_show_ability_panel() now builds both sections and returns early only
when both would be empty.
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>
If sync_complete or sync_failed never fires (e.g. background refresh
_is_syncing guard eats the start_sync call and signals were already
emitted before init_screen connected them, or a server request is
in-flight with no reply), the player was silently stranded with no
retry path and had to relaunch.
Adds a SYNC_TIMEOUT_SEC = 20 watchdog timer started in _do_sync() and
reset on each sync_progress page. If it fires, surfaces the retry
button with a "Timed out" message.
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>