Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arena Quest LiveOps Academy

Arena Quest is a top-down 2D arena game built with TypeScript and Excalibur.js, made to be run as a live service. This repository holds the game at four points in its construction, from an empty project to the finished game, and serves any one of them on port 3000.

Versions

GAME_VERSION What it is Source
blank An empty Vite and Excalibur project with the sprite sheet. Nothing runs yet snapshots/blank
player An animated player moving around a one-screen arena with the keyboard snapshots/player
playable The first playable round: enemies, an attack, coins, score, a HUD, win, loss, pause, restart snapshots/playable
final (default) The finished game: weapons, dash, elites, upgrades, a leaderboard, and rules in a separate engine-free package apps/, packages/

Each version continues from the one before. The first three are small, standalone, plain Excalibur projects; see snapshots/README.md.

Quick start

Needs Docker with Compose. The design system is a git submodule, so clone with it:

git clone --recurse-submodules <this repository>
make up

Then open http://localhost:3000. Only that one address is needed: the version you choose is what it serves.

make up GAME_VERSION=playable   # or blank, player, final
make down

Switching versions restarts one container and rebuilds nothing. http://localhost:3000/versionz reports which one is running. If you cloned without the submodule, make up fetches it.

For final, the page at / is the workspace: it shows the game and, when admin tools are running, one of them beside it. In the final game: Move with WASD or the arrow keys and aim with the mouse; bullets fire on their own when an enemy is in reach, and a wedge in front of the avatar shows where they will go. Space or Shift dashes, P or Escape pauses, Enter resumes or plays again. Each round draws one of six arena layouts. The title screen is the player's base: spend coins on weapons and permanent upgrades there and check the leaderboard, whose rivals are simulated.

Live services

The game always works on its own. Profiles add the services a live game runs on, all behind the same port:

make up PROFILE=backend       # Nakama and PostgreSQL: accounts, coins kept by the server, rewards, live events
make up PROFILE=analytics     # PostgreSQL, the event collector, 1,000 simulated players, and Grafana
make up PROFILE=experiments   # Nakama, the event collector and GrowthBook: flags, remote configuration, an A/B test
make up PROFILE=operations    # Nakama, the event collector, Grafana, Prometheus and Loki: metrics, logs, alerts
make up PROFILE=full          # everything

With a profile running, the workspace page at http://localhost:3000 shows the game on the left and an admin tool on the right, with a divider you can drag. Tabs switch between the Nakama Console, GrowthBook, and Grafana.

Each tool opens already signed in as its administrator: a sandbox has one user. make up PROFILE=full AUTO_SIGN_IN=false turns that off, and each tool then asks for the sign-in values generated into .secrets/sandbox.env.

The game's base screen shows what it is connected to. With Nakama it signs in, saves progress to the server, submits each run for the server to check, and lets the server keep its coins: the server pays for accepted runs, grants a daily reward and achievements, takes the coins for purchases, and runs live events with prizes; with GrowthBook it reads three flags (arena.double_coins, arena.coin_multiplier, arena.config) and takes part in one A/B test; with the event collector it reports what happens in each round. If a service is down, the game says so and plays on. See docs/architecture.md.

Gameplay events and simulated players

In the analytics, experiments, and full profiles the game sends its gameplay events to an event collector, which checks them and stores them in PostgreSQL. The same database starts with 30 days of history from 1,000 simulated players, produced by running the real game rules.

make sql PROFILE=analytics QUERY="SELECT outcome, count(*) FROM sessions GROUP BY 1"
make sql PROFILE=analytics FILE=my-query.sql
make simulate PROFILE=analytics PLAYERS=200 DAYS=14 SEED=7   # replace the simulated players
make verify-dataset PROFILE=analytics                        # SQL results match the dataset's manifest

make sql runs as a role that can only read. The tables and views are described in docs/analytics-data.md.

In the experiments and full profiles GrowthBook reads the same database, also read-only. It starts with the coin-reward-test experiment already running: linked to the arena.coin_multiplier flag, with six metrics, and with results worked out from the simulated players. Rounds you play join the same experiment.

Running the sandbox as a live game

Profiles with Nakama have a clock of their own, live events, and switches that break things on purpose:

make clock PROFILE=backend ADVANCE=1d                        # tomorrow: a new daily reward, a day off every event
make clock PROFILE=backend RESET=1                           # back to the real time
make event PROFILE=backend ID=friday-cup DURATION=10m        # a new live event, open for ten minutes
make fault PROFILE=operations SET="game_rpc_delay_ms=800"    # every call to the game server takes 0.8 s longer
make fault PROFILE=operations SET="collector_error_rate=0.5" # half of all event batches fail
make fault PROFILE=operations CLEAR=1
make load PROFILE=operations LOAD_PLAYERS=20 LOAD_SECONDS=120   # players playing right now
make reset PROFILE=backend                                   # a new sandbox's state, in about a second
make seed PROFILE=backend                                    # a fixed cast of 20 players, the same every time
make state PROFILE=backend                                   # the game server's state as JSON

In the operations and full profiles Grafana also has an "Arena Quest services" dashboard over Prometheus and Loki, and eight alerts. Switch a fault on, run some load, and the matching alert fires within about a minute. See docs/operations.md.

A release also carries one archive with every program of ours already built. The same sandbox runs where all containers share one host, and where our programs run in a single workspace with only the tools as containers beside it: see docs/single-host.md.

./scripts/verify-profile.sh <profile> asserts that Compose starts only the services that profile lists, and that only port 3000 is published. The full profile needs up to 2.9 GiB of memory, most of it GrowthBook; operations needs about 0.9 GiB and game about 30 MiB. make down stops whatever is running, whichever profile started it.

Working on an earlier version directly

Each folder under snapshots/ is a complete project that needs only Node 26 and pnpm, with no Docker:

cd snapshots/player
pnpm install
pnpm dev      # http://localhost:3000, reloads on save
pnpm check    # type check and tests

Development

Needs Node 26 and pnpm 12.

pnpm install
pnpm lint && pnpm format:check && pnpm typecheck && pnpm test
make up GAME_VERSION=final && GAME_VERSION=final pnpm test:e2e

Browser tests run against one version at a time: give make up and pnpm test:e2e the same GAME_VERSION. The tests for the live services run with make up PROFILE=full and LAB_PROFILE=full pnpm test:e2e, and likewise for analytics.

Publishing a GitHub release attaches one source archive per version; see docs/releases.md.

License

This project is licensed under the Elastic License 2.0. See LICENSE.md.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages