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:
@@ -44,10 +44,14 @@ internal sealed class GameSpectateHandler : GameHandlerBase, IMessageHandler
|
|||||||
.SingleOrDefaultAsync(ct)
|
.SingleOrDefaultAsync(ct)
|
||||||
?? throw new GameException("SESSION_NOT_FOUND");
|
?? 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);
|
_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,
|
return ServerMessage.Reply("game.spectate.ack", message.Seq,
|
||||||
new SpectateResponse(dto));
|
new SpectateResponse(dto));
|
||||||
|
|||||||
Reference in New Issue
Block a user