# Build a game for the arcade

You are building a small game for the arcade of Ibadan Life (https://ibadanlife.app), a life-simulation game set in Ibadan, Nigeria. The arcade can hold games made by developers outside the city. Build one, in this folder.

Ask me what the game should be if I have not said; if you cannot ask, build the first of these. Good first games fit one screen and one finger: a tapping game, a memory game, a reaction test, a number puzzle.

THE FRAME. Your app is ONE HTML file, at most 200,000 characters (counted as JavaScript counts them, the file's length as a string), with its CSS in <style> and its JavaScript in <script>. It runs inside the player's phone in a locked frame:
- No network at all: no fetch, XMLHttpRequest, WebSocket, no scripts, stylesheets, fonts or images from any address. Pictures go in as data: URLs; the device's own fonts and emoji are fine, though emoji look different from phone to phone.
- No cookies, no localStorage or sessionStorage, no forms that submit (an <input> or a <button> outside a <form> is fine), no new windows, and it cannot move the page. It cannot send anything out. The only way to reach the game is the bridge below.
- Design for a screen from 340 px wide on a phone to about 900 px wide on a computer, and about 600 px tall. Lay it out so it works at both. The arcade shows the game's name, its developer, its board and a way back outside your frame, so a back button of your own is not needed. For a canvas game keep one fixed playing field and scale it to fit, centred; do not widen the field on a wide screen.
- Plain HTML, CSS and JavaScript only. No framework, no build step, no modules, no imports.

THE BRIDGE. The arcade adds a global object, ibadan, before your code runs. Every call returns a promise; a refusal rejects it with an Error whose message you can show. Use only these calls. There are no others.
- ibadan.score(n) reports a score: a whole number from 0 to 1,000,000,000. At most one every 20 seconds, counted from the last score you sent (not from the start of the round); a second one sooner is rejected, so send it once, when a round ends. If that is less than 20 seconds after your last one, show the player their score yourself and say it was not sent; do not queue it. The arcade's answer is the last word: if it rejects, show its message. If your rounds can be very short, a short pause before the next round starts keeps most scores on the board. It resolves with { best }: this player's best so far, counting the one just sent. The board shows only the number and higher is better, so if fewer moves or less time is better in your game, turn it into a number that rises, and tell the player how. The arcade keeps the best and shows the ten best in Ibadan beside your game. A score wins nothing in the game: no money and no rep. You are never told another player's name or score.
- ibadan.player() resolves with { name, id }: the player's username and an id made for your game alone. The arcade asks the player once; if they say no, it rejects, and your game must still be playable. You are never told where a player is.
- ibadan.storage.get(key) resolves with a string or null. ibadan.storage.set(key, value) saves a string for this player: keys up to 40 characters, values up to 2,000, 20 keys per player. Use it for settings or progress.
- ibadan.toast(text) shows a short message for 3 seconds; text past 120 characters is cut. ibadan.close() goes back to the arcade. Neither needs a permission.
At most 20 calls in any 10 seconds. A game cannot charge a player. Past a storage limit, set rejects with a message.

WHAT GETS A GAME TURNED DOWN OR TAKEN DOWN. Pretending to be Ibadan Life. Asking for a password. Heavy work that never stops: pause your loop when a round is over. Anything sexual, hateful or cruel: players are adults, and the game is played in the open.

A WORKING EXAMPLE, to copy the shape of:
```html
<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>body{font:17px system-ui;margin:0;padding:16px;background:#12303a;color:#fff8ec;text-align:center}button{width:150px;height:150px;border-radius:50%;border:0;background:#c98a1a;font:700 30px system-ui}</style>
<h2>Yam Tap</h2><button id="yam">0</button><p id="t">Tap to start: ten seconds</p><p id="out"></p>
<script>
  var n = 0, left = 0, timer = null, yam = document.getElementById("yam"), t = document.getElementById("t"), out = document.getElementById("out");
  yam.onclick = function () {
    if (left <= 0 && timer === null) { n = 0; left = 10; out.textContent = ""; t.textContent = "10 s";
      timer = setInterval(function () { left--; t.textContent = left + " s";
        if (left <= 0) { clearInterval(timer); timer = null; t.textContent = "Time. You tapped " + n + ".";
          ibadan.score(n).then(function (r) { out.textContent = "Your best is " + r.best + "."; }).catch(function (e) { out.textContent = e.message; }); } }, 1000); }
    if (left > 0) { n++; yam.textContent = n; }
  };
</script>
```

WHAT TO WRITE. Two files (the second writes a third when it runs):
1. app.html: the game. Handle every rejected promise: show the message, never leave a blank screen.
2. check.mjs: exactly the script below. Then run "node check.mjs" and fix app.html until its line starts with "ok:". It looks for these words anywhere in the file, comments and visible text included, so keep them out: fetch, XMLHttpRequest, WebSocket, EventSource, sendBeacon, importScripts, localStorage, sessionStorage, indexedDB, document.cookie. If you cannot open a browser, say so: "ok:" means the file may be submitted, not that you saw it run. It also writes harness.html, which runs the game in a frame like the arcade's, 600 px tall, with a stand-in for the bridge that keeps the score rules; open that in a browser to play it.

```js
// check.mjs: run with  node check.mjs  beside app.html. It prints what the store would turn down, and writes
// harness.html: your app in the same kind of locked frame, with a stand-in for the phone's bridge. Open it in a browser.
import { readFileSync, writeFileSync } from "node:fs";
const src = readFileSync("app.html", "utf8"), bad = [];
if (src.length > 200000) bad.push("over 200000 characters: " + src.length);
if (/<script[^>]+\bsrc\s*=/i.test(src)) bad.push("a script loaded from another file");
if (/<link[^>]+\bhref\s*=\s*["']?(?!data:)/i.test(src)) bad.push("a linked stylesheet or font");
if (/\b(?:src|href|poster)\s*=\s*["']?\s*(?:https?:)?\/\//i.test(src) || /url\(\s*["']?\s*(?:https?:)?\/\//i.test(src)) bad.push("something loaded from another address");
if (/\b(?:fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon|importScripts)\b/.test(src)) bad.push("a network call");
if (/\b(?:localStorage|sessionStorage|indexedDB|document\.cookie)\b/.test(src)) bad.push("the browser's own storage");
if (/<form\b/i.test(src)) bad.push("a <form>");
console.log(bad.length ? "WOULD BE TURNED DOWN: " + bad.join("; ") : "ok: " + src.length + " characters, one file, no network");
const MOCK = '<script>(function(){var kv={},best=0,last=0,ok=function(v){return new Promise(function(y){setTimeout(function(){y(v)},60)})};window.ibadan={player:function(){return ok({name:"ade",id:"0123456789abcdef0123456789abcdef"})},storage:{get:function(k){return ok(k in kv?kv[k]:null)},set:function(k,v){kv[k]=String(v);return ok()}},score:function(n){if(!Number.isInteger(n)||n<0||n>1e9)return Promise.reject(new Error("A score is a whole number from 0 to 1,000,000,000."));if(Date.now()-last<20000)return Promise.reject(new Error("Too soon after the last score. Try again in a moment."));last=Date.now();best=Math.max(best,n);return ok({best:best})},toast:function(t){console.log("toast:",t);return ok()},close:function(){console.log("close");return ok()}};})();<\/script>';
const policy = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; font-src data:; media-src data:; connect-src 'none'; form-action 'none'";
const page = '<meta http-equiv="Content-Security-Policy" content="' + policy + '">' + MOCK + src;
// The real frame is sandbox="allow-scripts" only. allow-modals is added HERE alone, for a stand-in that asks a question with confirm().
writeFileSync("harness.html", '<!doctype html><title>harness</title><body style="margin:0;background:#222;display:grid;place-items:center;height:100vh"><iframe sandbox="allow-scripts allow-modals" style="width:min(900px,96vw);height:600px;border:0;border-radius:16px;background:#fff" srcdoc="' + page.replace(/&/g, "&amp;").replace(/"/g, "&quot;") + '"></iframe>');
process.exit(bad.length ? 1 : 0);
```

HOW IT IS SUBMITTED. Through an Arena54 developer account at developers.arena54.com, as kind "game" with the permissions it uses and no others, from "player", "storage" and "score". Only app.html is submitted. Ibadan Life's staff read and play every game before it is listed.

When you finish, tell me: how the game is played, which permissions it uses, and what check.mjs printed.
