diff --git a/backend/src/uno-game-engine/events/joinGame.ts b/backend/src/uno-game-engine/events/joinGame.ts new file mode 100644 index 0000000..1697a57 --- /dev/null +++ b/backend/src/uno-game-engine/events/joinGame.ts @@ -0,0 +1,12 @@ +import { assert } from 'console'; +import { GameEngine } from '../engine'; +import { registerEventHandler } from '../gameEvents'; + +export function joinGame(game: GameEngine, event: GameEvent): EventResult { + assert(event.type === 'JOIN_GAME', 'Invalid event type'); + const player: Player = { id: event.playerId, cards: [] }; + game.addPlayer(player); + return { type: 'SUCCESS', message: 'player joined successfully' }; +} + +registerEventHandler('JOIN_GAME', joinGame);