Commit Graph
146 Commits
Author SHA1 Message Date
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
0f416127b1 Fix: Genus not propagated to CardInstance/FieldCard — breaks passive conditions
DefinitionToInstance and ToFieldCard both omitted copying Genus, so
HasGenusCondition and GenusContainsFilter always evaluated against null
(returning false). All three data-flow gaps are now fixed:
- DefinitionToInstance: def.Genus?.ToList() → CardInstance.Genus
- ToFieldCard:          source.Genus?.ToList() → FieldCard.Genus
- FilterMatches:        GenusContainsFilter now handled (was falling to _ => true)

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-17 17:29:42 -04:00
f60457b716 Fix: implement Passive ability execution with per-target conditions
Passive abilities (e.g. 'All Merfolk +1 attack') were never executed
because AbilityType.Passive had no runtime processing.

Three root causes fixed:

1. Passive abilities are now applied when units enter the battlefield
   and reversed when they leave (new DurationType.WhileSourceOnBattlefield).
   - ApplyPassivesForSource: runs a unit's passives against all current targets
   - ApplyPassivesToNewTarget: applies existing passives to a newly-entered unit
   - RevokePassivesForSource: reverses all passive effects on source death/leave
   - Hooked into GameEngine.Channel, Transition and AbilitySystem
     ReturnToBattlefield, SummonToken, KillUnit, SendToDiscard

2. Action conditions with Subject="Target" now filter per-target instead of
   aborting the entire action (which evaluated against ctx.Source).
   Source-level conditions still gate the whole action; target-level ones
   are evaluated individually and skip non-matching targets.

3. ExecuteActions/ResolveTargets gain a restrictTargets parameter used by
   ApplyPassivesToNewTarget to avoid double-applying existing passive buffs
   to units that already received them when the passive source entered.

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 15:54:00 -04:00
aeeae9dec7 Feature: structured trigger dropdowns in AbilityBuilder
Replace raw JSON textarea for trigger event with per-type dropdown
and input fields. Each of the 39 trigger types now renders only its
relevant fields (Player, Ownership, SourceOwnership, TargetOwnership,
UnitType, CardType, DamageType, Amount, Stat, Cause, CausedBy,
RuinOwnership, OccupantOwnership, UnitOwnership, AuraOwnership).

- AbilityDraft gains 15 structured trigger fields replacing TriggerJson
- RenderTriggerFields: per-type RenderFragment (mirrors RenderConditionFields)
- CompileTrigger: builds TriggerEvent JsonObject from draft fields
- ParseJson: reads all trigger fields from existing TriggerEvent JSON
- SelectTrigger: resets all fields to sensible defaults on type change
- New helpers: BuildStringInput, BuildOptionalAmountInput, BuildOptionalStringSelect

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 15:36:19 -04:00
c105120dc6 Feature: card unit SFX + genus multi-select + CardEditor UX fixes
- CardDefinition: add MoveSoundUrl, DamagedSoundUrl, BlockedSoundUrl,
  AttackSoundUrl, DeathSoundUrl columns (nullable text)
- Migration 20260317100000_AddCardUnitSounds: 5 new columns on card_definitions
- CardDefinitionDto + ContentDtoMapper: expose 5 SFX fields to client
- CardEditor:
  - Genus: replace plain text input with DB-backed checkbox multi-select
    (loads distinct tags from all cards; add new tags inline)
  - Channel range (Min/Max): now ArchSpirit-only (removed from Spirit)
  - CanUseAbility / RequiresLos: default true for display & new cards
  - Assets tab: Unit Sound Effects section (5 CDN URL inputs)
  - model-viewer script injected lazily so 3D preview renders

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 09:36:18 -04:00
3ba33275e3 Feature: model retry + rejoin on login + 5-min inactivity detection
**Feature 1 — Model retry (client)**
- `ModelCache.gd`: add `evict(url)` to remove failed entries so re-download is possible
- `game_screen.gd`: when GLB load fails, `_schedule_model_retry` queues a 60-second
  retry (up to 10 attempts); `_do_model_retry` evicts + re-downloads and swaps the
  placeholder mesh for the real model if/when it succeeds

**Feature 2 — Rejoin on login (server + client)**
- Server: `GameGetActiveSessionHandler` (`game.get_active_session`) — returns the
  caller's active session ID + phase, or null when no session exists
- Client: `init_screen.gd` checks for an active session after content sync; shows
  a "Rejoin / Concede" dialog when one is found; rejoin navigates to GameScreen with
  the session ID already set so `send_ready` → `AlreadyStarted` → `_fetch_state`

**Feature 3 — 5-minute inactivity detection (server + client)**
- `GameSession`: add `LastActionAt` column + EF migration
  (`20260317000001_AddLastActionAt`)
- `GameHandlerBase.SaveStateAsync`: sets `session.LastActionAt` on every action
- `GameInactivityMonitorService`: background poll every 60 s; when a session hasn't
  had an action in ≥ 5 min, pushes `game.inactive_warning` to the stalled player and
  `game.opponent_inactive` to their opponent (once per session per server lifetime)
- `GameForceConcedeHandler` (`game.force_concede`): lets the waiting player claim
  the win; validates caller is not the active player and `LastActionAt` is stale
- `Game.gd`: new `opponent_inactive` / `inactive_warning` signals + push handlers +
  `send_force_concede()` helper
- `game_screen.gd`: handles `opponent_inactive` with Accept/Wait dialog;
  handles `inactive_warning` with informational 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-03-17 09:05:05 -04:00
c0e9ffbd18 Feature: native colour picker for model tint in card editor
Replace the plain hex text input + static swatch with a native
<input type="color"> (Bootstrap form-control-color) + text field
combo. Clicking the swatch opens the browser's colour picker and
updates the hex field in real-time. An × button clears the value
back to null (no tint). The text field still accepts manual hex
entry and the picker reflects the change on the next interaction.

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 08:36:31 -04:00
810935a680 Feature: card editor Assets tab — CDN picker + inline previews + model config
- Move Scale and Tint Colour from Basic tab into Assets tab under a
  new "3D Model Config" section (defaults: Scale=null→1.0, Tint=null)
- Model3D assets: folder icon opens a CDN picker modal that lists all
  *.glb / *.gltf from the models/ bucket (cached after first load),
  filterable by filename, with a list-group UI
- Art2D assets: same picker pattern but pulls from cardart/ bucket and
  shows image thumbnails in a responsive grid
- Model3D inline 3D preview via <model-viewer> appears below the URL
  when set; "Load animations" button invokes the same JS interop as
  CdnBrowser and populates an animation dropdown
- Art2D inline image preview appears below the URL when set
- Changing or uploading a URL clears cached animation state so the
  Load button reappears for the new file
- JS guard (window.sorCdn = window.sorCdn || {}) prevents double-
  definition when CdnBrowser is also loaded in the same 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-17 08:26:57 -04:00
26d2b88623 Feature: tile spacing gap + 2D placeholder textures
Visual changes (client):
- 0.1 gap between all tiles (TILE_SPACING = 1.1)
- Placeholder tiles (no 3D model) are now 0.5 height instead of random
  0.8-1.0, making undecorated tiles visually distinct
- Placeholder tiles load a 2D CDN texture via HTTP and apply it as the
  albedo on the BoxMesh (same affinity-per-shape lookup as 3D models)
- Placeholder tiles also attach a stalagmite bottom model, matching the
  look of fully-decorated tiles

Server:
- TileModelBinding.TexturePublicUrl (nullable text) added to entity,
  migration 20260317000001_AddTileTexture applied to DB
- TileModelDto extended with TexturePublicUrl
- ContentGetTileModelsHandler includes TexturePublicUrl in response

Admin (/content/tile-models):
- New "Square Texture" and "Hex Texture" columns in the bindings table
- Texture picker modal browses the CDN textures/ prefix and shows image
  thumbnails; select + assign writes TexturePublicUrl to the binding
- Texture can be assigned without a 3D model (creates a binding row
  with empty model fields)

ContentCache:
- Caches texturePublicUrl alongside modelPublicUrl from tile_models response
- New get_tile_texture_url(affinity, shape) → String accessor

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-16 17:47:28 -04:00
e1c8ccb6f5 Add migration Designer file for AddTileBottomModels
Required by EF Core to discover the migration via the [Migration] attribute.
Without it the previous database update reported "already up to date".

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-16 15:16:26 -04:00
51f3ee23d4 Feature: tile height variation + stalagmite bottoms + live content refresh
## Tile height variation (fix)
Tile tops now visibly vary (0.8–1.0) from a fixed bottom at world Y=0.
Previously the top was fixed and the variation was only visible underneath.
Heights are seeded by tile coordinate so they're deterministic per board.
Unit y_offsets and highlight positions update to match per-tile height.

## Stalagmite tile bottoms
Server: new TileBottomModel entity + migration (catalog.tile_bottom_models),
content.tile_bottoms handler returns all active CDN URLs.
Admin: "Tile Bottom Models" section in the Tile Model Manager page —
  add/toggle active/delete entries with CDN picker.
Client: ContentCache fetches + disk-caches the URL pool; _try_load_tile_model
  picks a random URL and attaches it flipped below the tile model as a
  stalagmite using the existing _fit_model_to_tile scale logic.

## Live content refresh
ContentCache schedules start_sync() every 5 minutes after sync_complete so
card definitions, tile models, and bottom models are refreshed in the
background without restarting the 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-03-16 15:05:48 -04:00
8d85f76180 Fix: unique CDN URLs per upload to bust browser + disk model cache
Uploading a replacement GLB with changed animation names to the same
folder/fileName path silently overwrote the S3 object but left the URL
unchanged.  ModelCache keyed its disk cache and in-memory cache by URL,
so all clients continued loading the stale model indefinitely.

Fix (CardEditor.razor):
- Asset uploads: append _yyyyMMddHHmmss timestamp to the filename stem
  before calling UploadAsync, e.g. merlock_20260316_143022.glb.
- Animation uploads: same treatment.
- Result: every upload produces a unique URL; the card asset record is
  updated to that URL; ModelCache sees a new key and fetches fresh bytes.

Fix (HttpCdnClient.cs):
- Set Cache-Control: public, max-age=31536000, immutable on uploaded
  objects.  Since keys are now unique-per-upload, aggressive caching is
  safe and avoids unnecessary re-downloads of unchanged assets.

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-16 12:05:28 -04:00
085249b5c4 Fix: model facing default (south/+Z) + clear game state on rematch
Model facing: GLB models exported from Blender arrive in Godot facing +Z,
not -Z. Changed _facing_to_base_angle default case from 0 (north/-Z) to
PI (south/+Z). Explicit "north" case added. Updated admin dropdown label
from "Default (north)" to "Default (south / Blender GLB)" to match.

Stale game state: when matchmaking.match_found is received, clear Game.state
so the new GameScreen always calls send_ready() rather than rendering the
previous (ended) game's state. Fixes same-players-re-match ending up in
the already-completed 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-16 08:18:28 -04:00
42a2834e03 Feature: model config UI + move scale/tint to CardDefinition
Reorganised model3D config into two logical levels:

Card-level (CardDefinition — "this card's visual identity"):
  ModelScale      float?   — uniform scale multiplier
  ModelTintColor  string?  — multiplicative hex tint e.g. "#FF8800"

Asset-level (CardAsset — "properties of this mesh file"):
  ModelFacingDirection  string?  — GLB export facing ("north" default)
  ModelTintMaskUrl      string?  — CDN URL for per-texel tint mask

Admin UI (CardEditor.razor):
  Basic tab: new "3D Model" row with Scale (number) + Tint Colour
  (text + live swatch preview).
  Assets tab: Model3D asset cards now show Facing Direction dropdown
  and Tint Mask URL input.

Server:
  ContentMessages: ModelScale/ModelTintColor moved to CardDefinitionDto;
  CardAssetDto retains only ModelFacingDirection + ModelTintMaskUrl.
  ContentDtoMapper updated accordingly.

Client (game_screen.gd):
  modelScale + modelTintColor now read from the definition dict;
  modelFacingDirection stays on the asset dict.

DB: migration MoveModelScaleTintToCard applied to pg-forge-01/SOR.

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-16 07:25:20 -04:00
8e8b61cbb7 Feature: model config (facing/scale/tint) + animation loop fix
SERVER
- CardAsset gains ModelFacingDirection (string?), ModelScale (float?),
  ModelTintColor (string?), ModelTintMaskUrl (string?) columns.
- CardAssetDto and ContentDtoMapper updated to expose them.
- EF migration AddModelConfig applied to pg-forge-01 / SOR DB.

CLIENT (game_screen.gd)
Animation loop:
- GLB standard: first 5 frames (ANIM_TRANSITION_SECS = 5/30s) are
  entry frames that blend from idle into the action.  Looping
  animations now skip those frames on every iteration after the
  first, eliminating the bind-pose flash at the loop seam.
- Manual loop management via animation_finished + CONNECT_ONE_SHOT
  replaces LOOP_LINEAR so the seek-past-transition trick works.
- _idle_callbacks tracks active loop callables so they can be
  disconnected when a one-shot animation interrupts idle.
- _idle_entry_done reset when a one-shot starts so the transition
  frames play correctly when returning to idle after the action.

Model config:
- _find_model3d_asset() replaces _find_model3d_url() — returns the
  full asset dict including the new fields.
- ModelFacingDirection → _facing_to_base_angle() → rotation.y applied
  at load; stored in _model_base_angles for movement / idle reset.
- ModelScale applied uniformly to model_node.scale on load.
- ModelTintColor applied as multiplicative albedo_color tint to all
  StandardMaterial3D surfaces (materials duplicated per-instance).
- ModelTintMaskUrl stored in DB/DTO; per-texel shader not yet wired.

Movement facing:
- _animate_unit_move pre-computes a facing angle per BFS step and
  snaps model_node.rotation.y at the start of each step so units
  face the direction they walk.
- On movement end, rotation resets to the idle/team direction.

Cleanup:
- _rebuild_units removal loop erases _idle_entry_done, _idle_callbacks,
  _model_base_angles, _needs_face_rot for freed units.

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-15 22:01:58 -04:00
5f87093a75 Fix: _schedule_rebuild race condition kills movement animation
Rapid echo state-updates (phase-change, turn-tick) arriving with
delay=0 used to cancel the pending movement tween, making unit travel
instant.  Now a delay=0 call only updates _pending_rebuild so the
latest state is applied when the existing tween fires; the tween is
only cancelled when a new positive delay arrives.

Also: password min-length 12→8 (auth), anchor preset cleanup (tscn).

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-15 20:55:40 -04:00
a86675b0c9 Fix: CORS header before upstream await + movement debug prints
CORS: Access-Control-Allow-Origin must be set before the CDN GetAsync
call so it is present even if the upstream throws (ASP.NET Core exception
handling resets responses, dropping headers set after an exception).
Added try/catch to return 502 cleanly on upstream failures.

Debug: [Move] prints in _play_move_animations and _schedule_rebuild to
diagnose why movement animation appears instant.

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-15 20:42:09 -04:00
c4999c953a Feature: GLB animation playback, model facing, CDN animation preview
Server:
- CardAnimationBinding.AnimationTrackName: nullable override for GLB track name
  (blank = case-insensitive convention match; Idle/Attack/Damaged/Moving/Dying)
- CardAnimationBindingDto: includes AnimationTrackName in content sync
- CardEditor: GLB Track Name column in animation bindings table
- CdnBrowser: model-viewer animation list + playback (JS interop on load event)
- Migration: AddAnimationTrackName applied to production

Client:
- ContentCache.get_anim_track(): resolves GLB track name from binding override
  or falls back to convention with case-insensitive aliases
- game_screen.gd:
  - _find_animation_player(): recursive search in loaded GLB scene tree
  - _resolve_anim_track(): case-insensitive + alias resolution
  - _play_unit_anim(): plays track, returns to Idle when one-shot finishes
  - _play_damage_animations(): detects HP drops and unit deaths before rebuild
  - Model facing: P1 units rotated 180deg Y to face opponent across board
  - Idle loop starts automatically after real model loads
  - Attack animation fires immediately on attack input (before ACK)

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-15 14:06:55 -04:00
dfafe89e79 Fix: regenerate EF migrations with proper Designer.cs files
Replaced linter-generated stubs (missing [Migration] attribute and
Designer.cs snapshots) with correctly generated migrations.
Applied to production (pg-forge-01).

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-14 08:26:46 -04:00
3810742fe6 Feature: leaderboard hide, ability animations, card sounds, BGM, in-game settings
Server:
- Account.IsHiddenFromLeaderboard: filter bots/devs from leaderboard
- AbilityAnimationDefinition: type, effect, dimensions, asset/sound URLs per ability
- CardAnimationBinding: CastSoundCdnUrl + ImpactSoundCdnUrl per card action
- GameAudioConfig entity: admin-configurable BGM tracks per context
- GetGameAudioConfigHandler (content.get_audio_config) + ServiceRegistration
- Admin pages: AccountDetail toggle, AudioConfig CRUD, CardEditor + AbilityBuilder UI
- Migrations: AddLeaderboardHide, AddCardActionSounds, AddGameAudioConfig

Client:
- Music.gd autoload: fetches BGM config, crossfades between context tracks
- InGameSettings overlay: audio sliders, camera follow toggle, concede with confirm
- GameScreen: gear button opens settings; ConcedeBtn moved into settings panel
- project.godot: Music autoload registered

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-13 23:31:10 -04:00
dingo 92f61dcd76 Ability Range fix 2026-03-13 17:36:57 -04:00
dingo 60268fd310 Ability changes 2026-03-13 09:47:06 -04:00
dingo c62b5c9355 bazaar bug 2026-03-10 22:09:52 -04:00
dingo 967af85545 Bazaar 2026-03-10 21:38:06 -04:00
8e3f64d9d1 Fix: ability WithinRange/IsAdjacentToSource filters + ModelCache web CORS
- AbilitySystem: implement WithinRangeFilter (Manhattan distance min/max) and
  IsAdjacentToSourceFilter in FilterMatches — both were falling through to
  _ => true, so range constraints on targeting were silently ignored
- Program.cs: add GET /cdn/{**path} proxy endpoint with
  Access-Control-Allow-Origin: * so browser web clients can fetch GLB models
  (Ceph RadosGW / cdn.aeternalisgames.com has no CORS headers)
- ModelCache.gd: on web export, rewrite cdn.aeternalisgames.com URLs to go
  through hub.aeternalisgames.com/cdn proxy; disk/memory cache still keyed
  on the original CDN URL for consistency across platforms

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-10 10:39:13 -04:00
da6899b2c7 Fix: include ArchSpirit in Battlefield ability target candidates
BuildCandidates only added p.Field to the candidate pool for
Scope=Battlefield, leaving p.ArchSpirit (stored as a separate
PlayerState property) out. A Unit-typed ability targeting the
opponent's ArchSpirit would match zero candidates → INSUFFICIENT_TARGETS.

Also include p.ArchSpirit in the AnyZone pool for consistency.

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-09 22:58:28 -04:00
696452f4c9 Fix: replace [JsonDerivedType] with [PolyType] to avoid STJ PolymorphicTypeResolver conflict
[JsonDerivedType] alone (without [JsonPolymorphic]) is sufficient in .NET 8 to
activate the built-in PolymorphicTypeResolver, which then throws
NotSupportedException because our custom converter does not support metadata
reads/writes.

Introduce PolyTypeAttribute — a plain internal attribute unknown to the
framework — and replace all [JsonDerivedType] usages on Effect, Condition,
TriggerEvent, and Filter with [PolyType]. PolymorphicAbilityConverter<T> reads
[PolyType] via reflection to build its type map; the framework ignores it entirely.

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-09 20:53:02 -04:00