fix(chess): admin users and move registration
Some checks failed
Deploy to Production / test (push) Failing after 29s
Some checks failed
Deploy to Production / test (push) Failing after 29s
- Add role field to JOIN_ROOM message schema - Allow admin users to join rooms and be added as players - Update panel to pass user role when joining game rooms - Fix chess move coordinates in tests (algebraic notation) - Ensure admin users can make moves for both sides
This commit is contained in:
@@ -45,10 +45,12 @@ export class RoomManager {
|
||||
if (room.status !== "waiting") return { ok: false, error: "Game already started" };
|
||||
|
||||
const plugin = gameRegistry.get(room.gameSlug)!;
|
||||
if (room.players.length >= plugin.maxPlayers) return { ok: false, error: "Room is full" };
|
||||
if (room.players.length >= plugin.maxPlayers && role !== "admin") return { ok: false, error: "Room is full" };
|
||||
if (room.players.includes(playerId) && role !== "admin") return { ok: true, started: room.status === "playing" };
|
||||
|
||||
room.players.push(playerId);
|
||||
if (!room.players.includes(playerId) || role === "admin") {
|
||||
room.players.push(playerId);
|
||||
}
|
||||
|
||||
if (room.players.length >= plugin.maxPlayers) {
|
||||
room.state = plugin.createInitialState(room.players);
|
||||
|
||||
Reference in New Issue
Block a user