Multiplayer mode: server, room tokens, docker setup, and client UI
This commit is contained in:
1 parent
176d7cc300
commit
434c81d0b6
19 files changed
+2563
-382
No files matched your search
@@ -0,0 +1,53 @@
|
||||
# Tic Tac Toe
|
||||
|
||||
A tic-tac-toe game with two modes: **CPU** (play against a minimax AI) and **Online** (real-time 2-player over WebSocket).
|
||||
|
||||
## Stack
|
||||
- Frontend: vanilla JS + CSS (no build step)
|
||||
- Backend: Node.js + Express (serves static files) + `ws` (WebSocket) + `sql.js` (SQLite, in-memory)
|
||||
|
||||
## Project layout
|
||||
```
|
||||
public/ frontend (index.html, app.js, game.js, multiplayer.js, style.css)
|
||||
server/ backend (server.js, db.js, package.json, pnpm-lock.yaml)
|
||||
docs/ design docs
|
||||
Dockerfile production image
|
||||
docker-compose.yml
|
||||
```
|
||||
|
||||
## Run locally
|
||||
|
||||
The backend lives in `server/` (the frontend has no build step).
|
||||
|
||||
```bash
|
||||
# install backend deps (pnpm)
|
||||
cd server && pnpm install
|
||||
|
||||
# start (default port 8080)
|
||||
node server/server.js
|
||||
# or with an explicit port
|
||||
PORT=8080 node server/server.js
|
||||
```
|
||||
|
||||
Then open <http://localhost:8080/>.
|
||||
|
||||
> The server reads `PORT` (default `8080`) and optional `BASE_PATH` (default empty).
|
||||
|
||||
## Run with Docker
|
||||
|
||||
```bash
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
or build and run the image directly:
|
||||
|
||||
```bash
|
||||
docker build -t tictactoe .
|
||||
docker run -p 8080:8080 tictactoe
|
||||
```
|
||||
|
||||
Then open <http://localhost:8080/>.
|
||||
|
||||
## Notes
|
||||
- `server/data/` holds the SQLite file and is git-ignored.
|
||||
- Online games persist to SQLite; a host who reloads can re-enter via the saved token.
|
||||
Reference in new issue
Block a user