diff --git a/Server/src/SOR.Game/GameEngine.cs b/Server/src/SOR.Game/GameEngine.cs
index 93b25d9..ed721c4 100644
--- a/Server/src/SOR.Game/GameEngine.cs
+++ b/Server/src/SOR.Game/GameEngine.cs
@@ -214,41 +214,49 @@ public static class GameEngine
///
/// End the active player's turn.
- /// - Resets IsExhausted on all active player field cards.
- /// - Restores CurrentDefense to MaxDefense for all active player field cards (§6.9.3).
- /// - Switches the active player.
- /// - Accumulates SP for the next player (+SpAccumulationPerTurn; never resets).
- /// - Sets phase to Draw for the next player's turn.
+ ///
+ /// Per §6.0 (start-of-turn order):
+ /// 1. MP restore (not yet implemented — no positional grid in v1)
+ /// 2. Defense restoration for the NEXT player's units (§6.9.3)
+ /// 3. SP gain for the next player
+ /// 4. Draw phase
+ ///
+ /// Note: IsExhausted resets for the ENDING player's units (they finished acting).
+ /// Defense restores for the STARTING player's units (at the top of their turn).
+ /// These apply to different players — restoring defense for the wrong player
+ /// would let the opponent attack into fully-restored defense every single turn.
///
public static GameState EndTurn(GameState state, string actorId)
{
ValidateActivePlayer(state, actorId);
ValidatePhase(state, GamePhase.Main);
- // Refresh active player's field cards at end of their turn.
+ // End of active player's turn: reset exhausted status only.
+ // Defense does NOT restore here — it restores at start of that player's NEXT turn.
var active = state.Players[actorId];
foreach (var card in active.Field)
- {
card.IsExhausted = false;
- if (card.MaxDefense.HasValue)
- card.CurrentDefense = card.MaxDefense;
- }
if (active.ArchSpirit is not null)
- {
active.ArchSpirit.IsExhausted = false;
- if (active.ArchSpirit.MaxDefense.HasValue)
- active.ArchSpirit.CurrentDefense = active.ArchSpirit.MaxDefense;
- }
// Switch active player.
state.ActivePlayerAccountId = GetOpponentId(state, actorId);
- // Next player's turn: advance counter, accumulate SP.
+ // Start of next player's turn: restore their defense (§6.9.3), accumulate SP.
var next = state.Players[state.ActivePlayerAccountId];
var rules = state.Rules;
state.TurnNumber++;
+ // Defense restores for the player whose turn is starting.
+ foreach (var card in next.Field)
+ {
+ if (card.MaxDefense.HasValue)
+ card.CurrentDefense = card.MaxDefense;
+ }
+ if (next.ArchSpirit is not null && next.ArchSpirit.MaxDefense.HasValue)
+ next.ArchSpirit.CurrentDefense = next.ArchSpirit.MaxDefense;
+
// SP accumulates — never resets between turns.
next.CurrentSp += rules.SpAccumulationPerTurn;
if (rules.SpHasCap && next.CurrentSp > rules.SpCap)
@@ -295,6 +303,7 @@ public static class GameEngine
Phase : state.Phase.ToString(),
ActivePlayerAccountId : state.ActivePlayerAccountId,
TurnNumber : state.TurnNumber,
+ StateVersion : state.NextActionSequence,
Players : players);
}
diff --git a/Server/src/SOR.Game/GameMessages.cs b/Server/src/SOR.Game/GameMessages.cs
index ad2f346..16d467f 100644
--- a/Server/src/SOR.Game/GameMessages.cs
+++ b/Server/src/SOR.Game/GameMessages.cs
@@ -122,12 +122,18 @@ public sealed record CustomLobbyGameStartedPush(
///
/// 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.
///
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 Players);
public sealed record PlayerStateDto(