feat: vytržení miniher do samostatného projektu
CI / Server unit tests (push) Successful in 26s
CI / Generate TypeScript types (push) Successful in 10s
CI / Build server (push) Successful in 28s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 2m24s
CI / Build and push Docker image (push) Successful in 44s
CI / Notify (push) Successful in 2s

This commit is contained in:
mates committed 2026-10-22 12:42:49 +02:00
1 parent 8a7bbef729
commit 35cf2ca9d7
42 files changed
+136 -8224

No files matched your search

+2 -18
View File
@@ -1,7 +1,7 @@
import { Server, Socket } from "socket.io";
import { Socket } from "socket.io";
import { getLogin } from "./auth";
/** Sdílené pomůcky pro websocketové minihry (reakční hra, had). */
/** Pomůcky pro websocketové minihry (kreslení). Ostatní minihry jsou v samostatné aplikaci Lobby. */
/** Chyba určená hráči — posílá se zpět klientovi, nic se neloguje. */
export class GameError extends Error { }
@@ -60,19 +60,3 @@ export function gameHandler(socket: Socket, errorEvent: string, action: (login:
/** Minimální počet hráčů — lokálně lze hrát i sám. */
export const minPlayersForEnv = (prod: number) => process.env.NODE_ENV === 'development' ? 1 : prod;
/**
* Jednoduchý chat v lobby miniher — zprávy se nikde neukládají, server je jen
* přepošle všem (klient si je filtruje podle hry).
*/
export function registerLobbyChat(io: Server) {
io.on('connection', socket => {
socket.on('lobbychat:send', gameHandler(socket, 'lobbychat:error', (login, payload) => {
const { game, text } = (payload ?? {}) as { game?: unknown, text?: unknown };
if (typeof game !== 'string' || typeof text !== 'string') return;
const trimmed = text.trim().slice(0, 200);
if (!trimmed) return;
io.emit('lobbychat:message', { game: game.slice(0, 20), login, text: trimmed });
}));
});
}