Commit Graph
287 Commits
Author SHA1 Message Date
7a917cf93b fix(ability-prompts): fix 3 client wiring gaps
1. JSON case normalization
   Parse CostGroupJson, ActionGroupJson, BranchesJson, RevealedCardsJson
   through _normalize_keys in game_screen.gd — server serialises these
   inner payloads with _jsonOpts (no naming policy = PascalCase), but the
   client was reading lowercase keys, producing empty option lists.

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

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

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-21 17:13:04 -04:00
c45db289ad feat(ability-prompts): wire all 8 pending pick types end-to-end
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>
2026-04-21 17:02:12 -04:00
2d9e9e7347 feat(phase6-AB): Ruin client preflight check and channel confirmation dialog
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>
2026-04-20 14:13:05 -04:00
8f3911e881 feat(ability): implement AbilityBuilderR3 + engine additions
Engine:
- AbilityDefinition: add SourceZoneGate (zone-restricted triggers) and TriggerLimitPerGame
- Effects: add StatModOperator (Add/Subtract/Multiply/Divide/Percent) on all stat mod effects; reversal stored as delta
- Action/CostEntry: add CostPickMode enum (Random/SelfPick/EnemySeePick/EnemyRandomPick/EnemyPick)
- PendingCostPick: new model for interactive cost pause/resume (mirrors PendingTriggeredTarget)
- GameState: PendingCostPick field
- GameMessages: CostPickRequestPush, GameCostPickRequest, GameCostPickResponse records
- AbilitySystem: FireTrigger scans Hand/Discard/Deck when SourceZoneGate set; per-game trigger limit tracking; ApplyStatOperator helper; PayCosts/ResumeCostPick for interactive cost flow
- GameCostPickHandler + ServiceRegistration wiring

Admin:
- AbilityBuilderR3.razor: full ability builder at /cards/ability-builder-r3 (39 triggers, 69 effects, 32 conditions, form/canvas/mermaid modes, compiles to engine-native $type JSON)
- AbilityBuilderR2-Draft.razor: fix switch expression no-best-type error

Docs:
- BuilderR3.md: master plan document

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-18 20:15:13 -04:00
dingo f966643e31 Spectator fix 2026-04-15 13:35:15 -04:00
dingo abf2c1d96c AI Match fix 2026-04-15 12:51:14 -04:00
afa9e73489 fix(hand): scroll throttle, deselect on spin/click-outside for all card modes
- 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>
2026-04-15 09:31:30 -04:00
573d8cf727 fix(spectate): move Game signal connections to top of _ready, null-safe IIDs
- 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>
2026-04-14 23:42:28 -04:00
8649384997 fix(spectate): restore _rebuild_hand for spectators, fix typed Array filter
- 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>
2026-04-14 23:30:37 -04:00
286ccf26c7 fix(spectate): skip hand rebuild and clear draw popups when spectating
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-14 23:24:28 -04:00
cbf1ff2ad5 fix(ui): move InGameSettings to CanvasLayer 15 so it renders above all HUD
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-14 23:13:17 -04:00
611f4bbb66 fix(hand): use add_theme_*_override instead of dictionary accessors for dynamic nodes
theme_override_* dict syntax requires the node to already be in the tree.
Use add_theme_constant_override / add_theme_font_size_override instead.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-14 23:08:18 -04:00
7023004046 feat(hand): draw card popup — show drawn card centre-screen, click to add
- 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>
2026-04-14 23:05:51 -04:00
01ca65e121 fix(hand): incremental add/remove cards, no jitter on draw or play
- _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>
2026-04-14 22:58:51 -04:00
8f37dd7e9b feat(hand): cache hand by IID, fix click precision, double arrow button size
- 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>
2026-04-14 22:54:01 -04:00
5290847651 fix(hand): remove _restack_hand_cards to stop fan position shuffling
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>
2026-04-14 22:42:53 -04:00
aef635d495 fix(hand): remove hover effect that was shifting card positions on mouse move
Hover lift/scale/z_index boosts and mouse_entered/exited callbacks were
causing cards to jump around whenever the cursor passed over them.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-14 22:18:08 -04:00
750a0e5934 fix(hand): set mouse_filter=IGNORE on Panel/Panel2 in HandArea
These full-size Panel nodes were overlapping HandCards and swallowing
all click events before cards could receive them.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-14 22:13:29 -04:00
9c75c86b95 feat(hand): fan layout with bring-to-front selection, no focus shift on click
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>
2026-04-14 22:10:39 -04:00
dingo ad031a8e30 UI improvements ++ 2026-04-14 16:02:24 -04:00
f76814a03b feat: collapsible scrollable active effects sub-section in tile drawer
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>
2026-04-14 12:22:31 -04:00
b4062d8179 feat: add active effects inspector to tile drawer
- Track active effects with human-readable labels in AbilitySystem
  (LabelFromReversal/LabelFromTick for stat mods, status flags, DOT/HOT)
- Add ActiveEffectDto to GameStateDto and GameStateDelta; delta now
  always includes the full effects list so clients are never stale
- Add ResolveLabelFromEffectJson fallback for effects stored before the
  Label field was introduced (old game sessions show correct labels)
- Client _append_active_effect_lines helper filters activeEffects by
  targetRef and appends formatted lines to the tile drawer for spirits,
  archspirits, spirit tokens, and ruins

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-14 11:52:37 -04:00
dingo 144ad84cac minor bug fixes 2026-04-14 11:07:56 -04:00
dingo ad6ae689ed Add collapsible tile detail drawer UI 2026-04-14 11:06:58 -04:00
dingo a219b2fb31 Fix tile highlights for channeling spirit 2026-04-14 10:14:43 -04:00
dingo d1a78e672a update 2026-04-14 09:41:52 -04:00
dingo 5136a16fc0 Decrease logging 2026-04-14 09:18:15 -04:00
e204cdf74e fix: correct default modelFacingDirection to south for Blender GLB units
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>
2026-04-14 09:17:52 -04:00
23dc7925e2 fix: arch spirit placement field name, rules lock, and AI indicator
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>
2026-04-13 08:29:41 -04:00
540fa7d601 Client: Add AI opponent support to custom lobby
- 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>
2026-04-12 21:57:46 -04:00
dingo c3a39fd7a1 hmmm 2026-04-12 14:44:37 -04:00
dingo 4302a0f048 UI improvement start 2026-04-10 11:14:10 -04:00
232e06de6d Allow terramorpha to re-select first tile as third pick
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>
2026-04-07 14:49:16 -04:00
aa8fa34a05 Fix hex grid support for movement, channeling range, and terramorpha
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>
2026-04-07 14:36:08 -04:00
4ac92d0139 Add hex stalagmite support for tile bottom models
- 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>
2026-04-07 11:34:46 -04:00
cfb10ae4d0 Fix Keycloak auth failures: audience validation + packet drain race
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>
2026-04-02 19:36:09 -04:00
79fa08e192 Fix Keycloak: scene reload on error, web signal missed, redirect URI
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>
2026-04-02 19:20:04 -04:00
1c6064e157 Fix Keycloak auth: DISCONNECTED retry + web export support
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>
2026-04-02 16:39:13 -04:00
60d6098c11 Fix Keycloak login: force fresh WebSocket before auth.keycloak
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>
2026-04-02 16:20:45 -04:00
39253716ad Replace login/register forms with Keycloak sign-in flow
- LoginScreen: single "Sign in with Aeternalis" button replaces two-tab
  email/password/register layout; all credential encryption removed
- login_screen.gd: wires Keycloak.token_received → Auth.login_with_keycloak,
  handles auth_error and auth_failed signals
- Auth.gd: rewritten to use Keycloak session tokens; stores Keycloak refresh
  token for silent re-auth; calls Keycloak.revoke on logout
- Keycloak.gd: new autoload implementing Authorization Code + PKCE with
  loopback redirect, silent refresh, and fire-and-forget revocation
- project.godot: register Keycloak as autoload singleton

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-02 15:04:43 -04:00
78f55930a0 Fix team play: correct team indices, team-aware unit colors and ownership
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>
2026-04-02 08:40:43 -04:00
0572aea4d2 Extend board template builder with hex SVG canvas + filter client by grid type
- 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>
2026-04-01 21:22:07 -04:00
a4badc276b Unit models face nearest enemy rather than fixed north/south
_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>
2026-04-01 20:30:39 -04:00
f9832d1a1f Hex board: corner starting zones, half tile spacing
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>
2026-04-01 18:44:20 -04:00
97e7698000 Wire HexSides through custom lobby; fix boardTemplateIdOverride empty-string crash
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>
2026-04-01 18:28:08 -04:00
aa76ac9994 Add Grid Type toggle (Square/Hexagon) to lobby rules editor
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>
2026-04-01 18:18:21 -04:00
8a20e56cb3 Hex tiles: use affinity-coloured cylinder placeholder, no Square fallback
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>
2026-04-01 17:38:49 -04:00
1bd26f11be Add hex grid to lobby rules editor; fix hex model/texture CDN loading
- 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>
2026-04-01 17:16:22 -04:00
2cfa60c7dd Add hex grid support (sides 3–10) for boards, pathfinding, LOS, and client rendering
- New HexGrid.cs: axial coord helpers, BFS neighbors, cube-lerp LOS, jump-range
- Board: HexSides property, GetNeighbors() dispatches hex/square, IsInBounds() hex-aware
- BoardShapeGenerator: MakeHexagon() with edge-based starting zones (2–6 players);
  FromTemplate() now carries HexSides through to the Board
- Pathfinding: Walk/Flight BFS uses board.GetNeighbors() (hex+square unified)
- LineOfSight: delegates to HexGrid.HasLos when hexSides > 0
- GameRules/GameRuleSet/BoardTemplate/BoardTemplateSnapshot: GridType + HexSides fields
- GameMessages BoardDto: GridType + HexSides sent to client
- GameEngine: PlaceArchSpirit range uses HexGrid.Distance on hex boards;
  Teleport LOS passes board.HexSides; ToBoardDto emits GridType/HexSides
- EF migration 20260401000000_AddHexGridSupport: grid_type + hex_sides columns on
  game_rule_sets and board_templates; applied to pg-forge-01
- Client game_screen.gd: hex coord→world (pointy-top flat layout), CylinderMesh
  tiles (radial_segments=6), _board_distance cube metric, _bfs_reachable 6-dir,
  _client_has_los cube-lerp, highlight mesh for hex tiles; reads gridType/hexSides
  from BoardDto

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-01 16:44:17 -04:00
c756b9cffa Fix highlight accuracy: BFS movement, LOS attack filtering
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>
2026-04-01 11:19:24 -04:00