Fix defense restore order + add StateVersion for client sync

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>
This commit is contained in:
dingo
2026-02-26 08:17:29 -05:00
co-authored by Claude Happy
parent 682a525193
commit 7ab11e6f46
2 changed files with 30 additions and 15 deletions
+6
View File
@@ -122,12 +122,18 @@ public sealed record CustomLobbyGameStartedPush(
/// <summary>
/// Client-facing game state — opponent's private zones (hand, deck) are filtered.
///
/// StateVersion is a monotonically-increasing counter incremented after every game action.
/// Clients should track the last received StateVersion. If a GameStateUpdatePush arrives
/// with StateVersion > lastSeen + 1, the client missed a push and should call game.get_state
/// to request a full board refresh.
/// </summary>
public sealed record GameStateDto(
Guid SessionId,
string Phase, // Draw | Main | End | GameOver
string ActivePlayerAccountId,
int TurnNumber,
int StateVersion, // monotonic; use for client mismatch detection
IEnumerable<PlayerStateDto> Players);
public sealed record PlayerStateDto(