Commit Graph

12 Commits

Author SHA1 Message Date
tiennm99 d45b1275af refactor: typed proto enums, dead code cleanup, room-join broadcast fix
Protocol type safety
- Add Piece, GameResult, RoomType, RoomStatus proto3 enums; replace
  unsafe string fields in GameMoveSuccessResponse, GameOverResponse,
  RoomCreateSuccessResponse, RoomSummary, WatchGameSuccessResponse.
- Go compiler now rejects typos like "PVP" or "BLACK". protobufjs
  toJSON() serializes enums as UPPERCASE names, so existing client
  comparisons keep working.
- Fixes turn-change bug where lowercase "black"/"white" server strings
  never matched client 'BLACK'/'WHITE' checks, freezing currentTurn
  and blocking the non-starting player's clicks.
- Regenerate Go + JS stubs.

Room-join bug fix
- home.go handleJoinRoom now broadcasts RoomJoinSuccessResponse to all
  players in the room (owner + joiner), not just the joiner. Owner
  can see the player count flip to 2/2 and the Start Game button
  enables. Remove superseded broadcastJoined + GameReadyResponse path.
- client menu-scene _onRoomJoinSuccess: read correct proto camelCase
  field names (roomOwner, roomClientCount, clientNickname).

Dead code removal
- Delete GameReadyRequest/Response proto messages entirely; leaveRoom
  notifies via ClientExitResponse.
- Delete server/network/{network,wss}.go empty stubs.
- Delete server/pkg/consts/ unused re-export package.
- Slim server/consts/const.go from 117 LOC to 24: drop legacy TCP
  constants, duplicated RoomType/RoomStatus enums, Error/NewErr types,
  StateJoin/StateCreate=0 type-unsafe aliases, unused GameTypes maps.
- database/player.go: remove unused IP, Mode, Type, Amount, legacy
  private state field.
- Fix gopls findings: unused forPlayer, gameOverOnce, runAIMove player,
  handleGameReset player params.

go vet + go test ./... green, npm run build green.
2026-04-11 16:03:21 +07:00
tiennm99 b2be88597c feat(docker): multi-stage Dockerfiles and compose for server + nginx client
- server/Dockerfile: golang:1.23-alpine build → distroless/static-debian12:nonroot (3.5 MB)
- client/Dockerfile: node:22-alpine Vite build → nginx:1.27-alpine runtime
- client/nginx.conf: SPA fallback, aggressive asset caching, gzip
- docker-compose.yml: two services — server :1999, client :8080
- server/.dockerignore / client/.dockerignore: trim build contexts
- server/Makefile: add docker-build/run/stop/logs/smoke targets
- client/vite.config.js: raise chunkSizeWarningLimit to 2000 (Phaser bundle)
- remove server/docker-compose.yaml (superseded by root compose file)
2026-04-11 15:28:15 +07:00
tiennm99 e8281e5411 chore(client): split menu-ui into lobby and rooms modules
menu-ui.js exceeded 200-line limit. Extract room-list, PVE difficulty panel,
and waiting-room into menu-ui-rooms.js. menu-ui.js re-exports showRoomList
and showWaiting so menu-scene.js import paths are unchanged.
2026-04-11 14:55:04 +07:00
tiennm99 2d917d5d85 feat(client): dom menu-ui and game-ui with role-aware waiting room
menu-ui.js: nickname screen, lobby, PVP/PVE submenus, room list table,
role-aware showWaiting() — owner gets Start Game button (disabled until
playerCount=2); joiner gets passive wait message. Returns update() handle
for live ROOM_JOIN_SUCCESS pushes from menu-scene. All user strings set
via textContent for XSS safety.

game-ui.js: game HUD with turn indicator dots, scrollable move history,
showGameOver modal with Play Again (sendGameReset) and Leave buttons,
showToast auto-dismissing after 2s into #toast-container. Error toasts
wired for all GAME_MOVE_* and spectator-cannot-act events.
2026-04-11 14:49:04 +07:00
tiennm99 4c59ee0f83 feat(client): phaser board and stone objects with drop-in animation
Replace phase-09 stubs with real Phaser.GameObjects.Graphics implementations.
Board draws wood-textured 15x15 grid with star points and coordinate labels.
Stone renders gradient black/white circle with 180ms Back.easeOut drop tween.
createLastMoveMarker draws a red filled circle at the last-played intersection.
menu-scene.js wired for live waiting-room updates and role-aware showWaiting.
2026-04-11 14:48:55 +07:00
tiennm99 2c37c8f4ef feat(client): boot/menu/game scenes wired to event bus and protobuf dispatch
- boot-scene: connects WS, waits for NICKNAME_SET then starts MenuScene
- menu-scene: subscribes to CLIENT_CONNECT/NICKNAME_SET/SHOW_OPTIONS/SHOW_ROOMS/
  ROOM_CREATE_SUCCESS/ROOM_JOIN_SUCCESS/ROOM_JOIN_FAIL_*/GAME_STARTING; delegates
  to menu-ui stubs; proper shutdown() unsubscribes all handlers
- game-scene: Board+Stone stub integration, hover preview, click→sendGameMove,
  GAME_MOVE_SUCCESS/GAME_OVER/CLIENT_EXIT/GAME_STARTING/SPECTATOR_CANNOT_ACT/
  move error events all wired; audio feedback; shutdown() cleanup
2026-04-11 13:41:40 +07:00
tiennm99 6b2035632f feat(client): event-bus, connection-service, game-state-service with typed protobuf
- event-bus: pub/sub singleton with on/once/off/emit
- connection-service: WS wrapper for ws://host:1999/gomoku, binary protobuf
  encode/decode, 50s heartbeat, exponential backoff reconnect (max 10 attempts),
  14 typed send helpers including sendGameStarting() (owner-only explicit start)
- game-state-service: client-side state container wired to all ClientEventCode
  events; exposes isMyTurn(), currentPlayerNickname(), isOccupied()
- menu-ui, game-ui: no-op stubs for phase-10 to replace
- board, stone: minimal stub classes so GameScene compiles without real Phaser objects
2026-04-11 13:41:32 +07:00
tiennm99 a5acd69b87 feat(client): phaser+vite bootstrap with html shell, game config, and scene stubs
- index.html: dark shell with #game-container (Phaser canvas parent),
  #ui-overlay containing #menu-root, #game-hud-root, #toast-container
- vite.config.js: port 5173, strictPort, sourcemap build, no GitHub Pages base
- src/main.js: instantiates Phaser.Game from gameConfig
- src/config/game-config.js: 800x800 FIT canvas, parent=game-container, scene list
- src/config/protocol-constants.js: ClientEventCode enum aligned to response.proto
  oneofs; adds SPECTATOR_CANNOT_ACT, renames GAME_WATCH_SUCCESSFUL to
  WATCH_GAME_SUCCESS, drops CLIENT_KICK (no proto case)
- src/scenes/boot-scene.js|menu-scene.js|game-scene.js: minimal stubs for Phaser
  scene registry; phase-09 replaces them with real implementations
2026-04-11 12:48:07 +07:00
tiennm99 a5d1443327 feat(client): initial package.json and generated protobuf bindings
Adds Phaser+Vite+protobufjs package.json with proto:gen script, installs
dependencies, and commits generated protocol.js and protocol.d.ts so
builds work without requiring protoc or pbjs on every dev box.
Also adds node_modules/ to root .gitignore.
2026-04-11 12:41:06 +07:00
tiennm99 1ce619ba4c chore: add skeleton directories for future phases
common/proto/, server/game/, server/protocol/, client/src/{config,scenes,
services,objects,ui,generated} — all .gitkeep placeholders.
2026-04-11 12:07:25 +07:00
tiennm99 b089e64955 refactor: delete api/, core/, old client/, web/, server/bot/, server/network/tcp.go
Removed legacy Java API, Go shared core lib, Go CLI client, vanilla-JS web
client, QQ bot integration, and TCP listener. Server is now WS-only.
2026-04-11 12:07:18 +07:00
tiennm99 6e3670aec8 feat: add ratel-online server, core, client, and api sources
Import source files from ratel-online organization repos into monorepo
structure for gomoku game development. Update README with project
structure and credits for original authors.
2026-04-09 17:09:41 +07:00