Commit Graph
192 Commits
Author SHA1 Message Date
7b1e7e346a Show display names everywhere accountId was shown in GameScreen
Server:
- PlayerState: add DisplayName property (populated from identity DB)
- PlayerStateDto: add DisplayName field (falls back to truncated ID)
- GameEngine.ToDto: include DisplayName in player DTO
- GameReadyHandler: resolve display names from identity DB after state
  initialization so every subsequent state push carries them

Client:
- Game.gd: add get_display_name(account_id) helper — reads displayName
  from player state, falls back to substr(0,8)
- game_screen.gd: replace all 5 pid/eid/elim_id.substr(0,8) UI sites
  with Game.get_display_name() — HUD opp name, turn order strip,
  game-over outcome list, discard scope selector, elimination dialog
- Turn order strip chips: use resolved display name; add mouse_filter
  STOP + tooltip_text showing SP/ST/Hand/Deck for opponent chips on hover

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-03-26 10:52:08 -04:00
dingo a50b60ad82 Merge branch 'main' of https://git.aeternalisgames.com/dingo/SOR
multiple workers.
2026-03-26 10:33:07 -04:00
Shard 84284be4d0 Fix active ability target gating for server-resolved ownership scopes 2026-03-26 14:32:31 +00:00
6465607eb0 Fix FFA last-man-standing and nil attack-target crash
- GameEngine.Concede: use EliminatePlayer instead of unconditionally
  setting GamePhase.GameOver — FFA game continues until one team remains.
  Return value changed to (GameState, bool gameOver) tuple.
- GameConcedeHandler / GameForceConcedeHandler: check gameOver flag;
  when game continues push BroadcastPlayerEliminatedAsync + state update
  instead of calling FinalizeMultiPlayerGameAsync prematurely.
- game_screen.gd _valid_attack_target_coords: use `not (_tpos is Dictionary)`
  guard instead of typed assignment — prevents nil crash when eliminated
  players' units still appear in get_all_enemy_units() with position:null.

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-03-26 10:27:12 -04:00
cabadfc647 Fix N-player game.ready: per-player ready tracking and deck deserialization
- GameReadyHandler: change `else` → `else if (P2)` so Player 3+ no
  longer incorrectly marks PlayerTwoReady; additional players now track
  their own IsReady flag inside AdditionalPlayersJson on the session.
  All-ready check now waits for P1 + P2 + all additional players.
- GameLobbyReadyHandler.StartGameAsync: add PropertyNameCaseInsensitive
  when deserializing AdditionalPlayersJson → prevents Guid.Empty deck IDs
  caused by camelCase/PascalCase mismatch between join and ready handlers.
- SessionAdditionalPlayer: add IsReady property to support per-player
  ready tracking in the N-player game.ready flow.

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-03-26 10:08:19 -04:00
7fd5beb172 Fix 2-player placement zone and game.over null crash
BoardShapeGenerator: 2-player rectangle now assigns one row per seat
(row 0 for seat 0, top row for seat 1), restoring the original 1v1
behaviour.  3-4 player lobbies keep the two-row zones for extra
placement room.

Game.gd game.over: server sends playerOutcomes:null for 2-player games.
d.get(key, default) returns null when the key exists with value null,
so 'null as Array' crashed.  Use 'is Array' guard to safely fall back
to an empty array when the field is absent or null.

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-03-26 09:22:14 -04:00
497e1c3172 Fix N-player lobby: premature start, unready for seat 3+, stale reconnect
GameLobbyReadyHandler: change else→else if (isGuest) so additional
players (seat 3+) no longer incorrectly set GuestReady=true.  When
Player 3 called ready the else-branch marked GuestReady, making the
all-ready check fire as soon as the host was also ready — starting
the game without Player 2 ever clicking ready, leaving 2/3 clients
in a starting state and 1 stuck in the lobby.
Also: update DeckId for additional players in AdditionalPlayersJson;
push ready_status to additional player connections.

GameUnreadyHandler: handle additional players (seat 3+) by updating
isReady in AdditionalPlayersJson via JsonNode; push unready status to
all participants including additional players.  Previously threw
NOT_IN_LOBBY for anyone beyond the primary guest.

Game.gd: guard _on_auth_reconnect with 'state is non-empty' so stale
session_id values from ended games don't trigger spurious game.ready
calls.  Also clear session_id in the game.over handler so it never
lingers past the end of a session.

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-03-26 09:18:45 -04:00
9c7dc098aa Fix 3 multiplayer bugs: type error, reconnect, lobby count
- game_screen.gd: fix Parser Error on line 270 — use 'as Environment'
  cast instead of ': Variant' annotation for WorldEnvironment.environment
- Game.gd: auto-resend game.ready on auth_success reconnect so the
  game session is restored when the WebSocket reconnects mid-game
- lobby_browser_row.gd: show real N/Max player count instead of
  hardcoded "1/2" / "2/2"
- CustomLobbyDto: add MaxPlayers, CurrentPlayerCount, GameMode, TeamCount
- GameListCustomLobbiesHandler: compute currentPlayerCount from
  GuestAccountId + AdditionalPlayersJson; pass new fields to DTO

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-03-26 09:05:40 -04:00
9d4302cc6c Client multiplayer: N-player targeting, placement zones, lobby creation, outcomes
Server:
- BoardDto: add StartingZones (seat → coord list) so client knows valid placement tiles
- GameEngine.ToBoardDto: serialize StartingZones into the DTO

Client – Game.gd:
- get_enemy_players(): returns all players not on the local player's team
- get_all_enemy_units(): flat list of field + archSpirit from all enemies
- game_over signal: adds player_outcomes: Array parameter
- game.over push: extracts playerOutcomes array and passes to signal

Client – game_screen.gd:
- _valid_placement_tiles(): uses board.startingZones[seatIndex] when available; falls back to legacy row logic
- _valid_attack_target_coords/ids: use Game.get_all_enemy_units() instead of single opponent
- ability target picker: uses get_all_enemy_units() for enemy units
- player-panel builder (zone abilities): iterates get_enemy_players() for N-player
- _on_game_over: shows per-player rank deltas from playerOutcomes when present

Client – CustomLobby.gd:
- State: max_players, game_mode, team_count fields (cleared on clear_state)
- create(): accepts p_max_players, p_game_mode, p_team_count params; sends to server
- join(): stores max_players/game_mode/team_count from server response
- game.custom.started: calls clear_state() before emitting game_starting

Client – FreePlayScreen:
- Create dialog: MaxPlayersSpinner (2-10), GameModeOption (FFA/Teams/MultiTeam), TeamCountRow (hidden for FFA)
- GameModeOption.item_selected toggles team_count_row visibility
- _on_create_confirmed: passes max_players, game_mode, team_count to CustomLobby.create()

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-03-26 06:12:14 -04:00
74af9aa4bd Phase 5: N-player ELO, spectator-for-eliminated, turn-limit/concede N-player paths
- GameEngine: GetNPlayerTurnLimitWinners() ranks surviving players by ArchSpirit HP; highest-HP player(s) win, rest lose
- GameConcedeHandler: N-player path — conceder is loser, remaining non-eliminated players are winners; delegates to FinalizeMultiPlayerGameAsync
- GameForceConcedeHandler: same N-player/1v1 branch split for inactivity forfeit
- GameEndTurnHandler: N-player path uses GetNPlayerTurnLimitWinners + FinalizeMultiPlayerGameAsync on turn-limit game-over
- GameTurnTimerService: same N-player/1v1 branch on timer-expiry game-over
- Game.gd: player_eliminated signal + game.player_eliminated push handler
- game_screen.gd: _on_player_eliminated shows AcceptDialog; sets _is_spectating=true for the local player so they can watch the rest of the game

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-03-26 05:56:01 -04:00
356e1a50e3 Phase 3 & 4: Team colors, player_eliminated push, board shapes, lobby team UI
Phase 3 – Team modes:
- GameState: TeamColors dictionary (int → hex color string) populated from palette
- GameMessages: PlayerEliminatedPush, PlayerOutcomeDto, extended GameOverPush
- GameHandlerBase: FinalizeMultiPlayerGameAsync (pairwise ELO), BroadcastPlayerEliminatedAsync, GetAllPlayerIds for N-player push
- GameAttackHandler: snapshot pre-attack elimination state; use FinalizeMultiPlayerGameAsync; push PlayerEliminatedPush for mid-game knockouts
- game_screen.gd: turn order strip chips carry team-color left border from state.teamColors
- lobby_room_screen.gd: _team_label() helper; team badges on host/guest/additional slots

Phase 4 – Board shape library:
- BoardShapeGenerator: AutoShape() picks shape by player count; adds Triangular (3p), RadialStar (5p, 5-arm star), HexRing (6p, hex perimeter zones); CoordsInRect helper
- GameLobbyReadyHandler: auto-selects board shape at game start; passes BoardShape+PlayerCount into rules snapshot

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-03-26 05:50:55 -04:00
00bf788ac8 Phase 2 client: N-player HUD, lobby room, and DTO fields
Server:
- PlayerStateDto: add SeatIndex, TeamIndex, IsEliminated
- GameStateDto: add SeatOrder, GameMode
- CreateCustomLobbyResponse / JoinCustomLobbyResponse: add MaxPlayers, GameMode, TeamCount
- GameEngine.ToDto(): populate new fields from GameState / PlayerState
- Handlers: return MaxPlayers, GameMode, TeamCount in lobby create/join ACKs

Client:
- GameScreen.tscn: add TurnOrderStrip HBoxContainer in TopBar
- game_screen.gd: show TurnOrderStrip for >2 player games; _rebuild_turn_order_strip()
  builds per-player chips sorted by seatIndex, highlighting active/eliminated players
- LobbyRoomScreen.tscn: add GameModeLabel, AdditionalPlayersContainer,
  unique_name on FirstTurnSection/FirstTurnBtns
- lobby_room_screen.gd: show game mode + player count; _rebuild_additional_players_panel()
  shows occupied seats and empty waiting slots; hide first-turn buttons for 3+ players;
  _on_guest_joined refreshes full display instead of only updating GuestNameLabel

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-03-26 00:14:25 -04:00
f700fd5de6 Implement multiplayer extension: 2-10 players FFA/Team/Multi-Team
Core engine:
- Add SeatIndex, TeamIndex, IsEliminated to PlayerState
- Add SeatOrder, GameMode to GameState with helpers: ActiveSeats(),
  GetNextActiveSeat(), GetEnemyIds(), AreAllies()
- Add StartingZones to Board for per-seat placement validation
- Add BoardShape, PlayerCount to GameRules
- New BoardShapeGenerator: Rectangle (up to 4 seats) + Cross shapes
- N-player Initialize() overload; old 2-player overload delegates to it
- EndTurn uses GetNextActiveSeat() instead of hardcoded GetOpponentId()
- Attack finds target across all enemy players; EliminatePlayer() helper
  allows multi-player elimination without immediate game over
- PlaceArchSpirit validates via StartingZones (legacy row fallback preserved)
- AbilitySystem.Own() uses AreAllies() for team-aware ownership checks

Database:
- GameSession: +player_count, +game_mode, +additional_players_json
- CustomLobby: +game_mode, +team_count, +additional_players_json
- EF migration: AddMultiplayerSlots (applied)

Handlers:
- GameCreateCustomLobbyHandler: honours MaxPlayers/GameMode/TeamCount from request
- GameJoinCustomLobbyHandler: multi-slot join up to MaxPlayers
- GameLobbyReadyHandler: N-player all-ready check; seats/team assignment by mode
- GameReadyHandler: builds N-player list from AdditionalPlayersJson
- GameHandlerBase.LoadActiveSessionAsync: recognises additional players

Client:
- Game.gd: get_opponents() returns all non-local players;
  get_opponent() kept as backward-compat alias returning first opponent

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-03-25 23:57:36 -04:00
c692d8ec64 Implement UnitSentToDiscard trigger — enables Bloodlust abilities
New TriggerEventKind.UnitSentToDiscard fires whenever a unit is moved to the
discard pile, carrying SourceId = the killer unit's instance ID and
ActorId = the victim's player — consistent with UnitDeath convention.

Wired in 4 paths:
- GameEngine.cs attack: attacker killed by counterattack (SourceId = target)
- GameEngine.cs attack: target killed by attacker (SourceId = attacker)
- AbilitySystem KillUnit: ability/effect-driven death (SourceId = ctx.Source)
- AbilitySystem SendToDiscardEffect: direct discard effect (SourceId = ctx.Source)

OnUnitSentToDiscardTrigger is now matched in TriggerMatches. CausedBy field
acts as killer ownership scope; CausedBy="ExactSelf" checks SourceId == this
unit's InstanceId via the existing Own() helper, enabling:

  Bloodlust Aggression:
    { type:"OnUnitSentToDiscard", unitType:"Spirit", ownership:"Enemy",
      causedBy:"ExactSelf" }
    → ModifyDamageEffect { Amount:1 }, Duration: PermanentInMatch

  Bloodlust Vitality:
    { type:"OnUnitSentToDiscard", unitType:"Spirit", ownership:"Enemy",
      causedBy:"ExactSelf" }
    → ModifyMPEffect { Amount:1, StatTarget:"Max" }, Duration: UntilEndOfTurn

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-25 21:14:44 -04:00
843660dfce Implement cubemap skybox, multi-active skyboxes, and 2D scene backgrounds
- Server: Add SkyboxType + 6 CubeUrl fields to SkyboxDefinition entity
- Server: EF migration AddSkyboxCubemapType
- Server: GetSkyboxConfigResponse now returns array of all active skyboxes
- Admin: SkyboxManagerPage supports Panoramic/AnimatedPanorama/Cubemap types,
  6 face URL fields for cubemap, and independent per-skybox active toggle
- Client: ContentCache fetches + caches skyboxes; adds get_random_skybox,
  get_skybox_bg_url, load_texture_async, apply_scene_background helpers
- Client: game_screen replaces _fetch_skybox with ContentCache-based approach;
  adds _load_cubemap_skybox / _apply_cubemap_images / _apply_cubemap_material
- Client: 12 2D scene scripts call ContentCache.apply_scene_background(self)
  in _ready() to replace solid-color backgrounds with CDN skybox images

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-03-25 16:11:02 -04:00
453f008620 Fix rejoin opponent GUID + CDN skybox null/logging
- GameReadyResponse: add OpponentDisplayName? (populated only on AlreadyStarted)
- GameReadyHandler: inject SorIdentityDbContext; fetch opponent display name when
  session is already Active so rejoining clients get the name immediately
- Game.gd: on AlreadyStarted ack, read opponentDisplayName and set Game.opponent_name
  before calling _fetch_state() — fixes opponent showing as GUID on rejoin
- game_screen.gd: replace typed-Dictionary null assignment with safe Variant check
  to avoid silent GDScript coercion when no skybox is configured; strip query-string
  from URL before extension check (_fetch_skybox); add print logging throughout CDN
  skybox flow to surface download/decode failures

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-03-25 15:03:35 -04:00
Shard 4cc7a828ad Implement useful account mailbox with thread view, reply, and delete 2026-03-25 18:40:40 +00:00
dingo e56a35b154 Bazaar and leaderboard bug fixes 2026-03-25 14:00:06 -04:00
0ace4d247b Fix free game: display names in lobby/game screen + rules fallback
- CustomLobbyGuestJoinedPush: add GuestDisplayName (host now sees guest's real name)
- JoinCustomLobbyResponse: add HostAccountId/Name + GuestAccountId/Name so guest
  lobby room shows correct state instead of "Waiting for guest…"
- CustomLobbyGameStartedPush: add OpponentDisplayName so game screen shows name not GUID
- GameJoinCustomLobbyHandler: use 3-tier rules fallback (lobby override → db custom-default
  → hard-coded default) matching StartGameAsync, fixing inconsistent rule display on join
- GameLobbyReadyHandler: inject SorIdentityDbContext, fetch display names for both
  players before pushing game.custom.started
- CustomLobby.gd: set Game.opponent_name on game.custom.started push; emit display
  names in guest_joined and game_starting signals; patch join response lobby dict
- lobby_room_screen.gd: use display name in _on_guest_joined; update _on_game_starting signature

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-03-25 12:14:14 -04:00
2a15bd2eb3 Fix crashes, add ModifyAttackRange effects, ArchSpirit swap in deck editor
- Bazaar Deck tab crash: null-safe float conversion for usdPrice in store_item_row.gd
- Leaderboard crash: freed-object guard in _on_leaderboard_ok (is_instance_valid check)
- Add ModifyMinAttackRangeEffect / ModifyMaxAttackRangeEffect with clamp-to-0 and correct reversal tracking
- AbilityBuilder: add new range effects to Stat Modification group + _amountOnlyTypes
- collection.set_arch_spirit: new handler, request record, and service registration
- Deck editor: show Tier-1 commander row with Change button + ArchSpirit picker panel

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-25 11:25:44 -04:00
9c42e5c1c8 Aura: self-apply Actions + ClearOnLeave / LingerDuration on leave
Previously, Aura abilities only fired OnEnterAuraRange / OnLeaveAuraRange
trigger events — their own Actions were never executed. Auras now directly
apply their Actions to any unit that enters range (using WhileSourceOnBattlefield
by default) and handle departure via three modes:

- Persist (default): effects expire at their configured Duration unchanged
- ClearOnLeave: effects are reverted immediately when the unit leaves range
- LingerDuration: effects switch to the specified duration when leaving range,
  allowing them to outlive the aura's reach (and the source if it leaves)

Server:
- AbilityDefinition: add ClearOnLeave (bool) and LingerDuration (DurationModel?)
- AbilitySystem: add ApplyAuraEffects + HandleAuraLeave helpers;
  refactor FireAuraTransition to take FieldCard + AbilityDefinition and call
  both helpers; update all six call sites in EvaluateAuraTransitions /
  EvaluateAurasOnEnter / EvaluateAurasOnLeave to use the unified path

Admin:
- AbilityBuilder: add AuraClearOnLeave / AuraLingerDurationStr / N draft fields;
  parse + compile round-trip; 3-radio On Leave UI + optional Linger duration select;
  update Aura help row to describe the new behaviour

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-24 21:11:56 -04:00
afb083093a Hill Training: ExactSelf trigger + TileAffinityMatches FieldCard fix
- AbilitySystem: add TileAffinityMatchesCondition case for FieldCard subject
  so activation conditions check the tile the unit is currently standing on
  (previously only handled Coord subjects; triggered abilities pass FieldCard)
- AbilityBuilder: add "ExactSelf" to OwnershipValues dropdown for trigger events
  so designers can restrict triggers to only this specific unit instance
- AbilityBuilder help section: add Trigger Ownership table documenting all
  ownership values including ExactSelf with clear explanation of instance-level scope

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 14:23:30 -04:00
dingo 2b7b6aa2ba Fixed but in AbilitySystem for resolving affinity 2026-03-23 13:55:36 -04:00
a870f2391b Add AffinitySystem.Decompose + fix SetAffinity for non-basic affinities
SetAffinity previously hardcoded Base1=Void which is only correct for
basic affinities. Non-basics like Jungle need (Forest,Forest), Island
needs (Lake,Hill), etc. — Void+Jungle would fall through to PureVoid.

Added AffinitySystem.Decompose(Affinity) which reverse-maps every
resolved affinity to its canonical (Base1, Base2) pair. SetAffinity
on tiles now calls Decompose so any affinity — basic or non-basic —
is stored correctly and Resolve() returns the intended value.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 13:04:01 -04:00
04dd457efa Fix SetAffinity tile layout: Base1=Void, Base2=affinity
Setting both slots to the same basic affinity produces the wrong
resolved value (Lake+Lake→Ocean). Basic tiles are represented as
(Void, Basic) per §8, so SetAffinity now sets Base1=Void and
Base2=newAffinity. Both original slot values are still tracked
for reversal when the duration expires.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 13:01:08 -04:00
a768f1b27c Fix Battlefield tile targeting and SetAffinity on tiles
Bug: Battlefield/All tile targets were always empty — the tile
resolution path required client-provided coords for every case,
but board-wide abilities (Scope=Battlefield, All=true) never send
coords from the client. Added server-side enumeration of all board
tiles for this case.

Fix: SetAffinity on a tile now writes both Base1 and Base2 to
the new affinity so AffinitySystem.Resolve returns the correct
value unambiguously. Reversal tracks both slots independently so
both are restored when the duration expires.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 12:33:03 -04:00
14609428e6 Fix three bugs blocking SetAffinity on tile targets
Bug 1 — SetAffinityEffect silently ignored for Coord targets:
ExecuteEffect had no tile case for SetAffinityEffect (only handled
CardInstance). Added case that writes to Base2 and tracks the original
value for duration reversal using a "tile:X,Y" target ref.

Bug 2 — ApplyReversal couldn't find tile targets:
The reversal lookup only searched players' card zones. Added parsing
of the "tile:X,Y" ref format to produce the Coord used to re-execute
the SetBaseAffinity2 reversal effect.

Bug 3 — TileIsOccupied / TileIsUnoccupied / TileAffinityMatches
conditions not implemented in EvaluateCondition:
All three tile condition types fell through to the default (return true),
so conditions like TileIsOccupied were silently no-ops. Implemented all
three with proper tile lookup and occupant/affinity checks.

Wavecrasher (SetAffinity Lake on occupied tiles, ForNTurns:2) now
correctly selects only occupied tiles, changes their affinity, and
reverts them automatically after two turns.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 12:23:39 -04:00
fe293f6bee Tile highlight texture system with cursor + hover glow
Server / DB:
- New HighlightConfig entity (catalog.highlight_configs): one row per
  highlight type (Movement/Attack/Ability/Terramorpha/Selector). Supports
  static texture URL or animated (base folder + frame count + FPS) with a
  FallbackHex RGBA colour for when no texture is configured.
- EF migration AddHighlightConfig.
- CosmeticType.HighlightPack added; AssetCdnUrl stores serialised JSON with
  per-type texture config so players can buy full highlight packs in the Bazaar.
- content.get_highlight_config handler in SOR.Content; response DTOs added to
  ContentMessages.cs; handler registered in ServiceRegistration.

Admin:
- /content/highlights page: inline editor for all five highlight types
  (CDN path, animated toggle, frame count, FPS, fallback hex with swatch).
  Upserts rows — no delete needed since there is always exactly one row per type.
- Highlights nav link added to Content section in NavMenu.
- CosmeticEditor: HighlightPack type renders a per-type table (Movement/
  Attack/Ability/Terramorpha/Selector), serialising to JSON in AssetCdnUrl.

Client (Godot):
- HighlightConfig autoload: fetches content.get_highlight_config on startup,
  caches to user://highlight_config.json. Provides get_texture(type) and
  get_color(type). Supports set_override/clear_override/apply_cosmetic_pack
  for cosmetic and settings overrides.
- Settings autoload: highlight_overrides Dictionary persisted in settings.cfg.
  set_highlight_override/clear_highlight_override push into HighlightConfig.
- settings_screen.gd: programmatic "Highlight Texture Overrides" section added
  with a LineEdit + Reset button per type; appended to Sections VBoxContainer.
- game_screen.gd:
  • _add_highlight() rewritten to use flat PlaneMesh quads with textured
    StandardMaterial3D. Accepts a string type key ("movement", "attack",
    "ability", "terramorpha", "selector") instead of a Color constant.
  • _cursor_highlight + _hover_team_overlay: two permanently-allocated quads
    that are never freed. The selector highlights the tile under the mouse at
    all times; the team overlay shows a coloured tint when hovering an occupied
    tile. Both are preserved across _clear_highlights() and _build_board().
  • _update_hover(): called on every InputEventMouseMotion event. Moves the
    selector quad, shows the team-colour overlay when hovering an occupied tile,
    and boosts MeshInstance3D emission on the hovered unit via
    set_surface_override_material (reset when hover leaves).
  • All existing _highlight_tiles() / _add_highlight() callers updated from
    HI_* Color constants to type key strings.

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-03-23 06:50:00 -04:00
9c44657deb Accept legacy TileAffinityMatchesFilter discriminator as read alias
Cards saved with the old typo in AbilitiesJson now deserialize correctly.
- PolymorphicAbilityConverter: s_reverseMap uses TryAdd so the first
  [PolyType] attribute wins for writing (canonical); subsequent attributes
  register additional discriminators as read-only aliases.
- Filters.cs: adds "TileAffinityMatchesFilter" as an alias beside the
  canonical "TileAffinityMatches" discriminator. Existing DB rows are
  accepted without migration; new saves write the correct canonical form.

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-03-22 22:05:15 -04:00
7a2e873127 Fix SummonToken TileFilter discriminator: TileAffinityMatchesFilter → TileAffinityMatches
The PolyType attribute on Filter registers TileAffinityMatchesFilter under
the discriminator "TileAffinityMatches" (no Filter suffix). CompileEffect was
writing "TileAffinityMatchesFilter" which caused a JsonException on
deserialization when game.activate_ability tried to parse the ability JSON.

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-03-22 21:55:24 -04:00
324537ded0 SummonToken: structured admin editor + affinity enforcement + art URLs
- AbilityBuilder.razor: replace raw JSON textarea with full structured
  editor for SummonToken effects. Supports two modes:
  • Existing Card — searchable autocomplete from Spirit card catalog
  • Custom Token — inline editor for all Spirit stats (name, affinity,
    health/defense/damage, movement type/MP, attack range, LOS, all
    permission flags, genus tags, abilities JSON, 2D art URL, 3D model URL)
  Compiles TileFilter[TileAffinityMatchesFilter] when affinity is non-Void,
  enabling client-side tile highlighting to match server enforcement.

- AbilitySystem.cs (SummonTokenEffect): validate that the target tile's
  affinity is compatible with the token's affinity before placing.

- GameState.cs (CardInstance): add Art2dUrl + ModelUrl so summoned tokens
  can carry visual asset references through the game state.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-22 16:15:36 -04:00
1831fd646c Add Previous Tier autocomplete to card editor
ArchSpirit cards can now have their Previous Tier set via a searchable
dropdown in the Stats tab. Type to filter by name, select to bind the
GUID. Shows current selection with a clear button. Excludes the card
itself from the list.

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-03-22 15:33:14 -04:00
6924ffdbd5 Remove [RULES] diagnostic logging (issue confirmed fixed)
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-03-22 13:48:51 -04:00
5989eba49b Add [RULES] diagnostic logging + remove [DELTA] console noise
- MatchmakerService: log whether ranked ruleset was found and its
  StartingRandomTilePct after DB query
- GameReadyHandler: log RuleSnapshotJson snippet and deserialized
  StartingRandomTilePct/BoardWidth/BoardHeight when both players ready
- GameHandlerBase: remove [DELTA] Console.WriteLines added for delta
  diffing debug (issue resolved)

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-03-22 13:36:34 -04:00
fe62df5d56 Fix custom lobby rules not inheriting admin-configured defaults
GameLobbyReadyHandler was building effective game rules by falling back
directly to the hard-coded GameRules.Default for any field not explicitly
set by the lobby host. It never consulted the admin-configured
IsCustomDefault ruleset from the database.

This meant changes to ranked/custom rule settings (e.g. tile affinity %)
in the admin panel had no effect on custom lobby games unless the host
explicitly overrode every field via the rules editor.

Fix: load the IsCustomDefault GameRuleSet at game-start time and use it
as the intermediate fallback — lobby override → admin default → hard-coded
default — matching the same three-level chain used by GameCreateCustomLobbyHandler
when the lobby is first created.

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-03-22 12:54:07 -04:00
23643d0934 Fix ArchSpirit ability activation + Ownership:Target auto-resolution
- AbilitySystem.cs: ActivateAbility was only searching player.Field for the
  source unit, but player.ArchSpirit is stored in a separate field and was never
  checked. Active abilities on an ArchSpirit now work correctly.

- game_screen.gd: Add "Target" to auto_ownerships so the client skips the
  player-picker UI for Ownership:Target actions. The server auto-resolves them
  from ctx.ResolvedTargets (the owner of the previously targeted card), which
  is exactly what Bounce needs: refund SP to the owner of the returned spirit
  without asking the user to choose a player.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-22 10:42:56 -04:00
2c737458a8 Fix ability builder crash + implement TargetOwnership.Target for Player targets
- AbilityBuilder.razor: ReadFixed now checks if the JSON node is a JsonObject
  before calling GetValue<int>() on it. Previously, a ValueExpr like
  {"Ref":"Target.SpCost"} caused an InvalidOperationException that was swallowed
  silently by ParseJson's catch block, leaving the builder showing no abilities.

- AbilitySystem.cs: TargetOwnership.Target on Player-type selectors now resolves
  to the owner of the last CardInstance in ctx.ResolvedTargets. This enables
  abilities like Bounce: Action 1 returns a spirit to hand, Action 2 targets that
  spirit's owner (Ownership:Target) to refund its channel cost via a Ref value.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-22 10:21:35 -04:00
d27c7f67c3 Debug delta diffing: add diagnostics + empty-delta fallback
- All game action handlers: move ToDto() call to after SaveStateAsync()
  so the ACK's StateVersion matches the pushed delta (stale-version fix)
- GameHandlerBase.PushStateToPlayersAsync: add empty-delta safety fallback
  — when ComputeDelta() returns all-null content fields, fall back to a
  full game.state_update push so clients always see the correct state
- Add Console.WriteLine diagnostics to PushStateToPlayersAsync to expose
  prev/next phase, turn, active player, and whether prevStateJson matches
  the post-mutation session.StateJson (root cause investigation)
- Game.gd: wire game.activity push to game_activity signal

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-03-21 21:52:45 -04:00
663b92a56b Expose all custom lobby rules in ranked play
MatchmakerService now snapshots all 18 game-play fields from the ranked
ruleset (previously only snapshotted 6). Admin panel at /game/ranked-rules
gains 6 new cards for the previously hidden fields:

- Board Size (width × height)
- Hand Size (cap + discard-on-max behaviour)
- Deck Rules (min/max deck size, max Tier-1 Arch copies)
- Timers & Limits (turn timer, game time limit, turn limit)
- Unit Buffs (MP buff per turn)
- Tile Randomisation (starting random tile %)

No DB migration needed — GameRuleSet already stores all fields.

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-03-21 12:44:21 -04:00
6650561051 Fix delta diffs always empty: capture prevStateJson before engine mutation
All GameEngine.* action methods mutate the state object in place and return
the same reference. Passing that reference as both 'prev' and 'next' to
GameStateDiffer produced all-null deltas — so phase, activePlayer, turnNumber,
unit stats, hand/discard, and tile changes were never sent via delta, requiring
clients to request a full resync after every action.

Fix: capture prevStateJson = session.StateJson! before calling the engine
method (before mutation occurs), then pass it to PushStateToPlayersAsync.
PushStateToPlayersAsync now accepts string? prevStateJson and deserializes it
internally for the diff computation, giving a genuine before/after snapshot.

Affects all 10 action handlers: EndTurn, Draw, Attack, MoveUnit, PlayCard,
ActivateAbility, Sacrifice, Ascend, Transition, PlaceArchSpirit.

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-03-21 10:50:15 -04:00
b812372514 Fix rule suggestions + placement highlights
- JoinCustomLobbyResponse now includes ActiveRules so the guest's rule editor
  pre-populates from the lobby's current effective rules instead of hardcoded
  defaults; previously all fields in a suggestion were sent as defaults, causing
  accepted suggestions to reset rules to defaults.
- game_screen.gd: placement tile highlights are now re-applied on every state
  update while the player hasn't placed yet, not only on the first entry into
  PLACEMENT mode; fixes highlights disappearing when the opponent places their
  ArchSpirit and a delta arrives mid-placement.

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-03-21 10:22:29 -04:00
97b8391608 Live-star skybox: game activity feed + procedural star sky
Server:
- GameActivityRegistry singleton tracks subscribed clients
- game.subscribe_activity handler: registers client, returns active session IDs
- game.unsubscribe_activity handler: deregisters client
- BroadcastActivityAsync helper in GameHandlerBase (mirrors spectator push pattern)
- GamePlaceArchSpiritHandler broadcasts "started" when both players have placed
- FinalizeGameAsync broadcasts "ended" to all subscribers

Client:
- Settings.skybox_mode: "live" | "cdn" | "off" (default: "live"), persisted to cfg
- Game.game_activity signal forwarded from game.activity push
- game_screen.gd: live mode sets near-black procedural sky; subscribes to activity
  feed; each active session is an emissive sphere star (280-unit radius, blue-white)
  that fades in on start, twinkles via sine tween, and flash-explodes on end
- CDN and Off modes preserved; hot-swap supported mid-game via Settings.settings_changed
- InGameSettings: SkyboxModeOption OptionButton (Live / CDN / Off)

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-03-21 09:49:08 -04:00
5b66f459c0 Add skybox system: admin management + client 3D application
- SkyboxDefinition entity (catalog schema) with static/animated support
- EF migration: catalog.skybox_definitions table
- content.get_skybox_config handler returns active skybox definition
- SkyboxManagerPage.razor: full CRUD admin UI with inline editing,
  activate/deactivate, and animated frame config
- NavMenu.razor: Skyboxes link under Content section
- game_screen.gd: fetches active skybox on ready; applies as
  PanoramaSkyMaterial on WorldEnvironment; animated skyboxes cycle
  frames via Timer; procedural sky kept as fallback when none active

Also fixes inverted camera pan (delta.x / -delta.y signs corrected).

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-03-21 08:55:45 -04:00
cf5089ae50 Delta state system: replace full-push with game.state_delta
After any game action, push a structured GameStateDelta instead of
the full GameStateDto to both players and spectators. Full state is
preserved for: initial connect (game.ready), reconnect/get_state,
spectate ACK, and turn-timer expiry.

Server:
- GameMessages.cs: add GameStateDeltaPush, GameStateDelta, TileDelta,
  UnitDelta, PlayerStatsDelta, GameMetaDelta record types
- GameEngine.cs: make ToCardDto internal (used by differ)
- GameStateDiffer.cs: new file — ComputeDelta (viewer-specific) and
  ComputeSpectatorDelta; diffs tiles, field units, hands, discards,
  archs, player stats, and game meta
- GameHandlerBase.cs: PushStateToPlayersAsync gains optional prevState
  param; when provided pushes delta, else falls back to full push
- All 10 action handlers: pass prev state to PushStateToPlayersAsync

Client:
- Game.gd: _state_version tracking, _apply_delta, _merge_unit_delta,
  request_sync, game.state_delta push handler with auto-resync on gap
- in_game_settings.gd + InGameSettings.tscn: Request Sync button

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-03-21 06:54:33 -04:00
c93aaf64c0 Two-tier inactivity: mutual idle blocks force-concede at 10 min
Tier 1 (5 min, unchanged):
- Active player: game.inactive_warning — "you may be forfeited"
- Waiting player: game.opponent_inactive — "Accept Forfeit / Wait"

Tier 2 (10 min — mutual idle):
- If the game is still stalled after 10 min the waiting player also
  hasn't claimed forfeit, so both are treated as mutually idle
- Sends game.both_idle_warning to BOTH players
- Client closes any open tier-1 dialogs and shows "Wait" only —
  no concede or force-concede available
- Prevents the tactic of both players going idle to pressure the
  other into conceding

Monitor service now prunes notified sets on each poll so sessions
that become active again can be re-notified if they stall again.

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-03-21 06:16:13 -04:00
674f1f6b8c Block spectators from joining during Placement phase
Deserialize state before registering the spectator and reject with
PLACEMENT_IN_PROGRESS if both ArchSpirits haven't been placed yet.

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-03-21 06:00:48 -04:00
a84a610964 Fix rules editor: allow Open state + update UI from ACK
Server (GameUpdateLobbyRulesHandler):
- Allow update_rules in both Open (solo) and Full lobby states,
  not just Full — was silently failing when no guest had joined yet
- Push to guest only when GuestAccountId is present (was crashing
  with null deref in Open state if status check had been bypassed)

Client (CustomLobby.gd):
- update_rules ACK callback now emits lobby_rules_updated immediately
  from the ACK payload instead of relying solely on the lobby_updated push

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-03-20 21:28:58 -04:00
66e7f75155 Tile seeding: compound tiles, void collapse, PerfectAether wildcard
Board.Create():
- Base1 pool: {Lake, Hill, Forest, Field, Aether} (no Void)
- Base2 pool: Base1 pool + Void; same pct roll independently
- If Base2 draws Void → both slots stay Void (no random Gateway tiles)
- Random tiles are now either fully compound or fully void

AffinitySystem.IsAffinityValid():
- PerfectAether tile (Aether+Aether) accepts any of the four elemental
  basics {Lake, Hill, Forest, Field} as valid channeling 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-03-20 20:22:53 -04:00
2a30408c8b Fix AddStartingTileRule migration — was generated empty, replaced with correct columns
Previous migration file was empty (generated before entity changes were saved).
Deleted the empty migration, regenerated with correct Up/Down:
- ADD COLUMN StartingRandomTilePct (int, not null, default 0) on game.game_rule_sets
- ADD COLUMN StartingRandomTilePctOverride (int, nullable) on game.custom_lobbies
Applied to production DB.

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-03-20 19:27:22 -04:00
aded0f03a0 Phase 8: StartingRandomTilePct rule — full-stack implementation
- GameRules: add StartingRandomTilePct (int, 0–100, default 0)
- Board.Create(): accept startingRandomTilePct param; each tile
  independently seeded from {Lake, Hill, Forest, Field} on Base1
- GameEngine: pass rules.StartingRandomTilePct to Board.Create()
- GameMessages: add StartingRandomTilePct to CustomRulesOverride + CustomRulesDto
- CustomLobby entity: add StartingRandomTilePctOverride column
- GameRuleSet entity: add StartingRandomTilePct column
- Migration AddStartingTileRule: new columns on custom_lobbies + game_rule_sets
- All 6 handlers wired: Create, LobbyReady, UpdateRules, AcceptSuggestion,
  ListCustomLobbies, ListActiveLobbies
- Client lobby_room_screen.gd: "Starting Tile Affinity %" SpinBox (0–100)
  in BOARD section; displayed in rules label and suggestion summary

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-03-20 18:23:15 -04:00