DB / Server:
- Added ResultJson (jsonb, nullable) to GameActionLog entity + EF migration
- Updated SaveStateAsync to accept resultJson (optional, default null)
- All 11 action handlers now serialize GameEngine.ToDto() result into the log
Admin — GameSessionsPage:
- Session IDs are now clickable links → /game/sessions/{id}
- "Abandon All Active" bulk button (previous)
- "Purge All" button (SuperAdmin only, JS confirm) — hard-deletes all sessions
and action logs via cascade
Admin — GameSessionDetailPage (/game/sessions/{id}):
- Session header: status badge, P1/P2 display names (click to copy GUID)
- Info cards: Player 1, Player 2, Created timestamp, Duration/WinCondition
- Action log table: seq#, time, actor name (click to copy GUID), action type
- Expandable Payload (JSON) and Result (JSON) per row
- Actor display names resolved from SorIdentityDbContext
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>
`ExactSelf` was accepted by the admin builder dropdown but crashed on
deserialization because the TargetOwnership enum was missing the value.
- Added `ExactSelf` to `TargetOwnership` enum in Action.cs
- BuildCandidates treats ExactSelf like Self/Owner (actor's player pool)
- ResolveTargets post-filters to ctx.Source.InstanceId when ExactSelf
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>
Client (game_screen.gd):
- Fix crash when clicking a unit with null abilitiesJson: server sends the key
with a null value, so dict.get(key,default) returns null — guard both uses
(_show_ability_panel and _on_hold_timer_fired) with explicit null check.
- Add double-click on battlefield units to open a full CardDetailPopup showing
name, affinity, stats, and ability descriptions. Popup is instantiated once
in _ready() and reused; aliases movementPoints/abilities keys as expected.
Server (Filters.cs / AbilitySystem.cs):
- IsSelf filter now matches by CardDefinitionId (definition-level: any copy of
the same card). This is the appropriate semantic for "self" as a type scope.
- IsExactSelf filter added: matches by InstanceId (instance-level: only this
specific unit on the battlefield). Use this to prevent duplicate-instance
trigger bleed where two copies of a card both fire when only one acted.
- TriggerMatches now accepts the evaluating FieldCard and forwards its
InstanceId to Own() for all ownership checks.
- Own() gains "ExactSelf" scope: fires only when occ.Data.SourceId matches the
evaluating unit's InstanceId — eliminating the definition-level bleed bug.
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>
- Input bug: CardWidget only consumed mouse PRESS via accept_event(), not RELEASE.
This caused _unhandled_input to fire _handle_board_click on release of a card
click, hitting the tile physically behind the hand area in 3D — accidentally
sending play_card to the wrong tile (Spirit/Ruin) or picking the first tile for
Terramorpha. Fixed by tracking _press_was_on_board: board clicks only fire when
the originating PRESS also reached _unhandled_input (i.e., was not consumed by
a UI card widget).
- Server: added SpCost, StCost, Genus, MinChannelRange, MaxChannelRange,
MinAttackRange, MaxAttackRange, CanMove, CanAttack, ExtraAttacksRemaining,
CanBeAttacked, AbilitiesJson to CardInstanceDto and ToCardDto mapping.
All fields were already on CardInstance; they were simply not exposed to clients.
- Client: build def dict in _make_hand_card with maxMp → movementPoints alias
so CardWidget displays movement points correctly.
- Client: show MetaRow (genus + type) in compact hand card; only StatsGrid is
hidden. HandArea / RightPanel height raised 190 → 220px for better visibility.
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>
SaveStateAsync was serializing GameState BEFORE incrementing NextActionSequence,
so the written StateJson always had the pre-increment value. Every subsequent
request read the same NextActionSequence and computed the same SequenceNumber,
causing duplicate key violations on IX_action_logs_GameSessionId_SequenceNumber
even in purely sequential scenarios (e.g. P2 places then P1 places).
Fix: increment NextActionSequence first, then serialize, so the persisted JSON
always reflects the sequence number that was just consumed.
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>
- LoadActiveSessionAsync: begin explicit transaction + lock session row
with SELECT FOR UPDATE so concurrent handlers for the same session
queue up instead of racing
- SaveStateAsync: commit (and release) the transaction after EF SaveChanges
fixes duplicate key on IX_action_logs_GameSessionId_SequenceNumber
when both players act simultaneously (e.g. both placing ArchSpirits)
- GameRules: default board size 9x9 (was 8x8)
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>
Client had no way to know if it was P1 or P2, so _valid_placement_tiles
always chose row bh-1. Now the DTO exposes playerOneAccountId so the
client can correctly pick row 0 (P1) or row bh-1 (P2).
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>
- PushUnitEffect and PullUnitEffect gain BlockedDamage (int): deals direct HP
damage to the displaced unit if it cannot complete the full tile distance
(blocked by a boundary or another unit)
- AbilityRange gains RequiresLos (bool): engine validates line of sight before
allowing ability activation
- AbilityRange gains LinearOnly (bool): restricts targeting to cardinal/diagonal
straight lines only (suitable for Push/Pull/beam abilities)
- AbilityBuilder UI exposes RequiresLos and LinearOnly as inline checkboxes in
the Active ability range row
- PushUnit/PullUnit effect templates auto-populate with BlockedDamage: 0
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>
• Light/dark mode toggle: Bootstrap 5.3 data-bs-theme, theme persisted to
localStorage via admin.js, Moon/Sun icon button in sidebar, flash-free
inline <script> in App.razor applies saved theme before first render.
• Account management: Add "Create Account" button + new /accounts/new page
(email, display name, password, role checkboxes). AccountDetail now has
interactive role assignment (Add/Remove Admin/SuperAdmin — SuperAdmin
actions gated with <AuthorizeView Roles="SuperAdmin">) and a force-reset
password section (RemovePasswordAsync + AddPasswordAsync, no current
password required).
• Chat fixes: stat card labels changed from text-muted → text-white-50 for
readability on bg-dark; card-headers now have border-bottom border-secondary
to visually separate from card bodies; "View" button relabeled "View & Post"
to surface the hidden compose feature.
• Ability builder (AbilityBuilder.razor): structured UI replacing the raw
textarea in CardEditor. Supports all 4 ability types (Active/Passive/Aura/
Triggered) with type-specific fields (range, uses/turn, aura range, trigger
dropdown). Each ability holds structured actions (scope/type/ownership/count
dropdowns) and effects (59 types in 11 grouped optgroups; each auto-populates
a JSON fields template on type selection). Description field stores plain-
English text in the JSON. Raw JSON toggle + Apply for power users. Live
compiled JSON preview.
• AbilitySystem: added JsonStringEnumConverter so JSONB enums serialize as
human-readable strings ("Active" vs 0, "Battlefield" vs 3, etc.).
• AbilityDefinition: added optional Description property (admin-only metadata).
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
- Add EnterAuraRange and LeaveAuraRange to TriggerEventKind enum
- Add TriggerMatches cases for OnEnterAuraRangeTrigger / OnLeaveAuraRangeTrigger
with AuraOwnership + UnitOwnerMatches (ally/enemy/any) scope filtering
- Add EvaluateAuraTransitions (on move), EvaluateAurasOnEnter (on channel),
EvaluateAurasOnLeave (on sacrifice/kill) public methods to AbilitySystem
- Bidirectional evaluation: moving unit vs. stationary auras + moving unit's
own auras vs. stationary units
- Hook into GameEngine: MoveUnit, ChannelCard (Spirit), Sacrifice
- KillUnit now calls EvaluateAurasOnLeave before board removal
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>
- ExecuteEffect now builds and stores reversal effects in GameState.ActiveEffects
for all non-Instant durations (stat deltas, flag toggles, genus, affinity)
- DOT/HOT effects register tick entries instead of reversals
- TrackedDuration wrapper records owner + IsTick flag alongside DurationModel
- ExpireActiveEffects handles UntilEndOfTurn, UntilStartOfOwnerTurn, ForNTurns,
WhileCondition; applies reversal on expiry for non-tick entries
- TickActiveEffects fires DOT/HOT damage/healing each turn end
- GameEngine.EndTurn: tick → expire(end) after TurnEnd trigger;
expire(start) after player switch, before TurnStart trigger
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>
Defense restore bug fix:
- EndTurn previously restored defense for the ENDING player's units (wrong)
- Per §6.0 start-of-turn order: defense restores for the player whose turn is STARTING
- IsExhausted still resets for the ending player (they finished acting)
- This prevents opponents attacking into fully-restored defense every turn
StateVersion on GameStateDto:
- NextActionSequence from GameState exposed as StateVersion in every state push
- Clients track lastSeen StateVersion; if push arrives with version > lastSeen+1,
client calls game.get_state for a full board refresh
- game.get_state already returns full state — no additional server work needed
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>
Engine corrections (per gameplay.md + user spec):
- Opening draw: both players draw 6 cards at game start
- P1 skips Draw phase on turn 1 (already has opening hand);
P2 draws once at start of their first turn → 7 cards total
- SP: starts at 0, accumulates +3/turn (never resets, no cap by default)
- ST: starts at 0, earned only through sacrifice (no per-turn grant)
- No entry sickness: units can attack/move/ability the turn they are summoned
- Defense restores to MaxDefense at start of each turn (§6.9.3)
- Rename Graveyard → Discard throughout (GameState, GameEngine, GameMessages)
- Remove IsEntrySick flag from CardInstance and CardInstanceDto
GameRuleSet / CustomLobby infrastructure:
- GameRuleSet DB entity: admin-configurable rules (IsRankedDefault, IsCustomDefault)
- GameRules record (SOR.Game): in-memory config embedded in GameState.Rules
- GameSession.RuleSnapshotJson: immutable per-session rule snapshot (jsonb)
- MatchmakerService: loads ranked ruleset and snapshots it into each GameSession
- GameReadyHandler: deserializes rule snapshot and passes rules to GameEngine.Initialize
- CustomLobby DB entity: host+guest, rule overrides, GameSessionId link
- CustomLobbyStatus enum: Open / Full / Started / Cancelled
Custom game handlers (4):
- game.custom.create — host creates lobby with optional rule overrides
- game.custom.join — guest joins; when full, creates GameSession + pushes both players
- game.custom.leave — host cancels or guest leaves
- game.custom.list — paged list of Open lobbies
Admin portal:
- /game/ranked-rules — edit the ranked play ruleset (auto-seeds default on first visit)
- /game/custom-lobbies — read-only view of active and recent custom lobbies
- NavMenu: added Ranked Rules + Custom Lobbies links under Game
Migration: AddGameRulesAndCustomLobby (game_rule_sets, custom_lobbies,
rule_snapshot column on game_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>