تخطَّ إلى المحتوى

Platforms: PC today, consoles and phones later

هذا المحتوى غير متوفر بلغتك بعد.

We build for Windows PC first. But the architecture is ready for consoles, phones and other devices, so that anyone can add them later without rewriting the project. This page explains how.

Status: only the PC path is built. Everything else on this page is a designed route that is waiting for a contributor. See IDEAS.md (“Other devices”) for how each route was judged.

Every setup is made of the same three roles. Only the devices change.

Role What it does Today (PC) Later, on other devices
Hub host Runs the hub: the rules, question choice, progress The desktop app on the PC A PC or home server next to a console; a phone app; a small server
Game integration Reports game events and applies rewards Hollow Knight mod (C#) A Minecraft Bedrock behavior pack on a dedicated server; a “manual” button on a phone
Surface Shows questions and takes answers Electron overlay A phone page; a TV app; the game’s own UI (in-game forms)

They talk with the same protocol over WebSocket, wherever they run.

  1. Surfaces describe themselves. A screen says what it is and how the player answers (surface: { kind: "phone", input: ["touch"] }). The hub can adapt text length, hints and audio. Older screens that send nothing still work.
  2. Games can show questions in their own UI. A game integration that declares capabilities.surface receives challenge, feedback and reward messages and may send answer. This is how a console player answers inside Minecraft Bedrock, or how a future Hollow Knight in-game card works. Tested in packages/hub/src/server.test.ts.
  3. The core runs anywhere. @game-learning/core, the protocol messages and the content schemas use no Node-only APIs, so they can run in a phone app, a browser or a game server. A test (packages/core/src/portable.test.ts) fails if someone adds Node-only code there. File access is separate (@game-learning/content/fs), and so is the discovery file (@game-learning/protocol/discovery).
  4. The hub’s network address is a setting (host), kept on this computer only by default.

A. Phone companion (any game, any console) — easiest

Section titled “A. Phone companion (any game, any console) — easiest”
  • Surface: a web page on the phone, served by the hub.
  • Game integration: none, or a “manual” one: the same page also connects as a game peer that only sends player.died when the player taps “I died” (or on a timer). No effects.
  • Needs: LAN pairing (below).

B. Consoles and phones through Minecraft Bedrock — real game events

Section titled “B. Consoles and phones through Minecraft Bedrock — real game events”
  • Players on Xbox, PlayStation, Switch, iOS and Android join a Bedrock Dedicated Server running on the PC.
  • A behavior pack (Bedrock Script API) on that server is the game integration: it sends player.died, applies rewards, and declares capabilities.surface: { kind: "in-game", input: ["controller", "touch"] } to show questions as in-game forms (@minecraft/server-ui).
  • The server runs next to the hub, so it can connect to 127.0.0.1 — no LAN pairing needed.
  • A native or React Native app draws over games (Android allows overlays) and acts as a surface; with route A’s manual triggers, or later screen detection.
  • The core and protocol packages can run inside the app’s JavaScript; the hub host could be the phone itself or a PC.
  • iOS does not allow drawing over other apps. Use route A (phone companion) or route B (Minecraft).

LAN pairing (built: phone as an answer pad)

Section titled “LAN pairing (built: phone as an answer pad)”

Tray icon → Phone as answer pad → Connect a phone… (packages/hub/src/phone-gateway.ts):

  1. The app starts a separate phone gateway on the home network (port 47475). It stays off until a phone is connected for the first time; after that it starts with the app.
  2. A QR code holds the address and a one-time pairing code (valid 5 minutes). The phone exchanges it for its own device token. The hub’s main token never leaves the PC: phones even get their own audio links.
  3. Phones are screens only: they see and answer questions, and cannot act as a game (so they cannot fake events or rewards).
  4. Only private network addresses are accepted (home Wi-Fi). Forget all phones removes every device token and stops the gateway.
  5. The phone page is plain HTML served by the gateway: no app to install. It supports every question kind, Arabic (right to left) and audio.

Plain HTTP is fine on a home network; do not use it on public Wi-Fi. The main hub still listens on 127.0.0.1 only.

  1. Pick the route above, and open an issue that links this page.
  2. Reuse @game-learning/protocol for message shapes (TypeScript) or the JSON Schema files in packages/protocol/schema/ (other languages).
  3. Declare only what you really support (events, effects, surface). Rewards still count only after the game confirms them (ADR 0004).
  4. Follow PRIVACY.md: children’s data stays on their devices.
  5. Add your integration under integrations/ or your surface under apps/, with a README.