- 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>
2-finger pinch/pan, 3-finger pan, MagnifyGesture, and PanGesture are
now gated behind gesture mode. In buttons mode only single-finger drag
(controlled by the active toggle button) affects the camera.
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>
Cumulative drag distance (_touch_drag_total) is the wrong metric for tap
detection: natural finger jitter (A→B→A) can exceed 36 px even on a clean
tap, silently suppressing board clicks (unit moves, card plays, etc.).
Switch the board-click gate to start-to-end distance (< 50 px = tap).
_touch_drag_active now only means "camera mode fired during this touch" and
is set by the gesture timer or when an active camera mode consumes a drag.
This means taps always reach _handle_board_click regardless of finger wobble.
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>
_touch_drag_active was set unconditionally on 36px drag, silently eating
board taps even when no camera action occurred. Now only set when a camera
mode (orbit/pan/zoom) is actually active. Gesture timer also immediately
marks drag-active on activation so the 3s hold doesn't fire a board click.
Buttons enlarged to 44px minimum height for touch usability.
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>
- Settings: new touch_camera_mode ("gesture"|"buttons"), persisted to camera section
- GameScreen: CamGestureTimer (3 s), CamCtrlPanel with Orbit/Pan/Zoom toggle buttons
- game_screen: gesture timer fires orbit/pan/zoom after 3-second stationary hold;
button mode shows on-screen toggles; single-finger drag now gated behind active mode
- InGameSettings: Camera Controls section with Touch Camera OptionButton
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>
Left-click drag was orbiting the camera on desktop, so any mouse movement
>2px during a click would suppress _handle_board_click. Moved camera orbit
to right-mouse drag (_orbit_active flag) leaving left-click exclusively for
board actions regardless of mouse movement. Touch single-finger orbit is
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>
4px per-event threshold was too sensitive — normal finger tremor during
a tap could exceed it, causing _touch_drag_active to suppress the click.
Now accumulates total drag distance since touch-down; requires 12px total
movement before classifying the touch as a camera orbit.
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>
Added _touch_drag_active flag set only when finger moves > 4px threshold.
Camera orbit now requires meaningful drag; taps no longer jiggle camera
or get swallowed — board clicks fire correctly for gameplay actions.
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 _was_multi_touch flag: set when second finger lands, cleared only
when all fingers lift — prevents single-finger orbit logic from running
during a pinch even if ScreenDrag(finger-0) arrives before ScreenTouch(finger-1)
- Handle InputEventMagnifyGesture (trackpad/browser pinch-to-zoom) and
InputEventPanGesture (two-finger pan) which browsers emit instead of
raw dual ScreenDrag events
- Initialize _last_mouse from touch pair midpoint when second finger lands
so two-finger pan has a correct delta baseline
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>
- Right-side slide-in drawer shows tile coords, affinity, base1/base2, ruin,
and occupant name when any tile is clicked in NONE mode; auto-closes on mode change
- New 'Focus camera when clicking a tile' setting (Settings.click_to_focus_camera),
toggled in in-game settings panel, tweens camera to clicked tile
- Clicking a tile occupied by a unit now redirects to that unit in both NONE
and UNIT_SELECTED modes, so you no longer need to hit the unit mesh exactly
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>