Refactor index.html to use separate files for scripts and style

This commit is contained in:
sepia 2025-07-18 18:34:50 -05:00
parent 6baa194e5b
commit cd21e4e8bd
6 changed files with 129 additions and 158 deletions

View file

@ -22,20 +22,15 @@ const app = new Elysia()
}),
open(ws) {
const { gameId, playerId } = ws.data.query;
if (!gameId || !playerId) {
console.error(
'WebSocket connection missing gameId or playerId in query params.',
);
ws.send(
JSON.stringify({
type: 'error',
error: 'Missing gameId or playerId.',
}),
);
ws.send('Error: missing gameId or playerId.');
ws.close();
return;
}
wsHandler.handleConnection(ws, gameId, playerId);
const game = wsHandler.getGame(gameId);
@ -47,7 +42,7 @@ const app = new Elysia()
} else if (game.getPlayerCount() === 1 && game.status === 'waiting') {
message = `You are ${playerId}. Waiting for another player to join.`;
}
wsHandler.sendMessage(game.id, 'message', message, ws);
wsHandler.sendMessage(game.id, message, ws);
} else {
ws.send(
JSON.stringify({