Commit Graph
165 Commits
Author SHA1 Message Date
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
3d597856e4 Implement custom rules editor + guest rule suggestions
Server:
- RuleSuggestionService — in-memory pending suggestion store (one per lobby)
- GameSuggestRulesHandler (game.custom.suggest_rules) — guest proposes rules
- GameAcceptRuleSuggestionHandler (game.custom.suggest_rules.accept) — host applies suggestion
- GameRejectRuleSuggestionHandler (game.custom.suggest_rules.reject) — host dismisses
- New message types: SuggestRulesRequest/Response, AcceptRuleSuggestionRequest/Response,
  RejectRuleSuggestionRequest/Response, LobbyRuleSuggestionPush, LobbyRuleSuggestionRejectedPush
- ServiceRegistration: register RuleSuggestionService + 3 new handlers

Client:
- CustomLobby.gd: rule_suggestion_received/rejected signals + suggest/accept/reject methods
- LobbyRoomScreen.tscn: add SuggestionBanner (host accept/reject UI); EditRulesBtn always visible
- lobby_room_screen.gd: replace OS.alert stub with full scrollable rules editor popup
  (SpinBoxes + CheckBoxes for all 17 rule fields, grouped by category); host sees "Apply",
  guest sees "Suggest"; SuggestionBanner shows proposed rules summary to host

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 17:27:16 -04:00
aa4533269f Add Delete action to admin Custom Lobbies page; fix CS0136 in CollectionGetCardsHandler
- Admin CustomLobbiesPage: add Delete button (hard DB remove with confirm dialog)
  shown on every lobby row; Cancel remains for Open/Full lobbies only
- CollectionGetCardsHandler: rename inner-scope variables (groupedTotal/groupedDtos)
  to fix CS0136 compiler error from same-name variables in nested vs outer 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-20 17:12:05 -04:00
dingo e377faad92 Sync 2026-03-20 17:07:19 -04:00
dingo 2e3a5e4569 Enabling Decks to have multiple Tier 1 ArchSpirits 2026-03-20 10:13:55 -04:00
Shard 7d572ae55c Standardize active ability execution between unit and card paths 2026-03-19 23:53:05 +00:00
Shard 7ca86ce858 Enforce CanMove and CanUseAbility suppression in game flow 2026-03-19 22:55:04 +00:00
Shard 7a90e2b8ab Unify ability schema: canonical AbilitiesJson with EffectsJson compatibility 2026-03-19 21:20:27 +00:00
e9476a3775 Fix ReturnToHandEffect: revoke passives + skip target conditions at activation
- Skip ActivationConditions with Subject=="Target" in ActivateAbility (mirrors
  AbilitiesJson code path) so conditions like IsOnTileWithAffinity{Target,Lake}
  aren't evaluated against the source unit at activation time
- Add RevokePassivesForSource call in ReturnToHandEffect before removing the
  unit from the field, matching SendToDiscardEffect 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-03-19 15:49:16 -04:00
dingo c9b1da5993 Missed adding in Effectsto the DTO.... 2026-03-19 14:12:33 -04:00
dingo d5c6ca2559 Missing EffectJson for Repentance and Instinct cards 2026-03-19 14:04:20 -04:00
6fd1b07ab2 Fix custom lobby staying in Started state after game ends
Add CustomLobbyStatus.Completed; in FinalizeGameAsync, query the lobby
linked via GameSessionId and set Status=Completed when the game ends.
This removes finished games from the active-games browser (list_active
only returns Started lobbies) and from the admin "active" count.

Admin page: add Completed filter option, dark badge, include Started
lobbies in the always-loaded set so stale in-progress games are visible.

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-19 13:27:39 -04:00
efcd693d60 Fix null-session prompt, stale ready state, spectator UI, and admin cancel
- init_screen.gd: handle null sessionId from game.get_active_session.ack
  properly — str(null)="<null>" which passed the is_empty() check causing
  every player to see "active game in progress (null phase)" on login
- CustomLobby.gd: call clear_state() at the start of create() and join() so
  that i_am_ready/partner_ready are reset between lobbies — fixes players
  appearing instantly ready when entering a new lobby after a previous game
- game_screen.gd: in _setup_spectator_ui(), hide _settings_btn (prevents
  accessing the Concede button) and add a programmatic "Leave" button that
  calls Game.stop_spectating() and navigates back to FreePlayScreen
- CustomLobbiesPage.razor: add Cancel button (admin) for Open/Full lobbies;
  directly sets Status=Cancelled and refreshes 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-19 10:49:46 -04:00
2ec29ce2dc Fix leave handler, partner-left push, and GDScript compile error
- GameLeaveCustomLobbyHandler: return success silently for Started/Cancelled
  status (allows the Leave button to work regardless of lobby state); inject
  IClientPush and send LobbyPartnerLeftPush to remaining participant when
  someone leaves a Full lobby; reset ready flags when guest leaves
- GameMessages: add LobbyPartnerLeftPush(LobbyId, Reason)
- CustomLobby.gd: add partner_left signal; handle game.custom.lobby.partner_left
  push by calling clear_state() then emitting partner_left
- lobby_room_screen.gd: connect/disconnect partner_left; show toast + navigate
  back to FreePlayScreen when partner leaves
- free_play_screen.gd: extract auto-select into _auto_select_deck() helper to
  fix GDScript parse error (comma inside multi-line if-body within lambda)

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-19 09:45:24 -04:00
d61ebe66b8 Phase 8: Free Play ready-up system + client scenes
Server (Phase A):
- CustomLobby: +HostReady/GuestReady/HostFirstTurnPref/GuestFirstTurnPref/MaxPlayers
- Migration: AddReadyUpSystem — applied to prod DB
- GameJoinCustomLobbyHandler: no longer auto-creates session; sets Full status,
  resets readiness, pushes CustomLobbyGuestJoinedPush to host
- GameLobbyReadyHandler (NEW): game.custom.lobby.ready — marks caller ready,
  resolves first-turn, creates session + pushes game.custom.started when all ready
- GameUnreadyHandler (NEW): game.custom.lobby.unready
- GameChangeLobbyDeckHandler (NEW): game.custom.lobby.change_deck
- GameUpdateLobbyRulesHandler (NEW): game.custom.update_rules (host only)
- GameListActiveLobbiesHandler (NEW): game.custom.list_active (Status==Started)
- GameListCustomLobbiesHandler: now batch-loads host/guest display names
- GameMessages: +LobbyReadyRequest/Response, UnreadyInLobbyRequest/Response,
  ChangeLobbyDeckRequest/Response, UpdateLobbyRulesRequest/Response,
  ListActiveLobbiesRequest/Response, LobbyReadyStatusPush, LobbyDeckChangedPush,
  ActiveLobbyDto; CustomLobbyDto +HostDisplayName/GuestDisplayName
- ServiceRegistration: register 5 new handlers

Client (Phase B):
- CustomLobby.gd: new autoload for Free Play lobby state + all server calls
- project.godot: register CustomLobby autoload
- MainScreen: +Free Play button → FreePlayScreen.tscn
- FreePlayScreen (NEW): Open Lobbies tab + Active Games tab + Create dialog
- LobbyRoomScreen (NEW): ready-up UI, first-turn selector, preset voting
- Game.gd: +is_spectating, +start_spectating(), +stop_spectating()
- game_screen.gd: spectator mode — SPECTATING label, hidden action buttons,
  neutral HUD labels, stop_spectating() on exit

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-19 09:10:55 -04:00
cf05bacf0c Phase 6: GameGetLobbyHandler + CustomLobbyDetailDto
- game.custom.get returns full CustomLobbyDetailDto: all effective rules (overrides
  merged with GameRules.Default), host/guest account IDs, status, GameSessionId.
- CustomLobbyDetailDto includes Status string, GuestAccountId (nullable),
  GameSessionId (nullable); richer than the browse-list CustomLobbyDto.
- GetCustomLobbyRequest / GetCustomLobbyResponse added to GameMessages.cs.
- ServiceRegistration: registered GameGetLobbyHandler as transient IMessageHandler.

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-18 23:20:23 -04:00
e9c5255f85 Phase 5: Preset system — VoteSessionService + 5 handlers
- VoteSessionService singleton: ConcurrentDictionary<Guid, ActiveVote> keyed by lobbyId.
  TryStart prevents concurrent votes; Cast resolves immediately on any rejection or all approval.
- GameSavePresetHandler (game.custom.preset.save): captures lobby override columns into
  CustomRulesOverride JSON and persists as LobbyPreset; participants only.
- GameListPresetsHandler (game.custom.preset.list): returns all presets owned by caller.
- GameDeletePresetHandler (game.custom.preset.delete): owner-only delete.
- GameProposePresetHandler (game.custom.preset.propose): host-only in Full lobby;
  starts vote with guest as sole voter; pushes game.custom.preset.vote_requested to guest.
- GameVotePresetHandler (game.custom.preset.vote): casts yes/no;
  Approved → applies preset overrides to lobby DB + pushes game.custom.lobby_updated to both;
  Rejected → pushes game.custom.preset.vote_rejected to both.
- GameMessages.cs: SavePreset/ListPresets/DeletePreset/ProposePreset/VotePreset
  request/response types; LobbyPresetDto; PresetVoteRequestedPush, LobbyUpdatedPush,
  PresetVoteRejectedPush.

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-18 23:18:40 -04:00
02d469490b Phase 4: Spectator support — SpectatorRegistryService + handlers
- SpectatorRegistryService singleton: ConcurrentDictionary<Guid, ImmutableHashSet<Guid>>
  tracking spectators per session. Static Instance for use in static base-class helpers.
- GameEngine.ToDtoSpectator: delegates to ToDto(state, "") — both hands hidden.
- GameHandlerBase.PushStateToPlayersAsync: extended to push hand-hidden state_update
  to all registered spectators via SpectatorRegistryService.Instance.
- GameHandlerBase.FinalizeGameAsync: pushes game.over to spectators then calls
  RemoveSession to evict the entry from the registry.
- GameSpectateHandler (game.spectate): validates session Active, registers spectator,
  returns current spectator-view state as ack.
- GameStopSpectatingHandler (game.spectate.stop): unregisters the caller.
- GameMessages.cs: SpectateRequest/Response, StopSpectatingRequest/Response.
- ServiceRegistration.cs: register SpectatorRegistryService singleton + both handlers.

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-18 23:14:24 -04:00
2c40fb036f Phase 3: GameTurnTimerService — per-turn auto-end timer
- GameTurnTimerService singleton manages CancellationTokenSource per session.
  Fires AutoEndTurnAsync on expiry: acquires row lock, calls GameEngine.EndTurn,
  saves state, pushes to players, finalizes game if turn-limit reached.
  Caps effective delay by TimeLimitMinutes remaining wall time.
- FinalizeGameAsync (GameHandlerBase) calls GameTurnTimerService.Instance?.CancelTimer
  so all game-over paths (attack, concede, force-concede) cleanly cancel timers.
- GamePlaceArchSpiritHandler: injects timer service; ResetTimer when bothPlaced.
- GameEndTurnHandler: injects timer service; ResetTimer on normal end-turn,
  CancelTimer (via FinalizeGameAsync) on turn-limit game-over.
- ServiceRegistration: singleton + AddHostedService delegate for lifetime callbacks.
- GameHandlerBase: SaveStateAsync, PushStateToPlayersAsync, FinalizeGameAsync
  promoted from protected static → internal static for timer service access.

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-18 23:11:15 -04:00
93d27e9270 Phase 2+7: GameEngine rule enforcement + extended lobby handlers
Phase 2 — GameEngine:
- Draw(): now draws DrawPerTurn+DrawPerTurnBonus cards per call (was always 1);
  enforces HandSizeCap with block-draw or auto-discard (DiscardOnMaxHand)
- EndTurn(): returns (GameState, bool gameOver); applies MpBuff to all next-player
  units at turn start; checks TurnLimit and sets GameOver phase if exceeded
- GetTurnLimitWinner(): helper returning winner/loser by ArchSpirit HP (P1 on tie)
- ValidateDeck(): new public method checking MinDeckSize, MaxDeckSize, MaxArchTier1
- GameRules note: new fields are already in place from Phase 1

Phase 7 — Handlers + Messages:
- CustomRulesOverride: +9 new nullable fields (HandSizeCap, DiscardOnMaxHand,
  MaxDeckSize, MinDeckSize, MaxArchTier1, TurnTimerSeconds, TimeLimitMinutes,
  TurnLimit, MpBuff)
- CustomRulesDto: +9 matching fields + HasPassword bool
- CreateCustomLobbyRequest: +Password field
- JoinCustomLobbyRequest: +Password field; handler now validates password
- ListCustomLobbiesRequest: +NameSearch, ShowPasswordProtected filters
- GameCreateCustomLobbyHandler: full rule merge + ToDto covers all new fields
- GameJoinCustomLobbyHandler: password check + full rules construction incl. new fields
- GameListCustomLobbiesHandler: full DTO mapping + NameSearch/password filters
- GameEndTurnHandler: injected identityDb+eventBus; handles TurnLimit game-over
  using same pattern as GameAttackHandler (set session fields before SaveStateAsync)
- GameDrawHandler: update deconstruct to discard unused drawn list (_)
- CustomLobbyGuestJoinedPush: new push type (used in Phase 6)

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-18 23:01:09 -04:00
71947f785e Phase 1: Custom game system — DB schema extensions
- Extend CustomLobby with 12 new rule override columns (Password,
  HandSizeCap, DiscardOnMaxHand, MaxDeckSize, MinDeckSize, MaxArchTier1,
  TurnTimerSeconds, TimeLimitMinutes, TurnLimit, MpBuff, BoardWidth/Height)
- Extend GameRuleSet with matching non-nullable rule fields (same set)
- Extend GameRules record with 9 new rule fields (all default to 0/false)
- Add LobbyPreset entity (owner-scoped named rule presets)
- Register LobbyPreset in GameDbContext with index on OwnerAccountId
- Migration: AddCustomGameExtensions (applied to pg-forge-01)
- Add custom-game-system-plan.md with full 8-phase architecture plan
  and deferred features tracking list
- Also includes: AbilityBuilder ValueExpr dropdowns + help panel,
  Affinity enum/system fixes (from prior sessions)

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-18 22:42:59 -04:00
530b56c33c Fix: ghost-match bug — session stays Active after game ends
Two root causes fixed:

1. Race condition (primary cause): SaveStateAsync committed the
   transaction with Phase=GameOver in StateJson, but session.Status
   was not set to Completed until a separate SaveChangesAsync in
   FinalizeGameAsync. If the server crashed or any exception was
   thrown between those two calls, the session was left Active with
   a GameOver state — causing the "active game" prompt on next login.

   Fix: each game-over handler (concede, force_concede, attack) now
   sets session.Status/WinnerAccountId/WinCondition/EndedAt BEFORE
   calling SaveStateAsync, so all fields commit atomically in the
   same transaction.

2. Wrong save order in FinalizeGameAsync: identityDb.SaveChangesAsync
   (ELO update) ran before gameDb.SaveChangesAsync (Status=Completed).
   Any transient identity-DB error left the session permanently Active.

   Fix: gameDb is saved first; ELO runs after, so a failed ELO update
   never causes a ghost match.

3. Defensive startup heal (GameStartupCleanupService): on server
   start, Active sessions whose StateJson contains Phase=GameOver are
   now detected and marked Completed. game.over is pushed to any
   still-connected clients so they can exit cleanly.

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-18 20:02:10 -04:00
adae8cfc43 Fix: ValueExpr now resolves Target.* and ActionN.Target.* references
Extends ResolveValue to support dynamic references to the resolved target's
properties (SpCost, StCost, Damage, Health, Defense, MP). Also adds Self.SpCost
and Self.StCost.

Usage in ability JSON:
  {"Ref": "Target.SpCost"}        — current action's target's SP cost
  {"Ref": "Action0.Target.SpCost"} — cross-action: action 0's target's SP cost

Enables effects like "return target to hand and refund its channel cost":
  Action 0: Target spirit → ReturnToHand
  Action 1: Target Owner (Player) → ModifySP {"Ref": "Action0.Target.SpCost"}

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-18 14:32:11 -04:00
5d3ee92553 Fix: Repentance/Instinct card target selection + server active ability execution
Client: Repentance/Instinct cards with Active abilities in abilitiesJson now
enter ABILITY_TARGET mode instead of sending play_card immediately. Units on
matching tile affinities (IsOnTileWithAffinity) are highlighted in blue; the
player clicks a target unit and the card is sent with the selected unit target.

Server: FireCardEffects now also processes Active abilities from AbilitiesJson
(after the existing EffectsJson path). Source-side ActivationConditions are
checked; target-side conditions (Subject=Target) are trusted from the client.

New Game.gd helper: send_play_card_with_targets sends play_card with a targets
array so the server can route unit selections to the active ability handler.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-18 14:05:49 -04:00
66452313d5 Fix: conditional passive re-evaluation + INSUFFICIENT_TARGETS crash
Issue 1 — ActivationConditions on passives were never checked:
- ApplyPassivesForSource and ApplyPassivesToNewTarget now evaluate
  ActivationConditions against the source unit before executing each
  passive ability (e.g. IsOnTileWithAffinity: Lake only grants the buff
  when the unit is actually on a Lake tile).

Issue 1 — Passives not re-evaluated on movement / tile changes:
- Added ReEvaluateConditionalPassives(state): for every unit with at
  least one conditional passive, revoke all WhileSourceOnBattlefield
  effects then reapply with conditions re-checked. Units without
  conditional passives are skipped with zero overhead.
- Called after MoveUnit (unit changes tile affinity),
  ActivateAbility (ability may change board state),
  and ChannelCard Terramorpha path (tile affinities change).

Issue 2 — INSUFFICIENT_TARGETS thrown from ApplyPassivesToNewTarget:
- ResolveTargets: when restrictTargets is set (passive-to-new-target
  mode only) and filtering produces zero candidates, return [] silently
  instead of throwing. An ExactSelf source-buff simply has no valid
  target among the new unit — that is expected, not an error.

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-18 11:04:03 -04:00
73c3a71194 Feature: ETag-based CDN model cache invalidation
When admin replaces a model/art file via the CDN browser, the S3 ETag is
now captured and stored on CardAsset.ContentETag. The ETag is included in
the content sync DTO (CardAssetDto) so clients receive it on every sync.

Client-side ModelCache now keys its disk cache on sha256(url + "#" + etag)
instead of sha256(url), so updating a file at the same CDN path busts the
disk cache automatically. A _CACHE_VER="v2" sentinel purges old-scheme
.bin files on first launch after the client update.

Changes:
- CdnUploadResult: add string? ETag field
- S3CdnClient: capture ETag from PutObjectAsync response
- CardAsset: add string? ContentETag property
- Migration 20260318000001_AddAssetContentETag: add content_etag text column
- ContentMessages: add string? ContentETag to CardAssetDto
- ContentDtoMapper: map ContentETag in CardAsset → CardAssetDto
- CdnBrowser.razor: UploadFileToKeyAsync returns Task<string?> (ETag);
  ReplaceAsync calls PropagateAssetETagAsync which updates CardAsset rows
  and touches CardDefinition.UpdatedAt to trigger a version bump
- ModelCache.gd: versioned disk key + cache migration + etag parameter on
  load_model() and evict()
- game_screen.gd: pass model_asset.contentETag to load_model / retry chain

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-18 09:38:17 -04:00
4f0f0e9c0f Feature: ability-level Duration override + WhileSourceOnBattlefield in duration list
AbilityDefinition gains an optional Duration property. When set it is used
as forceDuration for every ExecuteActions call that resolves that ability,
overriding whatever per-action Duration individual effects specify.

- Active abilities: def.Duration is threaded through as forceDuration
- Triggered abilities: same
- Passive abilities: def.Duration ?? WhileSourceOnBattlefield (both
  ApplyPassivesForSource and ApplyPassivesToNewTarget paths)

AbilityBuilder admin panel:
- Duration row added after type-specific fields (dropdown + N input for ForNTurns)
- "WhileSourceOnBattlefield" added to the DurationTypeValues list
- Parse and compile paths updated for the new Duration field

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-17 23:15:05 -04:00
8bcacc29d2 Fix: passive effects not revoked on combat death or sacrifice
The attack resolution and sacrifice paths in GameEngine.cs bypassed
RevokePassivesForSource (and EvaluateAurasOnLeave for combat deaths).
Now all three exit points call both aura/passive cleanup before removing
the unit from the board.

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-17 21:27:37 -04:00