Tools, tests & building

The dev panel, hot reload, generated files, tests, the desktop app, and the mistakes that are easy to make.

Dev panel

Press ` (the key left of 1) in a dev build. Along the top: collision overlay toggle, the player's tile and position, the clock. Sections:

SectionLets you
Collision overlayRed walls, orange NPC boxes, green triggers, blue interaction areas, yellow objects with ids, cyan player hitbox
Maps & spawns, Events, Minigames, WindowsJump to any map/spawn; start anything
Flags, relationships, money, items, questsEdit values, add/remove, start/advance/reset quests
Party, battlesGive XP, heal or hurt, add members; fight any enemy or troop
Achievements & journalUnlock any
Time & weather, propsSet the hour, rain/snow; spawn a prop in front of the player
TranslationsSwitch language; copy the texts shown without a translation
Title screensUnlock, lock and show each title screen variant
Across all savesCount / reset read lines, unlocks and achievements
LookOpen the look gallery: every colour, text size, button (each variant and colour: normal, focus, disabled), named part and other MUI part from content/look/, with a button to hear each UI sound. See The game's look.
System stateWhat the engine is doing (screens, map, scene)

Hot reload

Generated files

Never edit these; they're rewritten by the dev server and pnpm gen (also part of pnpm typecheck). They are committed, so a fresh checkout typechecks.

FileFrom
src/generated/registry.gen.tsThe content folders, audio files and migrations, plus plain id lists (ContentIds, QuestStepIds: quest step ids are read from each quest file, so it is rewritten when a quest file changes)
*.gen.ts + *.gen.png next to .asepriteSprites and portraits
*.gen.ts next to .tmx / .tmjTiled maps and structures
index.gen.ts next to index.vn, name.gen.ts next to name.vnDialogue scripts
docs/assets/*.gen.jsThis guide's search and code colours (pnpm guide)

Script report: pnpm story

pnpm story            # the report
pnpm story --voice    # also writes the scripts to record (build/voice-script.csv, build/voice-script/<voice>.csv)
pnpm story --number   # first numbers every spoken line that has no voice yet

Tests

pnpm test               # everything once
pnpm test:watch         # re-run on save
pnpm vitest run src/core/managers/party.test.ts   # one file

Tests to know:

Tips for writing tests:

Browser tests

pnpm test            # unit tests (fast, no browser)
pnpm test:browser    # plays the start of the game in a real headless browser
pnpm test:built      # the same idea for the built web game (after pnpm build:web)

pnpm test:browser starts its own dev server (port 5180), then at 1280×720 and at phone landscape 844×390 with touch: passes the title screen, starts a new game, plays the intro with confirm, walks, opens every engine window and checks that it fits the screen, crafts, shows a timer, the game-over screen, an event, fast travel, and saves and loads. Any error in the browser console fails the run. A picture of every step is written to build/browser-test/.

The browser test always runs the normal game with maps, whatever vnOnly says in src/content/config/mode.ts (VN routes and the flowchart are checked too, since they work in either mode). pnpm test:built checks the build as it is: in VN-only mode it checks that the story starts and its lines advance, otherwise that the intro ends and the map is drawn. Rebuild after changing the mode.

BrowserThe Chromium Playwright has downloaded (pnpm exec playwright-core install chromium), or any Chrome with CHROME_PATH=/path/to/chrome.
A game already runningGAME_URL=http://localhost:5173/ pnpm test:browser uses it instead of starting a server (dev builds only: the test reads the game through the dev server).
Your own checksAdd steps to scripts/browser/smoke.ts: withGame(page, "game.windows.open('shop')") runs code with the real game, check(screen, 'what', ok) records the result.

Lint, format, types

Building

pnpm build                # all targets below
pnpm build:web            # build/web (static files, host anywhere)
pnpm build:linux          # Linux AppImage
pnpm build:win            # Windows installer + portable .exe (needs wine on Linux)
pnpm build:desktop        # Linux + Windows
pnpm build:android        # Android debug APK (needs JDK 21 + Android SDK)
pnpm build:android-bundle # Android Play Store bundle (.aab), signed with android/keystore.properties
pnpm build:android --lite # any build + --lite: smaller pictures and sounds for weaker devices (files end in -lite)
pnpm vn:extension         # build/vn-extension/*.vsix

The web build uses relative paths, so build/web runs from any folder of any web server. .github/workflows/pages.yml publishes it to GitHub Pages when you run it by hand (GitHub -> Actions -> Pages -> Run workflow; pushing never rebuilds the site): this guide (docs/) at the site's root and the game in demo/ (the live demo). It needs Settings -> Pages -> Source set to "GitHub Actions". For your own game, keep it, change the folder, or delete the file.

The desktop app

Icons and splash

Every icon is a file in src/content/assets/icon/ (png, webp, jpg or svg). One kind is never made from another: each has its own file.

FileUsed for
icon.pngBrowser tab, desktop window, desktop installers (square, 512×512 is good)
icon.square.*Android launcher icon, older phones (48 dp)
icon.round.*Android launchers that show round icons (48 dp)
icon.foreground.*Android adaptive icon, front layer: 108 dp, the phone cuts it to its own shape, so keep the art inside the middle 66 dp
icon.background.*Optional: the adaptive icon's back layer. Without it, the colour iconBackground in app.ts
icon.monochrome.*Optional: Android 13 themed icons (one colour, the phone tints it)

In content: import { isElectron, isAndroid, canQuit, quit, setFullscreen } from '@/core/platform' for system-specific features. They fall back gracefully in the browser.

Android

# make the key once, keep it safe (losing it = no more updates on Play)
keytool -genkey -v -keystore android/release.jks -alias game -keyalg RSA -keysize 2048 -validity 10000
# android/keystore.properties
storeFile=release.jks
storePassword=…
keyAlias=game
keyPassword=…

The web build runs once, even when you build several targets. A target that fails doesn't stop the others; the summary at the end lists it. Installers and the APK end up in build/dist.

Big games

TargetLimitWhat the build does
WindowsInstaller and portable .exe: 2 GBOver 1.7 GB it makes a .zip of the game folder instead (Steam ships folders anyway).
Desktop (all)nonePictures, sounds and videos stay as plain files next to app.asar, so an update only changes the files that changed (small Steam patches).
Play Store500 MB base, 1.5 GB per asset pack, 4 GB in allOver 450 MB, media files move into install-time asset packs. Play installs them with the app and the game reads them at the same paths. Over 4 GB the build stops (download-later packs aren't supported yet).
Android APK4 GBStops with a message; use the bundle.

Converted images (art → big games) keep all of these much further away.

What the built game may load (security policy)

Every built game (web, desktop, Android) carries a Content-Security-Policy: the browser inside it refuses to load or run anything the policy does not list. By default that is only the game's own files, so a bug or a bad mod cannot make the game run code from elsewhere. pnpm dev:* has no policy (hot reload needs more freedom).

// src/content/config/security.ts
export default defineSecurity({
  contentSecurityPolicy: {
    enabled: true,
    allow: {
      connect: ['https://api.example.com'],   // fetch() / WebSocket
      images: [], media: [], fonts: [],       // files from other sites
      styles: [], scripts: [], frames: [],
    },
    allowEval: false,                         // true only for a library that needs eval
  },
})

Locked media (encrypted pictures and sounds)

Built games ship their pictures, sounds and videos encrypted, so players can't just open them from the game folder. The game unlocks each file as it loads it; nothing in your content changes. pnpm dev:* never locks anything.

// src/content/config/protect.ts
export default defineProtect({
  media: {
    enabled: true,
    key: 'any text, made up once',    // changing it later = every media file changes in the next update
    extensions: ['webp', 'png', 'ogg', 'flac', 'webm', /* … */],
    skip: ['icon.png'],               // stays plain (the browser reads the tab icon itself)
  },
})

Pitfalls

SymptomCause / fix
"Maximum update depth exceeded" in a windowA useGameData selector builds a new array/object. Select the existing object and derive in the component.
Import cycle / "cannot access before initialization"An up-front file (character, item, prop, quest…) imports game. Use the game from the hook's context.
Circular type errors (TS7022) between maps/eventsHooks are typed => void on purpose; don't annotate them as Promise<void>. Keep save/data.ts free of game imports.
A Tiled tileset won't loadSaved as .tsx: export it as .tsj (JSON) or embed it.
Text stays EnglishNot found by the scanner (template string, variable): see Translations. Or a toast without game.t().
A mid-scene save loads differentlyMath.random() in the event: use random() from the context.
Works in dev, but a file or script is blocked in the built gameThe security policy: see what the built game may load.
No soundNo key pressed yet (browser rule), or the volume sliders in Settings.
game.events.start never resolvesAwaited from inside a running event: it's queued after the current one. Use event(id) instead.
Functions named use… get hook lint errorsBiome treats every useX as a React hook. Pick another name.