firstbyte 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ /* A small zip reader: stored and deflated entries, no zip64. Enough for a game build. And a writer, for the zips we hand out. */
2
+ import { inflateRawSync, deflateRawSync, crc32 } from 'node:zlib';
3
+
4
+ const EOCD = 0x06054b50;
5
+ const CENTRAL = 0x02014b50;
6
+ const LOCAL = 0x04034b50;
7
+
8
+ export class ZipError extends Error {}
9
+
10
+ /* The central directory, without unpacking anything. */
11
+ function entries(buf) {
12
+ const end = findEnd(buf);
13
+ const count = buf.readUInt16LE(end + 10);
14
+ const dirOffset = buf.readUInt32LE(end + 16);
15
+ if (count === 0xffff || dirOffset === 0xffffffff) {
16
+ throw new ZipError('This zip uses zip64, which the checker does not read. Zip it again with a normal zip tool.');
17
+ }
18
+ const out = [];
19
+ let p = dirOffset;
20
+ for (let i = 0; i < count; i++) {
21
+ if (p + 46 > buf.length || buf.readUInt32LE(p) !== CENTRAL) throw new ZipError('The zip is damaged: its file list is broken.');
22
+ const flags = buf.readUInt16LE(p + 8);
23
+ const nameLen = buf.readUInt16LE(p + 28);
24
+ const extraLen = buf.readUInt16LE(p + 30);
25
+ const commentLen = buf.readUInt16LE(p + 32);
26
+ const name = buf.toString(flags & 0x800 ? 'utf8' : 'latin1', p + 46, p + 46 + nameLen);
27
+ out.push({
28
+ name,
29
+ flags,
30
+ method: buf.readUInt16LE(p + 10),
31
+ compressed: buf.readUInt32LE(p + 20),
32
+ size: buf.readUInt32LE(p + 24),
33
+ mode: buf.readUInt32LE(p + 38) >>> 16,
34
+ local: buf.readUInt32LE(p + 42),
35
+ dir: name.endsWith('/'),
36
+ });
37
+ p += 46 + nameLen + extraLen + commentLen;
38
+ }
39
+ return out;
40
+ }
41
+
42
+ export function listZip(buf) {
43
+ return entries(buf).map(({ name, method, compressed, size, dir, mode }) => ({ name, method, compressed, size, dir, mode }));
44
+ }
45
+
46
+ export function readZip(buf) {
47
+ const files = new Map();
48
+ for (const e of entries(buf)) {
49
+ if (e.dir) continue;
50
+ if (e.flags & 1) throw new ZipError(`"${e.name}" is password protected. Zip it again without a password.`);
51
+ files.set(e.name, unpack(buf, e));
52
+ }
53
+ return files;
54
+ }
55
+
56
+ function findEnd(buf) {
57
+ const stop = Math.max(0, buf.length - 22 - 0xffff);
58
+ /* The real end record reaches the end of the file exactly; one hidden inside a comment does not. */
59
+ for (let p = buf.length - 22; p >= stop; p--) {
60
+ if (buf.readUInt32LE(p) === EOCD && p + 22 + buf.readUInt16LE(p + 20) === buf.length) return p;
61
+ }
62
+ throw new ZipError('This is not a zip file, or it is damaged.');
63
+ }
64
+
65
+ function unpack(buf, e) {
66
+ if (e.local + 30 > buf.length || buf.readUInt32LE(e.local) !== LOCAL) throw new ZipError(`The zip is damaged at "${e.name}".`);
67
+ const start = e.local + 30 + buf.readUInt16LE(e.local + 26) + buf.readUInt16LE(e.local + 28);
68
+ const raw = buf.subarray(start, start + e.compressed);
69
+ let out;
70
+ if (e.method === 0) out = Buffer.from(raw);
71
+ /* Never inflated past the size the zip claims: a zip that lies about its size stops there, not at gigabytes. */
72
+ else if (e.method === 8) {
73
+ try { out = inflateRawSync(raw, { maxOutputLength: Math.max(1, e.size) }); } catch { throw new ZipError(`The zip is damaged at "${e.name}": it is not the size the zip says.`); }
74
+ }
75
+ else throw new ZipError(`"${e.name}" uses a compression the checker does not read. Zip it again with a normal zip tool.`);
76
+ if (out.length !== e.size) throw new ZipError(`The zip is damaged at "${e.name}": it is not the size the zip says.`);
77
+ return out;
78
+ }
79
+
80
+ /*
81
+ * Writes a zip of { path: text or bytes }, in the order given, every file deflated. Each entry is
82
+ * dated 1 January 1980 (the earliest a zip can say), so the same files always give the same bytes.
83
+ */
84
+ export function writeZip(files) {
85
+ const DATE = 0x0021;
86
+ const locals = [];
87
+ const centrals = [];
88
+ let offset = 0;
89
+ for (const [name, body] of Object.entries(files)) {
90
+ const data = Buffer.isBuffer(body) ? body : Buffer.from(String(body));
91
+ const packed = deflateRawSync(data, { level: 9 });
92
+ const nameBuf = Buffer.from(name);
93
+ const head = (sig, more) => {
94
+ const b = Buffer.alloc(more);
95
+ b.writeUInt32LE(sig, 0);
96
+ return b;
97
+ };
98
+ /* The fields both records share: version, flags (names are UTF-8), deflate, time, date, crc, sizes, name length. */
99
+ const shared = (b, at) => {
100
+ b.writeUInt16LE(20, at);
101
+ b.writeUInt16LE(0x800, at + 2);
102
+ b.writeUInt16LE(8, at + 4);
103
+ b.writeUInt16LE(0, at + 6);
104
+ b.writeUInt16LE(DATE, at + 8);
105
+ b.writeUInt32LE(crc32(data), at + 10);
106
+ b.writeUInt32LE(packed.length, at + 14);
107
+ b.writeUInt32LE(data.length, at + 18);
108
+ b.writeUInt16LE(nameBuf.length, at + 22);
109
+ };
110
+ const local = head(LOCAL, 30);
111
+ shared(local, 4);
112
+ const central = head(CENTRAL, 46);
113
+ central.writeUInt16LE(20, 4);
114
+ shared(central, 6);
115
+ central.writeUInt32LE(offset, 42);
116
+ locals.push(local, nameBuf, packed);
117
+ centrals.push(central, nameBuf);
118
+ offset += 30 + nameBuf.length + packed.length;
119
+ }
120
+ const dir = Buffer.concat(centrals);
121
+ const count = Object.keys(files).length;
122
+ const end = Buffer.alloc(22);
123
+ end.writeUInt32LE(EOCD, 0);
124
+ end.writeUInt16LE(count, 8);
125
+ end.writeUInt16LE(count, 10);
126
+ end.writeUInt32LE(dir.length, 12);
127
+ end.writeUInt32LE(offset, 16);
128
+ return Buffer.concat([...locals, dir, end]);
129
+ }
@@ -0,0 +1,79 @@
1
+ /* Play sessions to numbers, with the guards that keep them honest. Plain ESM with no Node imports. */
2
+
3
+ export const GUARDS = { capMs: 2 * 60 * 60 * 1000, maxSessionMs: 24 * 60 * 60 * 1000 };
4
+
5
+ const r3 = (x) => Math.round(x * 1000) / 1000;
6
+ const r1 = (x) => Math.round(x * 10) / 10;
7
+ const share = (n, d) => (d ? r3(n / d) : 0);
8
+ const isPlay = (s) => s.played || s.activeMs > 0;
9
+
10
+ function median(list) {
11
+ if (!list.length) return null;
12
+ const a = [...list].sort((x, y) => x - y);
13
+ const m = a.length >> 1;
14
+ return a.length % 2 ? a[m] : Math.round((a[m - 1] + a[m]) / 2);
15
+ }
16
+
17
+ function group(list, keyOf) {
18
+ const m = new Map();
19
+ for (const x of list) {
20
+ const k = keyOf(x);
21
+ if (!m.has(k)) m.set(k, []);
22
+ m.get(k).push(x);
23
+ }
24
+ return m;
25
+ }
26
+
27
+ export function rollup(sessions, { from = null, to = null, capMs = GUARDS.capMs } = {}) {
28
+ let dropped = 0;
29
+ const best = new Map();
30
+ for (const s of sessions) {
31
+ if (!s || !s.game || !s.device || !s.session || !(s.activeMs >= 0) || s.activeMs > GUARDS.maxSessionMs) { dropped++; continue; }
32
+ if ((from && s.day < from) || (to && s.day > to)) continue;
33
+ const had = best.get(s.session);
34
+ if (!had || s.activeMs > had.activeMs) best.set(s.session, s);
35
+ }
36
+ const kept = [...best.values()];
37
+
38
+ /* The cap: one browser, one game, one day. Minutes past it are not counted. */
39
+ const counted = new Map();
40
+ for (const [, list] of group(kept, (s) => `${s.device}|${s.game}|${s.day}`)) {
41
+ let left = capMs;
42
+ for (const s of [...list].sort((a, b) => a.startedAt - b.startedAt || (a.session < b.session ? -1 : 1))) {
43
+ const take = Math.min(s.activeMs, left);
44
+ left -= take;
45
+ counted.set(s.session, take);
46
+ }
47
+ }
48
+
49
+ const games = [];
50
+ for (const [game, list] of group(kept, (s) => s.game)) {
51
+ const plays = list.filter(isPlay);
52
+ const byDevice = group(plays, (s) => s.device);
53
+ const players = byDevice.size;
54
+ const ms = list.reduce((sum, s) => sum + counted.get(s.session), 0);
55
+ games.push({
56
+ game,
57
+ plays: plays.length,
58
+ players,
59
+ minutes: r1(ms / 60_000),
60
+ minutesPerPlayer: players ? r1(ms / 60_000 / players) : 0,
61
+ pastFirstMinute: share([...byDevice.values()].filter((l) => l.some((s) => s.firstMinute)).length, players),
62
+ returning: share([...byDevice.values()].filter((l) => new Set(l.map((s) => s.day)).size >= 2).length, players),
63
+ loadFailures: share(list.filter((s) => s.loadFailed).length, list.length),
64
+ likes: new Set(list.filter((s) => s.liked).map((s) => s.device)).size,
65
+ readyMs: median(list.filter((s) => s.readyMs != null).map((s) => s.readyMs)),
66
+ });
67
+ }
68
+ games.sort((a, b) => b.minutes - a.minutes || (a.game < b.game ? -1 : 1));
69
+
70
+ const devices = group(kept.filter(isPlay), (s) => s.device);
71
+ const site = {
72
+ players: devices.size,
73
+ returning: share([...devices.values()].filter((l) => new Set(l.map((s) => s.day)).size >= 2).length, devices.size),
74
+ gamesPerPlayer: devices.size ? r1([...devices.values()].reduce((sum, l) => sum + new Set(l.map((s) => s.game)).size, 0) / devices.size) : 0,
75
+ secondGame: share([...devices.values()].filter((l) => new Set(l.map((s) => s.game)).size >= 2).length, devices.size),
76
+ };
77
+
78
+ return { games, site, minutes: Object.fromEntries(games.map((g) => [g.game, g.minutes])), dropped };
79
+ }
@@ -0,0 +1,145 @@
1
+ /* The AI brief: the rulebook written out for a coding assistant. Built from rules/Rulebook and the catalog. */
2
+ import { readFileSync } from 'node:fs';
3
+ import { RULES, ALLOWED, LIMITS } from '../Rulebook/Rulebook.js';
4
+ import { needs, shortlist } from '../../catalog/Needs/Needs.js';
5
+ import { rollup } from '../../metrics/Rollup/Rollup.js';
6
+ import { LEVELS, OWN_SHARE } from '../../dev/Levels/Levels.js';
7
+ import { LIMITS as ACH, ICONS } from '../../achievements/Achievements/Achievements.js';
8
+ import { starterFiles, STARTER_URL } from '../Starter/Starter.js';
9
+
10
+ /* The catalog the site shows. The brief lists what it lacks, worked out the same way the site does. */
11
+ export function catalog() {
12
+ return JSON.parse(readFileSync(new URL('../../../site/data/games.json', import.meta.url), 'utf8'));
13
+ }
14
+
15
+ /* Play minutes per game, rolled up from the site's sessions, so the brief weighs kinds as the site does. */
16
+ export function minutes() {
17
+ try {
18
+ return rollup(JSON.parse(readFileSync(new URL('../../../site/data/demo-sessions.json', import.meta.url), 'utf8'))).minutes;
19
+ } catch {
20
+ return undefined;
21
+ }
22
+ }
23
+
24
+ const pkg = { version: '0.1' };
25
+
26
+ export function brief({ wanted = shortlist(needs(catalog(), { minutes: minutes() })) } = {}) {
27
+ const line = (r) => `- [${r.id}] ${r.brief}`;
28
+ const auto = RULES.filter((r) => r.check !== 'person' && !r.optional);
29
+ const optional = RULES.filter((r) => r.optional);
30
+ const person = RULES.filter((r) => r.check === 'person');
31
+ return `# First Byte: what we expect from a game (v${pkg.version})
32
+
33
+ You are helping a developer get a browser game picked for First Byte, a site that
34
+ shows a few new games each week. Check the game against the rules below. If it
35
+ breaks one, name the rule by its id and say how to fix it, before anything else.
36
+
37
+ The developer can run every automatic check themselves, two ways:
38
+
39
+ - On the site: drop the zip at firstbyte.games/developers and press "Just check it". Nothing
40
+ goes to our team until they say so, and the report has a "Copy for my AI" button.
41
+ - On their machine: npx firstbyte check path/to/build.zip
42
+
43
+ Both give PASS or FAIL for each rule id below, with the fix (--json prints a report you can
44
+ read). Aim for no FAIL before the game is sent. LOOK means the checker could not tell: read it.
45
+ The quickest start is the starter game at the end of this page: it already passes every check.
46
+
47
+ ## Ready to send: checked automatically
48
+ ${auto.map(line).join('\n')}
49
+
50
+ ## Optional
51
+ ${optional.map(line).join('\n')}
52
+
53
+ ## Quality review: played by our team
54
+ After a game passes the checks above, our team plays it and grades each of these good,
55
+ needs work, or must fix, with feedback on anything that is not good. Only must fix stops a
56
+ game being picked; needs work is advice. The developer sees every grade and the feedback.
57
+ Help the developer play their own game against each one before sending.
58
+ ${person.map(line).join('\n')}
59
+
60
+ ## Allowed
61
+ ${ALLOWED.map((a) => `- ${a}`).join('\n')}
62
+
63
+ ## The SDK (optional)
64
+ <script src="https://firstbyte.games/sdk.js"></script>
65
+
66
+ - FirstByte.ready() once, when the first frame is on screen
67
+ - FirstByte.playing(true) when a round starts; FirstByte.playing(false) when it ends
68
+ - FirstByte.breakTime() an ad, only while playing(false). Resolves { shown }.
69
+ While playing it is refused and resolves { shown: false }.
70
+ - FirstByte.save(data) progress, anything JSON can store, up to ${LIMITS.saveBytes / 1024 / 1024} MB
71
+ - FirstByte.load() the saved progress, or null
72
+ - FirstByte.score(n) an optional score board
73
+ - FirstByte.achieve(id) an achievement earned, by its id in achievements.json; only the first time is new
74
+ - FirstByte.on(name, fn) 'mute', 'unmute', 'pause' (before an ad), 'resume'
75
+
76
+ Every call works without the site too: on its own the game saves to the browser
77
+ and breakTime() resolves { shown: false } at once, so nothing needs a special case.
78
+
79
+ ## Achievements (optional)
80
+ Two steps. 1: put achievements.json next to index.html:
81
+
82
+ { "achievements": [
83
+ { "id": "first-win", "name": "First win", "about": "Win a round.", "icon": "crown" },
84
+ { "id": "untouched", "name": "Untouched", "about": "Clear a level without a hit.", "secret": true }
85
+ ] }
86
+
87
+ 2: call FirstByte.achieve('first-win') when the player earns it. Calling it again is fine.
88
+
89
+ - Up to ${ACH.most}. An id is lowercase letters, digits and hyphens, up to ${ACH.idChars}; a name up to
90
+ ${ACH.nameChars} letters; "about" up to ${ACH.aboutChars}. Plain words: no links, no < or >.
91
+ - "icon" is optional, one of: ${ICONS.join(', ')}. Pictures are drawn for you.
92
+ - "secret": true shows a question mark until it is earned.
93
+ - npx firstbyte check checks the file (F7) and every unlock while it plays (P9), and says exactly
94
+ what to add or fix.
95
+ Achievements are for players' fun: they never pay, and never count toward a level or a badge.
96
+
97
+ ## Good to know
98
+ - The game plays in a frame on the page: 16:9 on a computer, close to that on a phone, and it
99
+ changes size. Fill the window and scale the picture to fit, as the starter's style.css does.
100
+ - Many players are on phones, with no keyboard. Taps as well as keys reach more of them.
101
+ - Zip the build folder: index.html at the top, or inside the one folder that holds everything.
102
+ - The checker clicks, then presses Space, Enter, the arrow keys, W and D. It listens for a sound
103
+ and looks for FirstByte.playing(true) after the first of them.
104
+
105
+ ## Exporting from an engine
106
+ - Unity: build for Web (WebGL) and zip the build folder (index.html, Build, TemplateData).
107
+ Brotli, Gzip or no compression all work: .br and .gz files are sent the way the browser needs.
108
+ - Godot 4.3 or newer: export for Web with Thread Support off (the default), and name the export index.html.
109
+ - Vite, webpack and the like: make every path relative (Vite: base: './'), then zip dist.
110
+ - Any engine: leave out other sites' SDKs, load nothing from a CDN, and play a sound on the first input.
111
+
112
+ ## What gets a game picked
113
+ Something new: an idea, a look or a feeling we have not seen lately. Polish helps,
114
+ but a polished copy is not picked. Help the developer write one sentence on
115
+ "what's new about it". We read that first.
116
+
117
+ ## Games we want most right now
118
+ Worked out from the games already on the site: the kinds it has fewest of.
119
+ ${wanted.map((w) => `- ${w.level}: ${w.name}`).join('\n')}
120
+
121
+ ## Pay
122
+ - Players who come through your own link (firstbyte.games/games/<id>?by=<you>): you keep ${OWN_SHARE}% of the ad money.
123
+ - Players First Byte brings: you keep a share that grows with your level:
124
+ ${LEVELS.slice(1).map((l) => ` - ${l.name}: ${l.share}%`).join('\n')}
125
+ - Levels come from games picked, clean reviews and players who stay. Raw play counts never raise one,
126
+ and a level is never lost for a quiet spell.
127
+ - Until ads are live, a fixed monthly pool is split by real plays (a minute or more) the same way.
128
+ - Paid monthly, after the ad network pays us; under $25 rolls over to the next month.
129
+ - Developers never pay to be picked.
130
+
131
+ ## A game that passes every check
132
+ Start from this: a whole game in four small files, also at ${STARTER_URL}
133
+ The comments name the rule each line is there for.
134
+ ${Object.entries(starterFiles()).filter(([name]) => name !== 'README.txt').map(([name, text]) => `
135
+ ### ${name}
136
+ \`\`\`
137
+ ${text.trimEnd()}
138
+ \`\`\``).join('\n')}
139
+
140
+ ## Send it
141
+ At firstbyte.games/developers: sign in with an email, drop the zip, give the game's name and
142
+ one sentence on what's new. Nothing else is asked for. The same checks run on it there, the
143
+ report shows in a minute or two, and our team answers within a week.
144
+ `;
145
+ }
@@ -0,0 +1,208 @@
1
+ /*
2
+ * The rulebook. Everything First Byte expects from a game lives here and nowhere else:
3
+ * the checker runs these rules, and the AI brief (site/ai.txt) is written from them.
4
+ * Rule ids are never renumbered or reused. Add a new id instead.
5
+ *
6
+ * check: 'files' checked by reading the build } Ready to send: the checker, which the
7
+ * 'play' checked by playing the build } developer can run before sending
8
+ * 'person' the quality review: played by our team, graded good, needs work or must fix
9
+ * strict: a quality item that is only good or must fix (no 'needs work').
10
+ * test: how a person tests a quality item, in two short steps: shown in the walkthrough our team
11
+ * grades with, and to the developer playing their own game the same way.
12
+ */
13
+
14
+ export const LIMITS = {
15
+ sizeBytes: 50 * 1024 * 1024,
16
+ readyMs: 10_000,
17
+ saveBytes: 1024 * 1024,
18
+ };
19
+
20
+ export const RULES = [
21
+ {
22
+ id: 'F1', key: 'index-top', check: 'files',
23
+ title: 'index.html at the top, or in one folder',
24
+ brief: 'Ships as one zip with index.html at the top, or inside one folder that holds the whole game.',
25
+ fix: 'Zip your build folder. index.html goes at the top, or in the one folder that holds everything.',
26
+ },
27
+ {
28
+ id: 'F2', key: 'relative-paths', check: 'files',
29
+ title: 'Every path is relative',
30
+ brief: 'Every path in the build is relative ("img/hero.png", never "/img/hero.png"), and its case matches the file.',
31
+ fix: 'Remove the leading "/" (in Vite, set base: "./"), and match upper and lower case exactly.',
32
+ },
33
+ {
34
+ id: 'F3', key: 'size', check: 'files',
35
+ title: 'Under 50 MB',
36
+ brief: 'The whole build is under 50 MB unzipped.',
37
+ fix: 'Compress textures and audio, and leave source files, maps and unused assets out of the build.',
38
+ },
39
+ {
40
+ id: 'F4', key: 'no-other-portal', check: 'files',
41
+ title: "No other site's SDK",
42
+ brief: "Loads no other game site's SDK (CrazyGames, Poki, GameDistribution, Yandex, Playgama, GamePix, GameMonetize, Y8). Make a First Byte build without it.",
43
+ fix: "Make a First Byte build that leaves the other site's SDK out. Keep it in your builds for that site.",
44
+ },
45
+ {
46
+ id: 'F5', key: 'no-store-links', check: 'files',
47
+ title: 'No links to outside purchases or other game sites',
48
+ brief: 'Has no links to outside purchases (Steam, Patreon, Ko-fi, PayPal, app stores) or to other game sites.',
49
+ fix: 'Remove the link from the First Byte build. Credits can name you, without a link to buy.',
50
+ },
51
+ {
52
+ id: 'F6', key: 'sdk', check: 'files', optional: true,
53
+ title: 'Uses the First Byte SDK',
54
+ brief: 'Optional: loads the First Byte SDK. Without it the game earns no ad share and keeps no saves with us.',
55
+ fix: 'Add <script src="https://firstbyte.games/sdk.js"></script> to index.html, before your game\'s script.',
56
+ },
57
+ {
58
+ id: 'F7', key: 'achievements', check: 'files',
59
+ title: 'Achievements are listed right',
60
+ brief: 'If the game has achievements, lists them in achievements.json next to index.html: an id, a name, a line about it and an optional icon, up to 30. A game without achievements needs no file.',
61
+ fix: 'Fix each line above in achievements.json, or leave the file out.',
62
+ },
63
+ {
64
+ id: 'P1', key: 'loads', check: 'play',
65
+ title: 'Loads without errors',
66
+ brief: 'Loads with no errors in the console and no missing files.',
67
+ fix: 'Open the game with the browser console showing and fix the first error listed.',
68
+ },
69
+ {
70
+ id: 'P2', key: 'on-screen', check: 'play',
71
+ title: 'On screen within 10 seconds',
72
+ brief: 'Something is on screen within 10 seconds. With the SDK, call FirstByte.ready() once, when the first frame is drawn.',
73
+ fix: 'Show something right away and load the rest in the background. Call FirstByte.ready() once the first frame is drawn.',
74
+ },
75
+ {
76
+ id: 'P3', key: 'self-contained', check: 'play',
77
+ title: 'Loads nothing from the internet',
78
+ brief: 'Loads every file from the build itself, apart from the First Byte SDK. No CDNs, web fonts or trackers.',
79
+ fix: 'Download the file into your build and load it with a relative path.',
80
+ },
81
+ {
82
+ id: 'P4', key: 'responds', check: 'play',
83
+ title: 'Responds to keys or a click',
84
+ brief: 'Responds to the keyboard and the mouse straight away, with no sign-in or account first. Keys the game uses must not scroll the page: event.preventDefault(). With the SDK, call FirstByte.playing(true) on the first key or click that starts play.',
85
+ fix: 'Let the first key press or click start the game. Put sign-in, if any, after the first play.',
86
+ },
87
+ {
88
+ id: 'P5', key: 'sound', check: 'play',
89
+ title: 'Plays sound',
90
+ brief: 'Plays sound for actions and menus.',
91
+ fix: 'Add a sound to the first thing the player does. A placeholder is fine for a first build.',
92
+ },
93
+ {
94
+ id: 'P6', key: 'ads-at-breaks', check: 'play',
95
+ title: 'Ads only at breaks',
96
+ brief: 'Shows ads only at a natural break, such as a game over or between levels. With the SDK: FirstByte.playing(false) first, then FirstByte.breakTime().',
97
+ fix: 'Call FirstByte.playing(false) when the round ends, and only then FirstByte.breakTime().',
98
+ },
99
+ {
100
+ id: 'P7', key: 'no-ad-first', check: 'play',
101
+ title: 'No ad before the first play',
102
+ brief: 'Never shows an ad before the player has played.',
103
+ fix: 'Ask for an ad only after the first round has ended.',
104
+ },
105
+ {
106
+ id: 'P8', key: 'mute', check: 'play',
107
+ title: 'Mutes when the site asks',
108
+ brief: "Goes quiet when the site's mute button is pressed: FirstByte.on('mute', ...) and FirstByte.on('unmute', ...).",
109
+ fix: "Add FirstByte.on('mute', () => yourVolume(0)) and FirstByte.on('unmute', () => yourVolume(1)).",
110
+ },
111
+ {
112
+ id: 'P9', key: 'achievements-known', check: 'play',
113
+ title: 'Unlocks only listed achievements',
114
+ brief: 'Calls FirstByte.achieve(id) only with ids from achievements.json, when the player earns one.',
115
+ fix: 'Call FirstByte.achieve(id) with an id from achievements.json, spelled the same, when the player earns it.',
116
+ },
117
+ {
118
+ id: 'H1', key: 'new', check: 'person',
119
+ title: 'Something new',
120
+ brief: 'Brings something new: an idea, a look or a feeling we have not seen lately. A polished copy is not picked.',
121
+ test: ["Play one full round.", "Ask: what would you tell a friend is new about it? If it is only a well-made copy, it is not new."],
122
+ },
123
+ {
124
+ id: 'H2', key: 'fun-fast', check: 'person',
125
+ title: 'Fun in the first 10 seconds',
126
+ brief: 'The player is doing something fun within 10 seconds, with no long menu first.',
127
+ test: ["Restart it and count to 10 from the first screen.", "By 10 you should be playing, not reading or clicking through menus."],
128
+ },
129
+ {
130
+ id: 'H3', key: 'no-copy', check: 'person', strict: true,
131
+ title: 'Not a copy of another game',
132
+ brief: "Does not copy another game's name, characters, art, music or levels.",
133
+ test: ["Look at the name, the characters, the art and the music.", "If any of it is taken from a game you know, it is must fix."],
134
+ },
135
+ {
136
+ id: 'H4', key: 'yours', check: 'person', strict: true,
137
+ title: 'Yours to publish',
138
+ brief: 'The developer made the game, or has the right to publish it.',
139
+ test: ["Look for another studio's logo, credits or art.", "If you doubt it is theirs to publish, it is must fix: ask them in your feedback."],
140
+ },
141
+ {
142
+ id: 'H5', key: 'first-minute', check: 'person',
143
+ title: 'The first minute is clear',
144
+ brief: 'A new player knows what to do and what to aim for within the first minute, without reading instructions.',
145
+ test: ["Restart it and play one minute, reading nothing outside the game.", "Then say what you do and what you are aiming for. If you can't, it is not clear."],
146
+ },
147
+ {
148
+ id: 'H6', key: 'controls', check: 'person',
149
+ title: 'Controls feel good',
150
+ brief: 'The controls answer straight away, do what the player expects, and are shown on screen when they matter.',
151
+ test: ["Press every control and watch for a delay.", "Check the controls are shown on screen the first time you need them."],
152
+ },
153
+ {
154
+ id: 'H7', key: 'difficulty', check: 'person',
155
+ title: 'Difficulty is fair',
156
+ brief: 'It starts easy enough to learn, gets harder at a fair pace, and a loss feels like the player\'s own mistake.',
157
+ test: ["Play until you have lost twice.", "The start should be easy enough to learn, and each loss should feel like your own mistake."],
158
+ },
159
+ {
160
+ id: 'H8', key: 'smooth', check: 'person',
161
+ title: 'Runs smoothly',
162
+ brief: 'Plays without stutter or long pauses on an ordinary laptop, including when the most is happening.',
163
+ test: ["Play to the busiest moment you can reach.", "Watch for stutter, or a pause longer than a blink."],
164
+ },
165
+ {
166
+ id: 'H9', key: 'readable', check: 'person',
167
+ title: 'Easy to read',
168
+ brief: 'The player, the dangers and the goal stand out at a glance, and every word on screen is easy to read.',
169
+ test: ["Glance at the screen for one second: find the player, the danger and the goal.", "Read every word on screen without leaning in."],
170
+ },
171
+ {
172
+ id: 'H10', key: 'sound-feel', check: 'person',
173
+ title: 'Sounds good',
174
+ brief: 'Sounds fit the game, tell the player what just happened, and never grate on a long play.',
175
+ test: ["Play two minutes with the sound on.", "What you do should have a sound that fits, and nothing should grate by the end."],
176
+ },
177
+ {
178
+ id: 'H11', key: 'no-bugs', check: 'person',
179
+ title: 'No bugs found',
180
+ brief: 'Nothing broke while our team played it: no stuck states, glitches, lost progress or crashes.',
181
+ test: ["Try to break it: mash the keys, restart mid-round, lose, win, leave it idle.", "Anything stuck, glitched or lost is a bug."],
182
+ },
183
+ ];
184
+
185
+ export const ALLOWED = [
186
+ 'Publishing the same game anywhere else, before, during or after First Byte.',
187
+ 'Skipping the SDK. The game then earns no ad share and keeps no saves with us.',
188
+ ];
189
+
190
+ /* The two sections of the checklist. */
191
+ export const SECTIONS = {
192
+ ready: { title: 'Ready to send', about: 'Checked automatically. Run npx firstbyte check to see it before you send.' },
193
+ quality: { title: 'Quality review', about: 'Played by our team. Each is good, needs work, or must fix.' },
194
+ };
195
+ export const sectionOf = (rule) => (rule.check === 'person' ? 'quality' : 'ready');
196
+
197
+ /* How the team grades a quality item. Only must fix blocks a game from being picked. */
198
+ export const GRADES = {
199
+ good: { label: 'Good', blocks: false },
200
+ 'needs-work': { label: 'Needs work', blocks: false },
201
+ 'must-fix': { label: 'Must fix', blocks: true },
202
+ };
203
+
204
+ export function ruleById(id) {
205
+ const rule = RULES.find((r) => r.id === id);
206
+ if (!rule) throw new Error(`No rule ${id}`);
207
+ return rule;
208
+ }
@@ -0,0 +1,19 @@
1
+ /*
2
+ * The starter game: a tiny, complete game that passes every automatic check, for a developer or their
3
+ * AI to start from. The game itself is the files in ./game/ (edit them there). The site hands them
4
+ * out as starter.zip (scripts/build-site.js) and the AI brief shows them (rules/Brief).
5
+ */
6
+ import { readFileSync } from 'node:fs';
7
+ import { writeZip } from '../../load/Zip/Zip.js';
8
+
9
+ export const STARTER_URL = 'https://firstbyte.games/starter.zip';
10
+
11
+ /* In the order a person reads them. */
12
+ const FILES = ['index.html', 'game.js', 'style.css', 'achievements.json', 'README.txt'];
13
+
14
+ export function starterFiles() {
15
+ /* Line endings as in the repo's other text files, whatever the machine. */
16
+ return Object.fromEntries(FILES.map((name) => [name, readFileSync(new URL(`./game/${name}`, import.meta.url), 'utf8').replace(/\r\n/g, '\n')]));
17
+ }
18
+
19
+ export const starterZip = () => writeZip(starterFiles());
@@ -0,0 +1,8 @@
1
+ First Byte starter game
2
+
3
+ A tiny game that passes every First Byte check. Make it yours: change game.js,
4
+ keep the lines marked with a rule id (P2, P4, P5...) and it keeps passing.
5
+
6
+ Check it: zip this folder and drop it at firstbyte.games/developers (Just check it)
7
+ or run: npx firstbyte check .
8
+ For an AI: paste firstbyte.games/ai.txt into it first.
@@ -0,0 +1,6 @@
1
+ {
2
+ "achievements": [
3
+ { "id": "first-round", "name": "First round", "about": "Start a round.", "icon": "flag" },
4
+ { "id": "ten-coins", "name": "Ten coins", "about": "Collect 10 coins in one round.", "icon": "coin" }
5
+ ]
6
+ }