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>
This commit is contained in:
dingo
2026-03-21 06:00:48 -04:00
co-authored by Claude Happy
parent a84a610964
commit 674f1f6b8c
@@ -44,10 +44,14 @@ internal sealed class GameSpectateHandler : GameHandlerBase, IMessageHandler
.SingleOrDefaultAsync(ct)
?? throw new GameException("SESSION_NOT_FOUND");
var state = GameEngine.Deserialize(session.StateJson!);
if (state.Phase == GamePhase.Placement)
throw new GameException("PLACEMENT_IN_PROGRESS");
_registry.Register(req.SessionId, accountId);
var state = GameEngine.Deserialize(session.StateJson!);
var dto = GameEngine.ToDtoSpectator(state);
var dto = GameEngine.ToDtoSpectator(state);
return ServerMessage.Reply("game.spectate.ack", message.Seq,
new SpectateResponse(dto));