63 lines
3.2 KiB
Markdown
63 lines
3.2 KiB
Markdown
# Star Wars - Wild Space
|
||
|
||
Exploitable ring only (outer Ø100, inner Ø60). Planet positions are deterministic from the **server world seed**; **stats stay hidden** until you click a tile. Reveals are **persisted in PostgreSQL**.
|
||
|
||
## Runtime config (file + volume)
|
||
|
||
Edit **`config/game.settings.json`** on the host (mounted into the container at `/app/config/game.settings.json`). The server reloads it when the file’s **mtime** changes, on a schedule controlled by **`configReloadIntervalSeconds`** (minimum 5s), so frequent polling is avoided when nothing changed.
|
||
|
||
| Field | Meaning |
|
||
|--------|--------|
|
||
| `clickCooldownSeconds` | Cooldown between **new** reveals (same as before). |
|
||
| `databaseWipeoutIntervalSeconds` | World period length in **seconds** (default `21600` = 6h). The **world seed** is `swg-<slot>` with `slot = floor(UTC unix seconds / this value)`. When the slot changes, **`grid_cells` is truncated** (full wipe). |
|
||
| `debugModeForTeams` | If `true` or string `"true"` / `"True"` (case-insensitive), the **Blue / Red** segmented control is shown; if `false`, it is hidden. |
|
||
| `configReloadIntervalSeconds` | How often the server **checks** the config file (mtime); also used by the client to poll `/api/config`. |
|
||
|
||
`GET /api/config` returns these values plus **`worldSeed`**, **`seedPeriodEndsAtUtc`**, **`seedPeriodStartsAtUtc`**.
|
||
|
||
## Teams (blue / red)
|
||
|
||
- With **`debugModeForTeams`**: use the **Team** control (top-left) to switch perspective.
|
||
- **Your** discovered tiles use your team color (blue: bright cyan; red: red when revealed). Unclaimed ring tiles use the **classic** idle tint for both teams.
|
||
- Tiles discovered by the **other** team appear **grey**, show **no planet**, and are **not clickable**. First reveal **owns** the tile (`discovered_by`).
|
||
|
||
## Cooldown
|
||
|
||
After revealing a **new** tile, a **cooldown** runs (top-right). During cooldown you **cannot reveal additional unseen tiles**, but you can still **click tiles your team already discovered** to view their stats.
|
||
|
||
## Run with Docker Compose (Node + PostgreSQL)
|
||
|
||
From `d:\Users\GaWin\Travaux\Code\star_wars_grid_game`:
|
||
|
||
```powershell
|
||
docker compose up --build
|
||
```
|
||
|
||
Open `http://localhost:8080`.
|
||
|
||
- **App:** port `8080`
|
||
- **Postgres:** port `5432` (user `game`, password `game`, database `star_wars_grid`)
|
||
- **Config:** host folder **`./config`** is mounted to **`/app/config`** — edit `game.settings.json` without rebuilding the image.
|
||
|
||
### Database persistence
|
||
|
||
PostgreSQL data is under **`./data/postgres`** (bind mount). The **world wipe** only clears `grid_cells` when the UTC period slot changes; it does not delete the Postgres data directory.
|
||
|
||
## Local dev (without Docker)
|
||
|
||
Requires PostgreSQL and `DATABASE_URL`, then:
|
||
|
||
```powershell
|
||
npm install
|
||
$env:DATABASE_URL="postgres://user:pass@localhost:5432/star_wars_grid"
|
||
npm start
|
||
```
|
||
|
||
Ensure `config/game.settings.json` exists (or copy from the repo).
|
||
|
||
## API
|
||
|
||
- `GET /api/config` — cooldown, wipe interval, debug flag, poll interval, `worldSeed`, period timestamps.
|
||
- `GET /api/grid/:seed` — cells for that seed; **`410`** if `seed` is not the current world seed.
|
||
- `POST /api/cell/reveal` — body `{ seed, x, y, team: "blue" \| "red" }` — first reveal wins; **`409`** if the other team owns the tile; **`410`** if seed is stale.
|