mirror of
https://github.com/tiennm99/caro.git
synced 2026-05-13 22:57:51 +00:00
42d94a2aed
Watch feature was half-implemented since day one and stayed broken through the typed-protobuf migration: 1. Server (WatchGameHandler): only pushed the WatchGameSuccessResponse ack. A mid-game watcher joined a blank scene because the server never told them who the players were or what moves had been played. 2. Client: had a Watch button that sent the request but no event bus handler for GAME_WATCH_SUCCESSFUL, so nothing happened visually. Server fix: - On successful watch, if room.status == STARTING, bootstrap the watcher with a synthesised GameStartingResponse (player ids, nicknames, board size) and replay every move in room.getMoveHistory() as individual GameMoveSuccessResponse messages on that channel. - Black/white player lookup uses room.getBlackPlayerId/getWhitePlayerId against the clientSideMap so we don't reassign roles. - Move replay resolves playerNickname from the same map. Client fix: - menu-ui.js: new GAME_WATCH_SUCCESSFUL handler flips gameState.isSpectating = true. The subsequent GameStartingResponse flows through the existing menu-scene handler (transitions to GameScene) and the existing game-state-service handler (populates room state, resets moves). - Move replay events propagate through the global GAME_MOVE_SUCCESS handler in game-state-service before GameScene.create() runs, so GameScene's existing rejoin/spectate loop at create() renders every stone.
Gomoku Web Client
Phaser 3 web client for the Gomoku game server.
Setup
npm install
npm run dev
Open http://localhost:5173 in your browser.
Requirements
- Node.js 22+
- Game server running on
localhost:1024(WebSocket on port1025)
Server Connection
The client connects via WebSocket to ws://localhost:1025/ratel by default.
To connect to a remote server, update the URL in src/services/connection-service.js.
Scripts
| Command | Description |
|---|---|
npm run dev |
Start development server with HMR |
npm run build |
Build for production (dist/) |
npm run preview |
Preview production build locally |