# VerseRealms Game Developer Guide

Version 1.4 · Updated 2026-11-21

This is the one set of rules for every game made for VerseRealms, the Bible games hub at https://biblized.com.
It covers content and Scripture, technical rules, the shared player interface, hub integration and how to hand a
game in. The newest version always lives at **https://biblized.com/developers/guide.md** (plain text) and
**https://biblized.com/developers** (web page). If a copy you have disagrees with those addresses, the addresses win.

## 0. Read this first (people and AI assistants)

- **MUST** means required: a game that breaks a MUST rule is sent back in review. **SHOULD** means expected: if
  you skip it, say why in your README.
- This guide applies to the whole project. When a template, framework default or your own habit conflicts with
  it, follow this guide.
- **AI coding assistants:** read this whole guide at the start of every work session before changing code.
  Never write Scripture from memory (section 3). When a rule is unclear, or a topic is listed under
  "Pending operator decisions" (section 10), stop and ask the person you are working with instead of guessing.
- Write the version you followed in your README, for example `Follows VerseRealms Game Developer Guide v1.0`.
  Reviewers check your game against that version.

## 1. Set up your game repository

Every game repository gets the same two small files at its top level. They never change, because they only point
here, so new rules reach every game automatically.

`AGENTS.md` (read by Codex, Cursor, GitHub Copilot and many other AI assistants):

```markdown
# VerseRealms game

This game is made for the VerseRealms Bible games hub.
At the start of every session, before changing anything, read and follow
https://biblized.com/developers/guide.md
It is the single source of rules for VerseRealms games and overrides defaults
or templates that conflict with it. Record the guide version you followed in
README.md. If a rule is unclear, ask instead of guessing.

## Notes for this game
(Game-specific notes go below this line.)
```

`CLAUDE.md` (read by Claude Code), one line that loads the file above:

```markdown
@AGENTS.md
```

Chat-only tools that cannot read files (for example ChatGPT in the browser): paste the guide address at the
start of the conversation and ask the assistant to follow it.

## 2. Audience and content

VerseRealms publishes games for a **general audience aged 13 and up**, including families, schools and churches.
Games are reviewed against the [Statement of Faith](https://biblized.com/statement-of-faith) and the
[Community Guidelines](https://biblized.com/community-guidelines). Players do not have to agree with the Statement of
Faith, but published games must not contradict it.

MUST:

- Everything is suitable for ages 13+: no sexual content, no harassment, hate or threats, no profanity or crude
  humor.
- Every character, human or not, is **modestly dressed** at all times. No undressed or sexualized appearances,
  poses or animations.
- No gambling mechanics: no loot boxes, no paid or chance-based rewards, no real money anywhere.
- Scores, levels and rewards measure play only. Never suggest that a score, level, or win or loss reflects a
  person's holiness, salvation or worth before God.
- The README lists **content notes**: combat, scary or sad moments, mature themes, and what is fiction or
  interpretation.
- Respect intellectual property: you need permission for all code, art, music, sound, fonts and text (section 8).

SHOULD:

- Point players toward reading the Bible itself. Games are a way to explore Scripture, never a substitute for it.
- Treat biblical people and events with respect, even in a light-hearted game.

## 3. Scripture

AI models often misquote verses, merge translations or invent references that sound right. These rules exist
because of that.

MUST:

- **Scripture text comes only from a data file** stored in the project (for example
  `data/scripture/web.json`), copied from a published source of a translation you are allowed to use. Name the
  source in the README. Never type, generate, "fix" or complete verse text from memory. AI assistants must load
  verses from that file, not write them.
- Every quotation shows its **reference and translation**, for example `John 3:16 (WEB)`, and matches the data
  file word for word.
- Quotation, interpretation and fiction are **visibly different**. Show Scripture in its own style (for example a
  serif font with the reference). Paraphrased or invented dialogue is never shown as a quotation with a reference.
  Fictional story elements are named in the content notes and on an "About this game" or credits screen.
- Use only a translation you have the right to use:

| Translation | Status |
| --- | --- |
| World English Bible (WEB), King James Version (KJV), American Standard Version (ASV, 1901), Berean Standard Bible (BSB) | Public domain in most countries. Recommended. Text files: ebible.org. |
| Korean Revised Version (개역한글, 1961) | Generally treated as public domain. Confirm with the operator before use. |
| NIV, ESV, NKJV, NLT, CSB, NASB, New Korean Revised Version (개역개정), 새번역 and other modern translations | Copyrighted. Allowed only with the operator's approval and the publisher's required copyright notice shown in the game. |

When unsure, use the WEB or the KJV.

## 4. How your game runs on the hub

| Your game | Launch type | What the hub does |
| --- | --- | --- |
| Runs entirely in the browser (HTML/CSS/JS, Phaser, PixiJS, Three.js, Godot or Unity web export), no server of its own | **Hosted static build** (recommended) | Reviews your build and serves exactly that version from its own isolated game site |
| Has its own server (accounts, leaderboards, server saves) | **Connected game** | Sends players to your https address; your server can use the integration API (section 7) |
| Lives on a website you host or don't control | **External link** | Opens your https address, inside the hub frame or in a new tab |
| Not playable yet | **In development** | Lists the title and art with no Play button |

The hub never runs your server code (no Node, Python, PHP or Docker on the hub). Frameworks that need a server
at runtime (server-side rendering, API routes) are connected games, not static builds.

The hub doesn't run desktop (download) games either. It can list one as an external link to its download page, or
as in development. A desktop game can still sign players in with their VerseRealms account through the desktop
link page (section 7, "Games on the VerseRealms backend").

An external link shown **inside the hub** must let the hub frame it: send no `X-Frame-Options` header, and if your
site sends a Content-Security-Policy, include `frame-ancestors https://biblized.com`. Register the final address (after
any redirect), because the hub talks only to that exact origin.

## 5. Technical rules

### Build contents (hosted static builds)

The hub checks every build automatically and refuses it if a rule fails.

MUST:

- `index.html` at the top level of the build, or inside one top-level folder.
- Only these file types: html, htm, js, mjs, cjs, css, json, map, txt, md, xml, csv, tsv, webmanifest, png, jpg, jpeg, gif, webp, avif, svg, ico, bmp, mp3, ogg, oga, wav, m4a, aac, flac, opus, mid, midi, webm, mp4, m4v, ogv, woff, woff2, ttf, otf, eot, wasm, pck, data, unityweb, bin, glb, gltf, fbx, obj, mtl, atlas, fnt, tmx, tsx, ldtk, vtt, srt.
- None of these: `.env` files, `node_modules/`, `.git/`, server scripts or programs, server configuration
  (`.htaccess`, `.htpasswd`, `.npmrc`, `web.config`), symbolic links, absolute paths or `..` in paths.
- At most 10,000 files, 1,024 MB in total and 200 MB per file; paths at most
  200 characters and 16 folders deep. Ask the operator before you need more.

### Paths

Your game is served from `https://<game-slug>.<game domain>/r/<release token>/`, not from the site root.

MUST:

- Use **relative paths** for every asset: `./assets/hero.png`, not `/assets/hero.png`.
  - Vite: set `base: './'` in `vite.config`.
  - webpack: set `output.publicPath` to `'./'` or `'auto'`.
  - Godot and Unity web exports use relative paths by default; keep them.
- The only absolute path allowed is the hub SDK script, `/_sdk/verserealms-sdk-v1.js` (section 7).
- The same build must work in both places it runs: at `/r/<release token>/index.html?vr_launch=...` on the hub and
  at `http://localhost:<port>/?vr_launcher=1` when the launcher installs it. Resolve addresses against
  `document.baseURI`, never against `location.origin` or a fixed path, and keep query parameters you don't know.
- No history-API routing (`pushState` to paths like `/settings`): only files listed in your build exist, so
  reloading such a path gives "not found" on the hub and in the launcher. Use hash routes (`#/settings`) or none.
- File names are case-sensitive where your game is served, even if they work on your Windows PC: `Hero.png` and
  `hero.png` are different files. The hub also refuses names that differ only by case, Windows device names
  (`con`, `aux`, `nul`, `com1`...), names ending in a dot or space, and the characters `: < > " | ? *`.
- Never ship files under `/_sdk/` or `/__verserealms/`: the hub and the launcher answer those addresses
  themselves.

### The sandboxed frame

The hub shows your game in an iframe with `sandbox="allow-scripts allow-same-origin"`.

MUST:

- Don't navigate or redirect the whole page, and don't open popups.
- Don't use `alert()`, `confirm()` or `prompt()`: they are blocked in the frame. Draw your own dialogs.
- If the game needs one of these extra permissions, list it in the README and the operator decides:
  `allow-pointer-lock`, `allow-popups`, `allow-forms`, `allow-modals`, `allow-downloads`.

SHOULD:

- Don't depend on Esc: browsers use it to leave fullscreen. Offer another key as well (section 6).

### Saves and network

- Browser saves: `localStorage` and `IndexedDB` work and are private to your game. Wrap storage calls in
  `try/catch`, because some browsers block storage inside frames. The game must still run, without saving, if
  storage fails.
- Browsers keep a separate copy of storage for a game shown inside another site. A browser save made inside the hub
  is not there when the game is opened in a new tab, in another browser or on another device. To keep progress with
  the player's account, use **cloud saves** (section 7), and keep browser saves for guests.
- MUST: no requests to other websites from a static build. Bundle every library and font file into the build (no
  CDNs, no Google Fonts links). No ads, analytics, trackers, third-party login, social widgets or external
  embeds. A game that needs its own server or API is a connected game; describe every network call in the README.
  The one exception is the VerseRealms backend address the operator gives you for sign-in and saves (section 7):
  read it from your build configuration, never hard-code a development address, and if your build sets its own
  Content-Security-Policy, allow it in `connect-src` together with `'self'`.
- MUST: no secrets in code, builds, README or chat messages. List only the names of environment variables your
  game needs, never their values. A key that is safe to be public (for example a Firebase web config protected by
  security rules) needs a sentence in the README explaining why it is safe.

### Engines

- **Godot 4 web export**: exports without threads run inside the hub. Exports with threads need special server
  headers; say so in the README and the game opens in its own tab. Godot 4 C#/.NET projects may not support web
  export; check your Godot version's export notes.
- **Unity WebGL**: export with compression **disabled** or with **gzip fallback**. Brotli-only builds won't load.
- Test in current Chrome, Edge, Firefox and Safari, and on a phone or tablet if you list those devices.

## 6. Shared player interface

The hub draws a bar above every game with **Back to hub**, the game title, **Fullscreen**, **New tab** and
**Report**. Your game fills the space below it. All games MUST work the same way in these respects:

- **Don't copy the hub.** No buttons, logins or screens that imitate the hub bar or the VerseRealms website.
- **Fit any frame.** The frame can be any size from about 360×480 (phone) to a full desktop screen, and it changes
  when the player resizes or switches to fullscreen. Scale or letterbox your canvas; never require a fixed window
  size, and don't show page scrollbars around the game.
- **Work on its own.** The New tab button opens your game outside the hub, so it must start and play there too.
- **Quiet start.** No sound before the player's first click, tap or key press. Offer sound on/off and remember
  the choice.
- **Title screen** with the game title, the creator name, the Bible translation used (`Scripture: WEB`) and a
  clear Start button.
- **Menu** reachable at any time from an on-screen button and a key (for example `P`), with at least Resume,
  Sound on/off, How to play and Restart.
- **How to play** screen listing the controls. Every control listed in the README works.
- **Readable and safe.** Text at least 16 px at a 1280×720 frame, with good contrast. Touch targets at least
  44×44 px on touch devices. No flashing more than three times per second.

The VerseRealms look (SHOULD, for menus, buttons and text; your game art style is your choice):

| Use | Value |
| --- | --- |
| Fonts | Plus Jakarta Sans (titles), Inter (interface text), Source Serif 4 (Scripture). All use the SIL Open Font License; put the font files in your build. |
| Background and panels | `#090c11` background, `#11161e` and `#161d27` panels |
| Text | `#eef1f6` main, `#b6bfcc` secondary, `#808b9b` muted |
| Accent | Gold `#f4c25b` for primary buttons and highlights |
| Status colors | Sage `#a6d78f` success, sky `#93b6ff` info, `#ff8080` danger |
| Shapes | Corner radius 11 to 16 px; Scripture in the serif font with the reference beneath it |

## 7. Hub integration (optional)

A game needs no integration to be listed (L0). Integration adds features step by step.

| Level | What your game gets | What it needs | Can award XP or Denarii? |
| --- | --- | --- | --- |
| L0 Launch | Listed and launched by the hub | A reviewed build or URL | No |
| L1 Identity | A game-scoped player ID, display name and avatar | Static: the SDK. Connected: a server that exchanges launch codes | No |
| L2 Progress and achievements | L1, plus reporting progress and achievements | A trusted game server with an API key | Yes, only for achievements the operator defines |
| L3 Denarii purchases | Future | | Disabled in v1.0 |

**Cloud saves** work at every level, L0 included, whenever a signed-in player plays inside the hub (see below).

Rules that never change:

- Games never receive the player's hub account ID, email, password, birth date, wallet or cookies.
- The same player has a different `gameUserId` in each game.
- Only a server holding an API key can grant rewards. A browser can't be trusted: static games can greet the
  player by name but cannot award XP or Denarii.
- The operator sets your game's integration level and defines its achievements and their rewards (at most
  1,000 XP and 100 DN each). Ask the operator for your achievement keys; don't invent new ones.

### The SDK

The SDK is one small script. Load it from the address that matches your launch type:

| Launch type | Script tag |
| --- | --- |
| Hosted static build | `<script src="/_sdk/verserealms-sdk-v1.js"></script>` (served by your game's own origin) |
| External link inside the hub | `<script src="https://biblized.com/sdk/verserealms-sdk-v1.js"></script>` (if your site sends a Content-Security-Policy, allow `https://biblized.com` in `script-src`) |

Connected games don't use the SDK; their server calls the API below.

### L1 in a hosted static game

```html
<script src="/_sdk/verserealms-sdk-v1.js"></script>
<script>
  const vr = window.VerseRealms; // undefined when the SDK isn't available (local testing, other hosting)
  if (vr) {
    vr.ready().then((s) => {
      // s = { connected, guest, player: { gameUserId, displayName, avatar } | null, integrationLevel, saves }
      showGreeting(s.player ? `Playing as ${s.player.displayName}` : 'Playing as a guest');
    });
    vr.onConnect((s) => { /* also called if the hub answers after ready() resolved */ });
  }
  // Optional menu items: vr.exit() returns to the game's hub page, vr.reportProblem() opens the report form.
</script>
```

- Always check `window.VerseRealms` first so the game still runs without it (local testing, other hosting).
- `ready()` resolves within about 6 seconds; opened outside the hub it resolves at once with `connected: false`.
- `player` is `null` for guests, for L0 games and for external links (they never receive identity). You may use
  `gameUserId` as a key for local saves, but never to grant anything valuable. It is not the same id as the
  backend's `gameUserId` (launcher and ticket starts), so a game played both ways must not rely on it to find the
  same local save or to build event ids.

### Cloud saves (any level)

A game can keep up to 10 named **slots** per player in the hub, each holding up to
256 KB of JSON, so progress follows the player's account to any browser or device. Slot names are 1 to
32 characters from `a-z 0-9 _ -`, starting with a letter or digit (for example `main`, `slot-2`, `settings`).

They work when a **signed-in** player plays a hosted static build or an external link **inside the hub's game
window**. Guests, a game opened in a new tab and local testing have no cloud saves: use browser saves there.
Connected games use the server API below instead.

**One save store.** When the operator turns it on for your game, its cloud saves live in the **VerseRealms
backend's** store, which the hub's game window, the VerseRealms launcher and backend ticket launches all share.
Inside the hub's game window your code above keeps working unchanged. Started by the launcher, the game is not in
the hub's window: the hub SDK reports `connected: false` and the code above falls back to browser saves. To share
the player's saves there too, the game must also call `signInViaLauncher` and use the backend SDK's saves with the
same slot names (see [Started by the VerseRealms launcher](#started-by-the-verserealms-launcher)). The first time a
player uses the shared store, the hub copies that player's existing hub saves over once, create only, unless the
backend already has saves of theirs for the game (those are kept; nothing is ever overwritten). A copy that was
interrupted is finished on the player's next save call. Revisions then start again at 1, so a tab that still holds
an old revision gets one `save_conflict` and loads again. Saves made through the hub carry no `formatVersion` (a
field of the backend's own save API): keep your format number inside `data`, as the rules below say.

Known limit: if the operator turns the shared store off again after players have used it, they go back to their
hub saves as they were before the copy, and saves made while it is off are not copied over when it is turned on
again.

```js
const vr = window.VerseRealms;
let revision = null; // the revision you loaded; null when nothing was saved yet

async function loadProgress() {
  if (vr) await vr.ready();
  if (vr && vr.saves.available()) {
    const save = await vr.saves.load('main'); // { slot, data, revision, bytes, updatedAt } or null
    revision = save ? save.revision : null;
    return save ? save.data : null;
  }
  return readBrowserSave(); // your own localStorage code (guests, new tab, local testing)
}

async function saveProgress(data) {
  if (!(vr && vr.saves.available())) return writeBrowserSave(data);
  try {
    const meta = await vr.saves.store('main', data, { expectedRevision: revision });
    revision = meta.revision;
  } catch (err) {
    if (err.code === 'save_conflict') {
      // Saved somewhere else since you loaded (err.revision is the newer one): load it and let the player choose.
    } else {
      // Not saved (err.message says why). Keep playing and try again at the next checkpoint.
    }
  }
}
// Also available: vr.saves.list() -> [{ slot, revision, bytes, updatedAt }], vr.saves.remove('main').
```

MUST:

- Save at checkpoints (end of a level, opening the menu, leaving), not every frame or every second. The hub
  accepts at most 120 save requests per player per minute for each game.
- Store plain JSON only (objects, arrays, strings, numbers, `true`, `false`, `null`). Put a format number in it
  (`{ "format": 2, ... }`) and upgrade older saves when you load them. Never use `__proto__` as a key, or a
  `constructor` key holding `prototype` (for example from names players type): the backend's store refuses such a
  save with `invalid`.
- Keep the game running when a save fails (no connection, signed out, too large), and say quietly that it was not
  saved.
- Treat a missing save as a new game: players can remove a game's saves in their Settings at any time.
- Never use saves for rewards, rankings or anything other players see. The player's browser writes them, so a
  player can change them. Rewards go through L2.

SHOULD: pass `expectedRevision` (the revision you loaded, or `null` when there was none) so a save from another
device is never overwritten by mistake. Without it, the last write wins.

Error codes (`err.code`): `not_in_hub`, `not_signed_in`, `save_conflict` (`err.revision` is the current revision,
`null` if the slot is empty), `save_too_large`, `save_slots_full`, `rate_limited`, `timeout`, `network_error`,
`invalid_request`, `invalid` (this data can't be saved as it is; sending it again won't help),
`backend_unavailable` (the save service can't be reached or isn't ready for your game right now) and
`account_unavailable` (this player's account can't use cloud saves; nothing your game can fix).

`rate_limited`, `timeout`, `network_error` and `backend_unavailable` are temporary: nothing was saved (or loaded),
so keep playing and try again at the next checkpoint. An error is never an empty slot: don't start a new game or
overwrite a save because a load failed.

### L1 in a connected game (your server)

1. The player presses Play on the hub, and the hub sends them to your approved address with
   `?vr_code=<one-time code>`. The code expires after 2 minutes and works once, for your game only.
2. Your **server** exchanges it:

```js
// Node 18+, server side only. Keep the API key in an environment variable such as VR_API_KEY.
const res = await fetch('https://biblized.com/api/v1/integration/launch/exchange', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.VR_API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ code }),
});
if (!res.ok) throw new Error('VerseRealms sign-in failed'); // 400 code_invalid: expired, used or another game
const { gameUserId, displayName, avatar } = await res.json();
// Start your own session for gameUserId, then remove vr_code from the address bar (history.replaceState).
```

3. Later look-ups for a player who has launched your game: `GET /api/v1/integration/players/<gameUserId>` and
   `GET /api/v1/integration/players/<gameUserId>/avatar`.

API keys (`vrk_<id>.<secret>`) come from the operator, are shown once, and can be revoked. Never commit them. The
limit is 600 requests per minute per game.

4. Cloud saves from your server (L1 and up), with the same slots, limits and rules as the SDK:

| Request | Answer |
| --- | --- |
| `GET /api/v1/integration/players/<gameUserId>/saves` | `{ "saves": [{ "slot", "revision", "bytes", "updatedAt" }] }` |
| `GET /api/v1/integration/players/<gameUserId>/saves/<slot>` | `{ "save": { "slot", "data", "revision", "bytes", "updatedAt" } }`, or `{ "save": null }` |
| `PUT /api/v1/integration/players/<gameUserId>/saves/<slot>` with `{ "data": ..., "expectedRevision": 3 }` | `{ "save": { "slot", "revision", "bytes", "updatedAt" } }` |
| `DELETE /api/v1/integration/players/<gameUserId>/saves/<slot>` | `{ "removed": true }` |

`expectedRevision` is optional: a number replaces only that revision, `null` only creates an empty slot, and
leaving it out overwrites. A mismatch answers 409 with `{ "error": { "code": "save_conflict", "revision": <current
or null> } }`.

### L2 progress and achievements (your server)

Every event has these fields:

| Field | Rule |
| --- | --- |
| `eventId` | 8 to 100 characters from `A-Z a-z 0-9 _ . : -`, unique per event. Sending the same `eventId` again returns the first result and never applies twice. |
| `gameUserId` | From the exchange: `gu_` plus 32 hex characters |
| `occurredAt` | ISO 8601 with time zone, within the last 30 days and not in the future |
| `schemaVersion` | `1` |

`POST https://biblized.com/api/v1/integration/progress`

```json
{ "eventId": "progress:run-81f2", "gameUserId": "gu_...", "occurredAt": "2026-11-05T10:00:00Z", "schemaVersion": 1,
  "status": "completed", "summary": { "bestScore": 3, "chapter": "Genesis 1" } }
```

`status` is `in_progress` or `completed`. `summary` has at most 20 keys (`[a-zA-Z][a-zA-Z0-9_]{0,31}`); values are
strings (at most 100 characters), numbers or booleans; at most 2 KB in total. The hub stores only this summary,
never your save file.

`POST https://biblized.com/api/v1/integration/achievements`

```json
{ "eventId": "ach:gu_...:chapter_one_clear", "gameUserId": "gu_...", "occurredAt": "2026-11-05T10:00:00Z",
  "schemaVersion": 1, "achievementKey": "chapter_one_clear" }
```

The response `status` is `awarded` (first time; XP and DN granted), `already_awarded` (nothing granted) or
`rejected` (the key is not defined or is disabled). Use one fixed `eventId` per player and milestone, as above, so
retries are safe.

Errors always look like `{ "error": { "code": "...", "message": "..." } }`, with HTTP 400 (invalid), 401 (bad API
key), 403 (level too low, game disabled or feature disabled), 404 (unknown player), 409 (save conflict, all save
slots used), 413 (save too large) or 429 (too many requests).

### Games on the VerseRealms backend

Some games sign players in through the **VerseRealms backend**, a separate VerseRealms service, instead of the hub
frame: a web game on its own site, a game server that checks launches itself, or a desktop game. The hub still
owns the player's account; the backend gives your game a session for that player. The operator turns this on for
your game and gives you its **game key** and the backend address. In your README, list the origin of your web game
or the launch address of your server, so the operator can register it in the backend.

| Mode | For | What your game receives |
| --- | --- | --- |
| Web game ticket | External link, or connected game at L0 | Play opens your address with `?vr_ticket=<ticket>` |
| Signed launch | Your own game server | Play opens the launch address registered for your game, with a signed token (for example `https://<your server>/launch?token=...`) |
| Desktop link page | Desktop game | The player links the game in the browser and the ticket comes back to the game |

**Web game ticket.** Read `vr_ticket` from the address (the backend JS SDK's `readLaunchTicketFromUrl()` does this),
remove it from the address bar (`history.replaceState`), and exchange it at
`POST <backend>/v1/games/<game-key>/auth/exchange` from your registered origin.

**Signed launch.** Your server checks the token with the backend before it starts a session. The launch address
must have the same origin (scheme, host and port) as your game's address in the hub, or the hub opens your plain
address instead.

**Desktop link page.**

1. Create a PKCE verifier (RFC 7636 S256; the backend C# SDK has `Pkce.Create()`) and keep it in memory.
2. Open this address in the player's system browser. `<slug>` is your game's slug on the hub (as in
   `https://biblized.com/games/<slug>`); leave out the optional parameters you don't use.

```
https://biblized.com/link/<slug>?code_challenge=<challenge>&code_challenge_method=S256&state=<state>&redirect_uri=<loopback address>
```

| Parameter | Rule |
| --- | --- |
| `code_challenge` | Required. base64url(sha256(verifier)), always 43 characters |
| `code_challenge_method` | Required. `S256` |
| `state` | Optional. 1 to 64 characters from `A-Z a-z 0-9 . _ ~ -`. It comes back unchanged: check that it matches. |
| `redirect_uri` | Optional. `http://127.0.0.1:<port>/<path>` or `http://[::1]:<port>/<path>` on the player's computer, at most 100 characters, with no `?` or `#` |

3. The player signs in if needed and presses **Link**. The ticket reaches your game in one of three ways:
   - With `redirect_uri`: a **Send the code** button opens `<redirect_uri>?ticket=vrt_...&state=...` in a new tab.
     Listen on that port until the player has finished.
   - Without it: an **Open** button opens `verserealms-<game-key>://launch?ticket=vrt_...&state=...`. Your installer
     registers this address in Windows.
   - Always: the page shows the ticket with a **Copy** button. Also offer a box where the player can paste it.
4. Exchange the ticket with the verifier at `POST <backend>/v1/games/<game-key>/auth/exchange`, with
   `{ "ticket": "vrt_...", "codeVerifier": "<verifier>" }`. The answer is a game session (`vrp_...`).

MUST:

- A ticket works **once**, for about **2 minutes**, and only for your game. Exchange it at once, and never log,
  store or show it afterwards.
- Your game still starts without a ticket. Guests, and players whose sign-in is unavailable, get your plain
  address; a desktop game plays offline until it is linked.
- Hosted static builds inside the hub don't use backend tickets. They keep the hub SDK and cloud saves above,
  unchanged. Started by the VerseRealms launcher, they sign in as described below.
- Connected games at L1/L2 keep the hub's launch code (`vr_code`) and integration API; backend tickets are for
  external links and connected games at L0.

Saves: a game launched with a backend ticket saves in the backend (the backend SDK's saves, same slots, limits and
`expectedRevision` rules as the hub's). When the operator keeps your game's cloud saves on the backend ("One save
store" above), the hub's game window uses that same store, so the player has one save everywhere. Otherwise the
hub's cloud saves and the backend's saves are **two separate stores** that don't sync: ask the operator which one
your game uses.

#### Started by the VerseRealms launcher

The VerseRealms launcher (in development) is a desktop program that signs the player in once, installs your game
and starts it. Your game stays its own program; the launcher only hands it a one-time ticket ("launcher launch
profile 1" of the backend). The ticket is always bound to a PKCE challenge your game makes, so only your game can
use it.

- **Web games** (installed web packages): the launcher serves your build on a **fixed address**,
  `http://localhost:<port>` (the operator assigns the port, for example 5173, and registers that origin in the
  backend), and opens it with `?vr_launcher=1`.
  Call the backend JS SDK's `signInViaLauncher(vr)`: it makes the PKCE pair, asks the launcher for a ticket at
  `POST /__verserealms/launch-ticket` on your own origin (`{ "protocol": 1, "gameKey", "codeChallenge" }` in;
  `{ "protocol": 1, "ticket", "expiresAt" }` or `{ "protocol": 1, "offline": true, "reason" }` out) and exchanges
  the ticket. Only the result `signed_in` turns on cloud features; `offline`, `no_launcher` and `failed` mean "play
  on local saves". Without `?vr_launcher=1` the helper does nothing. Outside the hub frame the hub SDK reports
  `connected: false`, so use the backend SDK's saves there, with the same slot names as in the hub ("One save
  store" above).
- **Native programs** (for example Bible RPG): the launcher starts the game with
  `--vr-launcher stdio --vr-api <backend address> --vr-game <game key> --vr-protocol 1` and connects its standard
  input and output. The game writes the line `VRLAUNCH/1 CHALLENGE <challenge>` and reads one of
  `VRLAUNCH/1 TICKET <ticket>`, `VRLAUNCH/1 OFFLINE <reason>` or `VRLAUNCH/1 ERROR <code>`; every other line is
  ignored in both directions. Wait at most 20 seconds, then play offline. The backend C# SDK does this:
  `LauncherLaunch.TryParse(args)` (null when not started by the launcher) and
  `LauncherLaunch.SignInAsync(client, Console.In, Console.Out)`, off the main thread.

MUST:

- Never put a ticket or a PKCE verifier on a command line (other programs can read it). Keep the verifier in
  memory, and never log either of them.
- Keep your fixed port. The address (`localhost`, never `127.0.0.1`, plus the port) is your game's origin and keys
  its local saves: another port would make them seem lost. If the port is busy, the launcher tells the player; it
  never picks another one.
- Start without a ticket too. A game started offline or by itself runs on its local saves; that is normal, not an
  error. Show at most a quiet "offline" badge, never a problem to fix.
- Never report a cloud save that didn't happen. While offline, local saves stay the primary copy; on the next online
  start, reconcile with `expectedRevision` and settle a `save_conflict` with your own rule (newest wins, or ask the
  player), never by silently overwriting the newer save.

## 8. Handing in your game

You don't publish on VerseRealms yourself. You hand the game to the operator, who reviews and tests it and, with
your consent, publishes it.

Send one folder or zip named `<game-slug>-<version>`, for example `scripture-reclaim-1.2.0`:

```
scripture-reclaim-1.2.0/
  build/          the production build, index.html at the top (static games)
  source/         a source snapshot, or a repository link in README.md
  media/
    cover.png     16:9, at least 1280x720
    screenshot-1.png ... up to 6
  README.md
  RIGHTS.md
```

Images: PNG, JPEG or WebP (no SVG), at most 3 MB each, with no text cut off at the edges.

**README.md** contains:

- Title, a one-sentence description and a longer description.
- Category, one of: Bible Quiz, Strategy & Battle, RPG & Adventure, Scripture Memory, Typing, Handwriting, Personality, Puzzle, Other. Plus tags.
- Creator name as it should appear (first name, team or studio).
- Devices (Desktop, Tablet, Phone) and controls (Keyboard, Mouse, Touch, Stylus, Gamepad), with the full key list.
- Content notes (section 2), the Bible translation used and the source of the Scripture data file (section 3).
- How to run it locally, the exact build command (for example `npm run build` to `dist/`), and dependencies with
  versions.
- Names (never values) of environment variables, any extra sandbox permissions (section 5) and every network
  call.
- `Follows VerseRealms Game Developer Guide v<version>`, and which AI tools helped and for what.
- Connected games: the https address and database setup notes.

**RIGHTS.md** names who made the code, art, music, sound, fonts and text, with the license and a link for
anything you didn't make (for example CC BY 4.0 for a sound effect, OFL for a font). For AI-generated assets,
name the tool and check that its terms allow this use. Then:

```
Title: <game>        Version: <x.y.z>
Creators and roles: <names or team name as it should appear>
Third-party assets and licenses: <list with links>
I/we confirm we have the right to share this game and its assets, and we agree that the VerseRealms operator may
publish it on VerseRealms under the creator name above. We can ask to have it removed at any time.
Signed: <name, date>        Parent/guardian (if required): <name, date>
```

**Updates:** send a new package with a higher version number and a short "what changed" list. The operator
reviews it as a new release; the previous version stays available for an instant rollback. Follow "Patching a
released game" below for every update.

### Patching a released game

Once players have your game, it lives in several places at once: the hub's game window, the VerseRealms launcher
(which installs a copy on the player's PC and keeps playing it offline), ticket launches from the backend, and
sometimes your own server. An update reaches each of them differently, and players' saves stay behind on their
devices. These rules keep a patch from losing progress or breaking sign-in.

How an update reaches players:

- **Hub web and launcher web packages:** the operator activates your new release. The hub serves it at once; the
  launcher sees it at its next check (at start and every few hours) and installs it **only when the player presses
  Update**, never while the game is running. Players may stay on an older release for a long time, and they can
  play it offline indefinitely.
- **Rollback:** the operator can re-activate an older release at any time, and the launcher installs it like an
  update. Your older build will then meet saves written by the newer one.
- **Desktop programs:** your own installer delivers the update. The player pointed the launcher at your program
  once ("Locate program").
- **Games with a server** (connected, signed or backend web ticket): you redeploy the server, and every player gets
  it at once.

MUST, for every game:

- **Never lose a save.** Read every save format you ever wrote. Upgrade an older save when you load it, and keep a
  copy of the old one until the upgraded one is written. An unknown or newer format is left untouched (show
  "this save needs a newer version"), never reset to a blank profile. The format number inside the save data is
  the one that counts; a backend save's `formatVersion` is only a hint.
- **Keep your storage identity.** These are where your players' saves live; changing any of them makes saves look
  lost: the game slug and backend game key, the launcher port and its `localhost` origin, your storage key names,
  IndexedDB database names, and the cloud save slot names. Never lower the version you pass to `indexedDB.open`
  (an older release would fail to open the database after a rollback). Ask the operator before changing any of
  them; it needs a migration plan.
- **Prefix every storage key with your game** (`wmt.settings`, not `settings` or `sound`) and never call
  `localStorage.clear()`: some origins hold more than one game (for example a demo site), and other code may share
  your storage.
- **Stay compatible both ways.** A new release must still work with the current hub SDK and backend contract
  (both only add fields; ignore fields you don't know), and an older release still installed on players' PCs must
  keep working after your update. Don't make a server or save change that an older installed release can't read.
- **Bump the version for every package** (`<slug>-<version>`, and the version inside your game). Two different
  builds with the same version can't be told apart in problem reports.
- **Rebuild from a clean folder.** Delete the old build output first, so files removed from the game don't linger
  in the new release. Don't ship old entry scripts, unused images or source PNGs next to their WebP copies.

MUST, for web builds (hub and launcher):

- **No service worker, Cache Storage or offline copy of your game's own files.** Your origin stays the same from one
  release to the next, so a service worker would keep serving the old build after an update. The hub and the
  launcher already handle caching and offline play.
- Follow the path rules in section 5 (relative paths, `document.baseURI`, no history-API routing, exact
  case). Test the release both from a subfolder (section 9) and at the root of `http://localhost:<port>/`.
- In the launcher your game is a window of its own, not inside the hub frame: the hub SDK reports
  `connected: false`, `exit()` opens the hub in the player's browser, links that open new windows go to the browser,
  downloads (for example "save to file") are blocked, and only sound autoplay is allowed. Keep drawing your own
  dialogs and keep a quiet start (section 6). Share links must point to your game's public page on the hub, never
  to `location.origin` (that is `localhost` in the launcher).
- **Signed-in sessions expire** (the backend's session lasts about an hour). On a `401`, fall back to local saves
  and say so quietly; try to sign in again at most once per start. Keep the session in memory only, never in
  `localStorage`.

MUST, for desktop programs (launcher launch profile 1):

- The launcher may quit while your game runs: its pipes close. A failed write to standard output must never crash
  or block the game (wrap the hand-over in `try`/`catch`; the backend C# SDK treats a closed input as offline).
- Standard error is discarded: log to a file. Your working folder is the program's folder. Never print your own
  lines that start with `VRLAUNCH/1 `, never echo or log the `TICKET` line, and don't start helper programs that
  inherit the launcher's pipes.
- Keep the program's file name and install folder from one version to the next, or players have to locate it
  again.

MUST, for games with their own server:

- Tickets and signed launch tokens arrive in the address (`?vr_ticket=`, `/launch?token=`). Remove them from the
  address after use, and make sure your hosting doesn't keep query strings in its access logs.
- Keep the server's address and origin stable: they are registered in the backend, and browser progress is tied
  to them.
- Keep your own sign-in limit per visitor below the backend's limits (section 7), so one player retrying can't block
  the others.

Coordinate with the operator **before** the release goes live:

- A new or changed origin or port, launch address, capability (saves, milestones) or Content-Security-Policy needs
  the operator to update the hub and the backend first. Otherwise players get `origin_not_allowed` or "VerseRealms
  is not available" on launch.
- Changes to the backend itself (new endpoints, new data) follow the backend's change-request process and its
  evolution policy (`Backends-BibleGames/docs/09_EVOLUTION_AND_CONTRACT_POLICY.md`): `/v1` only grows, and a
  breaking change gets a new version and a long overlap.
- Write in the "what changed" list whether the release changes saves, storage, ports, the backend address or
  capabilities. The operator uses it to decide whether launcher players need a warning.

## 9. Checklist before you hand it in

- [ ] Production build served over HTTP from a subfolder works: copy the build into `test/r/abc/`, run
      `npx serve test`, open `http://localhost:3000/r/abc/` and play from start to finish.
- [ ] No errors in the browser console (F12); all images and sounds load; saving and loading work.
- [ ] With cloud saves: the game also starts, plays and saves in the browser as a guest and in a new tab, and a
      failed cloud save doesn't stop it (section 7).
- [ ] On the VerseRealms backend: the game also starts without a ticket, exchanges each ticket once and keeps it
      out of logs; a desktop game checks `state` and keeps its verifier private (section 7).
- [ ] Started by the launcher (if it installs your game): it signs in through the launcher, keeps its fixed port, and
      starts and plays offline without one (section 7). It also works when opened at the root of
      `http://localhost:<port>/`, and reloading any screen doesn't give "not found" (section 5).
- [ ] An update: it reads saves from every earlier version and leaves newer ones untouched, keeps its slug, port,
      storage keys and slot names, has no service worker, and has a higher version number (section 8, "Patching a
      released game").
- [ ] Works in a small window, a large window and fullscreen, and on every device listed in the README.
- [ ] Title screen, menu, How to play, sound on/off and quiet start (section 6).
- [ ] Every Bible quotation matches the data file and shows its reference and translation (section 3).
- [ ] Content is suitable for ages 13+ and the content notes are accurate (section 2).
- [ ] No requests to other websites, no ads or trackers, no secrets in the build (section 5).
- [ ] README.md and a signed RIGHTS.md are included, with the guide version (section 8).
- [ ] Cover image and screenshots meet the image rules.

## 10. Pending operator decisions

These topics have no rule yet. **Until the operator writes a rule here, don't add them without the operator's
written approval**, and AI assistants must ask before adding them:

- Showing God the Father, Jesus or the Holy Spirit as a visible or playable character, or giving them words that
  are not Scripture.
- Combat and violence. Until a rule exists: no blood, gore or cruelty; defeated enemies vanish, flee or are
  captured; combat against human characters needs approval.

## Changelog

- **1.4** (2026-11-21): "Patching a released game" in section 8 (how an update reaches hub, launcher, desktop and
  server players; never lose a save, keep your storage identity, prefixed storage keys, both-way compatibility,
  clean rebuilds, no service workers, launcher window behaviour, session expiry, desktop pipe rules, server
  tokens and logs, what to agree with the operator first). Section 5: the same build at `/r/<token>/` and at the
  launcher's `http://localhost:<port>/`, no history-API routing, case-sensitive and Windows-safe file names,
  reserved `/_sdk/` and `/__verserealms/` paths, and the VerseRealms backend address as the one allowed network
  exception. Section 7: the hub's and the backend's `gameUserId` differ. Checklist items for the launcher root and
  for updates.
- **1.3** (2026-11-17): One cloud save store per game when the operator keeps its saves on the VerseRealms backend
  (shared by the hub's game window, the launcher and ticket launches), the `backend_unavailable`,
  `account_unavailable` and `invalid` save errors, keys a cloud save can't use, no `formatVersion` on saves made
  through the hub, and "Started by the VerseRealms launcher" (launcher launch profile 1: `?vr_launcher=1`, the
  `VRLAUNCH/1` handshake, fixed ports, offline rules, the backend SDK's saves with the same slot names).
- **1.2** (2026-11-16): Games on the VerseRealms backend: the web game ticket (`?vr_ticket=`), the signed launch
  for game servers and the desktop link page contract, plus a note on desktop games in section 4.
- **1.1** (2026-11-09): Cloud saves for signed-in players (SDK and connected-game API), the SDK address for
  external-link games, and the framing rule for external links shown inside the hub.
- **1.0** (2026-11-08): First version. Combines the student submission guide, the integration guide and the
  content rules, and adds the shared player interface and the Scripture data rules.
