firstbyte 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ npx playwright install chromium
22
22
 
23
23
  Without it the files are still checked, and the report says the play checks were skipped.
24
24
 
25
- Nothing to install at all: drop your zip at [firstbyte.games/developers](https://firstbyte.games/developers)
25
+ Nothing to install at all: drop your zip at [firstbyte.games/send](https://firstbyte.games/send)
26
26
  and press **Just check it**. The same checks run there, and nothing is sent to our team until you say so.
27
27
 
28
28
  ## Commands
@@ -47,6 +47,22 @@ run `npx firstbyte check . --json` and fix what it reports.
47
47
  [firstbyte.games/starter.zip](https://firstbyte.games/starter.zip): a tiny, complete game. Its comments
48
48
  name the rule each line is there for.
49
49
 
50
+ ## Your game's page, in the zip
51
+
52
+ Two optional files next to `index.html` fill in the boxes when you send the game, so nothing is typed twice:
53
+
54
+ ```json
55
+ { "name": "Moon Hop",
56
+ "hook": "Hop between moons that shrink.",
57
+ "controls": [ { "keys": ["arrows", "wasd"], "does": "Move" }, { "keys": ["space"], "does": "Jump" } ],
58
+ "kinds": ["quick-runs"] }
59
+ ```
60
+
61
+ That is `game.json`: any of the name, one line on what you do, how to play, and the kinds. `cover.jpg`
62
+ beside it is the picture players see: a 16:9 JPEG, at least 640 wide, under 1 MB. The checker checks
63
+ both (rule F8) and says exactly what to fix, and the brief lists every key and kind you can use. The
64
+ starter game has both, as a working example.
65
+
50
66
  ## The SDK (optional)
51
67
 
52
68
  ```html
@@ -75,5 +91,5 @@ console.log(formatReport(report));
75
91
 
76
92
  ## Sending your game
77
93
 
78
- [firstbyte.games/developers](https://firstbyte.games/developers): sign in with your email, drop the zip,
94
+ [firstbyte.games/send](https://firstbyte.games/send): sign in with your email, drop the zip,
79
95
  name it, and say in one sentence what's new about it. Our team plays it and answers within a week.
@@ -0,0 +1,178 @@
1
+ /* A game's listing and cover, checked before it goes live. Plain ESM with no Node imports. */
2
+ import { CATEGORIES } from '../Kinds/Kinds.js';
3
+
4
+ export const MOODS = ['Cozy', 'Smashy', 'Tense', 'Tidy'];
5
+ export const LIMITS = { id: 40, name: 40, hook: 90, why: 240, developer: 60, kinds: 3, coverBytes: 1024 * 1024, coverWidth: 640, controls: 4, keys: 3, does: 16 };
6
+
7
+ /*
8
+ * How a game is played, as pictures: the keys, mouse moves and touches staff can pick for a control.
9
+ * caps: drawn as keycaps (site/js/controls-ui.js); icon: drawn as a mouse or a hand. label: the words,
10
+ * for search engines and screen readers (controlWords).
11
+ */
12
+ export const CONTROL_KEYS = {
13
+ arrows: { label: 'Arrow keys', caps: ['←', '↑', '↓', '→'] },
14
+ 'left-right': { label: 'Left and right', caps: ['←', '→'] },
15
+ 'up-down': { label: 'Up and down', caps: ['↑', '↓'] },
16
+ wasd: { label: 'W A S D', caps: ['W', 'A', 'S', 'D'] },
17
+ space: { label: 'Space', caps: ['Space'] },
18
+ enter: { label: 'Enter', caps: ['Enter'] },
19
+ shift: { label: 'Shift', caps: ['Shift'] },
20
+ z: { label: 'Z', caps: ['Z'] },
21
+ x: { label: 'X', caps: ['X'] },
22
+ mouse: { label: 'Move the mouse', icon: 'mouse' },
23
+ click: { label: 'Click', icon: 'mouse' },
24
+ 'right-click': { label: 'Right-click', icon: 'mouse' },
25
+ drag: { label: 'Drag', icon: 'mouse' },
26
+ scroll: { label: 'Scroll', icon: 'mouse' },
27
+ tap: { label: 'Tap', icon: 'hand' },
28
+ swipe: { label: 'Swipe', icon: 'hand' },
29
+ hold: { label: 'Hold', icon: 'hand' },
30
+ };
31
+
32
+ /* The controls as plain words: "Arrow keys: move. Space or click: jump." */
33
+ export function controlWords(controls) {
34
+ return (Array.isArray(controls) ? controls : [])
35
+ .map((c) => `${c.keys.map((k, i) => (i ? CONTROL_KEYS[k].label.toLowerCase() : CONTROL_KEYS[k].label)).join(' or ')}: ${c.does.toLowerCase()}.`)
36
+ .join(' ');
37
+ }
38
+
39
+ /* Controls are optional; each problem names its row. */
40
+ function checkControls(input, problems) {
41
+ if (input === undefined || input === null) return [];
42
+ if (!Array.isArray(input) || input.length > LIMITS.controls) { problems.push(`Controls: at most ${LIMITS.controls}.`); return []; }
43
+ return input.map((c, i) => {
44
+ const row = `Controls, row ${i + 1}:`;
45
+ const keys = Array.isArray(c?.keys) ? c.keys.map((k) => String(k)) : [];
46
+ const does = tidy(c?.does);
47
+ if (!keys.length || keys.length > LIMITS.keys) problems.push(`${row} pick 1 to ${LIMITS.keys} keys.`);
48
+ const unknown = keys.find((k) => !Object.hasOwn(CONTROL_KEYS, k));
49
+ if (unknown) problems.push(`${row} "${unknown}" is not a key we show. Use one of the keys in the list.`);
50
+ else if (new Set(keys).size !== keys.length) problems.push(`${row} each key once.`);
51
+ if (!does) problems.push(`${row} say what it does, in a word or two.`);
52
+ else if (does.length > LIMITS.does) problems.push(`${row} what it does, in at most ${LIMITS.does} letters.`);
53
+ else if (!/^[A-Za-z][A-Za-z '-]*$/.test(does)) problems.push(`${row} plain words only.`);
54
+ return { keys, does };
55
+ });
56
+ }
57
+ /* Addresses the site or the games domain uses, or that would mislead. */
58
+ export const RESERVED = ['www', 'api', 'app', 'admin', 'staff', 'mail', 'cdn', 'static', 'assets', 'covers', 'games', 'game', 'play',
59
+ 'week', 'developers', 'signin', 'mine', 'submissions', 'stats', 'sdk', 'help', 'support', 'status', 'firstbyte', 'first-byte', 'login', 'account'];
60
+
61
+ const ID = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
62
+ const TEXT = { name: 'Name', hook: 'Hook', why: 'Why we picked it', developer: 'Developer' };
63
+ const tidy = (s) => (typeof s === 'string' ? s.replace(/\s+/g, ' ').trim() : '');
64
+
65
+ /* One line of text: filled in, within its limit, plain words, no web addresses. Answers it tidied. */
66
+ function checkText(label, value, max, problems) {
67
+ const text = tidy(value);
68
+ if (!text) problems.push(`${label}: fill it in.`);
69
+ else if (text.length > max) problems.push(`${label}: at most ${max} characters (it has ${text.length}).`);
70
+ else if (/[<>]/.test(text)) problems.push(`${label}: plain words only, no < or >.`);
71
+ else if (/https?:\/\/|www\.|\b[a-z0-9-]+\.(com|net|org|io|gg|games|app|dev)\b/i.test(text)) problems.push(`${label}: no web addresses.`);
72
+ return text;
73
+ }
74
+
75
+ /* 1 to 3 kinds we know, each once. */
76
+ function checkKinds(input, kinds, problems) {
77
+ const out = Array.isArray(input) ? input.map(tidy) : [];
78
+ const known = new Set(kinds.map((k) => k.id));
79
+ if (!out.length) problems.push('Kinds: pick at least one.');
80
+ else if (out.length > LIMITS.kinds) problems.push(`Kinds: at most ${LIMITS.kinds}.`);
81
+ const unknown = out.filter((k) => !known.has(k));
82
+ if (unknown.length) problems.push(`Kinds: unknown ${unknown.map((k) => `"${k}"`).join(', ')}. The kinds are: ${kinds.map((k) => k.id).join(', ')}.`);
83
+ if (new Set(out).size !== out.length) problems.push('Kinds: each kind once.');
84
+ return out;
85
+ }
86
+
87
+ /*
88
+ * The part of a listing its developer gives: the name, one line on what you do, how to play and the
89
+ * kinds. All optional: what is given is checked by the same rules as the listing, and what is left
90
+ * out our team fills in. It comes from the boxes on the site, or from game.json in the zip
91
+ * (readGameFile), which fills those boxes. The cover is cover.jpg beside it (checkCover).
92
+ */
93
+ export const GAME_FILE = 'game.json';
94
+ export const COVER_FILE = 'cover.jpg';
95
+ const DETAILS = { name: 'Name', hook: 'Hook' };
96
+ /* Things a listing has that are not the developer's to set, and who sets them. */
97
+ const OURS = {
98
+ id: "Our team picks the game's address.", mood: 'Our team picks the mood.', week: 'Our team picks the week.',
99
+ why: 'Our team writes why we picked it.', developer: 'Your developer name comes from your account.', cover: `The cover is the file ${COVER_FILE}, next to index.html.`,
100
+ };
101
+
102
+ export function checkDetails(input, { kinds = CATEGORIES } = {}) {
103
+ if (!input || typeof input !== 'object' || Array.isArray(input)) return { details: null, problems: ['It must be one { } holding any of: name, hook, controls, kinds.'] };
104
+ const problems = [];
105
+ const out = {};
106
+ for (const key of Object.keys(input)) {
107
+ if (!['name', 'hook', 'controls', 'kinds'].includes(key)) problems.push(`"${key}" is not something a game sets. ${OURS[key] || 'It can have: name, hook, controls, kinds.'}`);
108
+ }
109
+ for (const [key, label] of Object.entries(DETAILS)) if (input[key] !== undefined) out[key] = checkText(label, input[key], LIMITS[key], problems);
110
+ if (input.kinds !== undefined) out.kinds = checkKinds(input.kinds, kinds, problems);
111
+ if (input.controls !== undefined) out.controls = checkControls(input.controls, problems);
112
+ return problems.length ? { details: null, problems } : { details: out, problems };
113
+ }
114
+
115
+ /* game.json as text. A file that isn't JSON says so in plain words, with where it went wrong. */
116
+ export function readGameFile(text, opts) {
117
+ let data;
118
+ try { data = JSON.parse(text); } catch (e) { return { details: null, problems: [`It is not valid JSON: ${e.message}`] }; }
119
+ return checkDetails(data, opts);
120
+ }
121
+
122
+ export function checkListing(input, { kinds = CATEGORIES } = {}) {
123
+ if (!input || typeof input !== 'object' || Array.isArray(input)) return { listing: null, problems: ['Fill in the listing.'] };
124
+ const problems = [];
125
+ const out = {};
126
+
127
+ out.id = tidy(input.id).toLowerCase();
128
+ if (!ID.test(out.id) || out.id.length > LIMITS.id) {
129
+ problems.push(`Address: use lowercase letters, numbers and single dashes, starting with a letter, up to ${LIMITS.id} characters (like "keep-cracker").`);
130
+ } else if (out.id.startsWith('review-')) {
131
+ problems.push('Address: "review-" addresses are kept for builds being reviewed. Pick another.');
132
+ } else if (RESERVED.includes(out.id)) {
133
+ problems.push(`Address: "${out.id}" is kept for the site. Pick another.`);
134
+ }
135
+
136
+ for (const [key, label] of Object.entries(TEXT)) out[key] = checkText(label, input[key], LIMITS[key], problems);
137
+
138
+ out.mood = tidy(input.mood);
139
+ if (!MOODS.includes(out.mood)) problems.push(`Mood: pick one of ${MOODS.join(', ')}.`);
140
+
141
+ out.kinds = checkKinds(input.kinds, kinds, problems);
142
+
143
+ out.week = typeof input.week === 'string' && /^\d+$/.test(input.week.trim()) ? Number(input.week) : input.week;
144
+ if (!Number.isInteger(out.week) || out.week < 1) problems.push('Week: a whole number from 1.');
145
+
146
+ out.controls = checkControls(input.controls, problems);
147
+
148
+ return problems.length ? { listing: null, problems } : { listing: out, problems };
149
+ }
150
+
151
+ /* The width and height in a JPEG's start-of-frame marker. */
152
+ function jpegSize(b) {
153
+ if (!(b.length > 4 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff)) return null;
154
+ let i = 2;
155
+ while (i + 9 < b.length) {
156
+ if (b[i] !== 0xff) { i++; continue; }
157
+ const m = b[i + 1];
158
+ if (m === 0xd8 || m === 0x01 || (m >= 0xd0 && m <= 0xd7) || m === 0xff) { i += m === 0xff ? 1 : 2; continue; }
159
+ const len = (b[i + 2] << 8) | b[i + 3];
160
+ if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc) {
161
+ return { height: (b[i + 5] << 8) | b[i + 6], width: (b[i + 7] << 8) | b[i + 8] };
162
+ }
163
+ if (len < 2) return null;
164
+ i += 2 + len;
165
+ }
166
+ return null;
167
+ }
168
+
169
+ export function checkCover(bytes) {
170
+ const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(0);
171
+ const size = jpegSize(b);
172
+ if (!size) return { width: null, height: null, problems: ['Cover: it must be a JPEG picture (.jpg).'] };
173
+ const problems = [];
174
+ if (b.length > LIMITS.coverBytes) problems.push(`Cover: at most 1 MB (it is ${(b.length / 1024 / 1024).toFixed(1)} MB). Save it smaller.`);
175
+ if (size.width < LIMITS.coverWidth) problems.push(`Cover: at least ${LIMITS.coverWidth} pixels wide (it is ${size.width}).`);
176
+ if (Math.abs(size.width / size.height - 16 / 9) > (16 / 9) * 0.02) problems.push(`Cover: 16:9, like 1280 × 720 (it is ${size.width} × ${size.height}).`);
177
+ return { ...size, problems };
178
+ }
@@ -2,6 +2,7 @@
2
2
  * The 'files' rules (F1-F7): everything that can be checked by reading the build, without playing it.
3
3
  * Spec: FileChecks.spec.md. Called by check/Checker; each rule's words and fix are in rules/Rulebook.
4
4
  */
5
+ import { readGameFile, checkCover, GAME_FILE, COVER_FILE } from '../../catalog/Listing/Listing.js';
5
6
  import { LIMITS } from '../../rules/Rulebook/Rulebook.js';
6
7
  import { FILE as ACHIEVEMENTS, readList } from '../../achievements/Achievements/Achievements.js';
7
8
 
@@ -53,6 +54,7 @@ export function checkFiles(files, root) {
53
54
  storeLinks(text),
54
55
  sdk(text),
55
56
  achievements(files, text, root ?? ''),
57
+ gameFile(files, root ?? ''),
56
58
  ];
57
59
  }
58
60
 
@@ -196,3 +198,31 @@ function achievements(files, text, root) {
196
198
  if (!unseen.length) return { id: 'F7', status: 'pass', detail };
197
199
  return { id: 'F7', status: 'warn', detail: [...detail, ...unseen.map((a) => `"${a.id}" isn't written in your code. Fine if your code builds the id; otherwise it can never unlock.`)] };
198
200
  }
201
+
202
+ /* F8: game.json and cover.jpg, the developer's part of the game's page, when the build carries them. */
203
+ function gameFile(files, root) {
204
+ const detail = [];
205
+ let bad = false;
206
+ const at = (name) => {
207
+ if (files.has(root + name)) return root + name;
208
+ const elsewhere = [...files.keys()].find((n) => n === name || n.endsWith(`/${name}`));
209
+ if (elsewhere && !elsewhere.startsWith('__MACOSX/')) { bad = true; detail.push(`${name} is at "${elsewhere}". Move it next to index.html${root ? ` (into "${root.slice(0, -1)}")` : ''}.`); }
210
+ return null;
211
+ };
212
+ const game = at(GAME_FILE);
213
+ if (game) {
214
+ const { details, problems } = readGameFile(files.get(game).toString('utf8'));
215
+ if (!details) { bad = true; detail.push(...problems.map((p) => `${GAME_FILE}: ${p}`)); } else {
216
+ const has = ['name', 'hook', 'controls', 'kinds'].filter((k) => details[k] !== undefined);
217
+ detail.push(`${GAME_FILE}: ${has.length ? `has ${has.join(', ')}.` : 'is empty, so it fills in nothing.'}`);
218
+ }
219
+ }
220
+ const cover = at(COVER_FILE);
221
+ if (cover) {
222
+ const c = checkCover(new Uint8Array(files.get(cover)));
223
+ if (c.problems.length) { bad = true; detail.push(...c.problems.map((p) => p.replace(/^Cover: /, `${COVER_FILE}: `))); } else detail.push(`${COVER_FILE}: ${c.width} × ${c.height}.`);
224
+ }
225
+ if (bad) return { id: 'F8', status: 'fail', detail };
226
+ if (!detail.length) return { id: 'F8', status: 'note', detail: [`No ${GAME_FILE} or ${COVER_FILE}. With them, the boxes fill themselves in when you send: see npx firstbyte brief.`] };
227
+ return { id: 'F8', status: 'pass', detail };
228
+ }
@@ -82,7 +82,7 @@ async function launch(pw, sandbox) {
82
82
  export async function checkPlay(files, root, opts = {}) {
83
83
  const readyMs = opts.readyMs ?? LIMITS.readyMs;
84
84
  const pw = await loadPlaywright(opts);
85
- if (!pw) return skipPlay('Playing the game needs a browser, which is not installed. In your game\'s folder run: npm i -D playwright@1.63.0 && npx playwright install chromium. Or install nothing: drop the zip at firstbyte.games/developers and press "Just check it".');
85
+ if (!pw) return skipPlay('Playing the game needs a browser, which is not installed. In your game\'s folder run: npm i -D playwright@1.63.0 && npx playwright install chromium. Or install nothing: drop the zip at firstbyte.games/send and press "Just check it".');
86
86
 
87
87
  const ownBrowser = !opts.browser;
88
88
  const browser = opts.browser || await launch(pw, opts.sandbox ?? !isRoot());
@@ -53,6 +53,18 @@ export function readZip(buf) {
53
53
  return files;
54
54
  }
55
55
 
56
+ /*
57
+ * One file out of a zip, without unpacking anything else: null when it isn't there. `maxBytes` is
58
+ * the most it may be: a bigger one throws, before any of it is unpacked.
59
+ */
60
+ export function readFile(buf, name, maxBytes = Infinity) {
61
+ const e = entries(buf).find((x) => !x.dir && x.name === name);
62
+ if (!e) return null;
63
+ if (e.flags & 1) throw new ZipError(`"${e.name}" is password protected. Zip it again without a password.`);
64
+ if (e.size > maxBytes) throw new ZipError(`"${e.name}" is too big to read here.`);
65
+ return unpack(buf, e);
66
+ }
67
+
56
68
  function findEnd(buf) {
57
69
  const stop = Math.max(0, buf.length - 22 - 0xffff);
58
70
  /* The real end record reaches the end of the file exactly; one hidden inside a comment does not. */
@@ -6,6 +6,8 @@ import { rollup } from '../../metrics/Rollup/Rollup.js';
6
6
  import { LEVELS, OWN_SHARE } from '../../dev/Levels/Levels.js';
7
7
  import { LIMITS as ACH, ICONS } from '../../achievements/Achievements/Achievements.js';
8
8
  import { starterFiles, STARTER_URL } from '../Starter/Starter.js';
9
+ import { LIMITS as LISTING, CONTROL_KEYS } from '../../catalog/Listing/Listing.js';
10
+ import { CATEGORIES } from '../../catalog/Kinds/Kinds.js';
9
11
 
10
12
  /* The catalog the site shows. The brief lists what it lacks, worked out the same way the site does. */
11
13
  export function catalog() {
@@ -36,7 +38,7 @@ breaks one, name the rule by its id and say how to fix it, before anything else.
36
38
 
37
39
  The developer can run every automatic check themselves, two ways:
38
40
 
39
- - On the site: drop the zip at firstbyte.games/developers and press "Just check it". Nothing
41
+ - On the site: drop the zip at firstbyte.games/send and press "Just check it". Nothing
40
42
  goes to our team until they say so, and the report has a "Copy for my AI" button.
41
43
  - On their machine: npx firstbyte check path/to/build.zip
42
44
 
@@ -94,6 +96,26 @@ Two steps. 1: put achievements.json next to index.html:
94
96
  what to add or fix.
95
97
  Achievements are for players' fun: they never pay, and never count toward a level or a badge.
96
98
 
99
+ ## The game's page (optional)
100
+ Two files next to index.html fill in the boxes when the game is sent, so nothing is typed twice.
101
+
102
+ game.json, with any of these:
103
+
104
+ { "name": "Moon Hop",
105
+ "hook": "Hop between moons that shrink.",
106
+ "controls": [ { "keys": ["arrows", "wasd"], "does": "Move" }, { "keys": ["space"], "does": "Jump" } ],
107
+ "kinds": ["quick-runs"] }
108
+
109
+ - "name" up to ${LISTING.name} letters; "hook" is one line on what the player does, up to ${LISTING.hook}. Plain words, no links.
110
+ - "controls": up to ${LISTING.controls} rows, each 1 to ${LISTING.keys} keys and what they do in a word or two (up to ${LISTING.does} letters).
111
+ The keys are: ${Object.keys(CONTROL_KEYS).join(', ')}.
112
+ - "kinds": 1 to ${LISTING.kinds} of: ${CATEGORIES.map((k) => k.id).join(', ')}.
113
+
114
+ cover.jpg: the picture players see. A JPEG, 16:9 (like 1280 × 720), at least ${LISTING.coverWidth} wide, under 1 MB.
115
+
116
+ Our team picks the mood, the week and the address, and can change any of this. Help the developer
117
+ write both files: a hook that says what you do, not what the game is called.
118
+
97
119
  ## Good to know
98
120
  - The game plays in a frame on the page: 16:9 on a computer, close to that on a phone, and it
99
121
  changes size. Fill the window and scale the picture to fit, as the starter's style.css does.
@@ -129,17 +151,18 @@ ${LEVELS.slice(1).map((l) => ` - ${l.name}: ${l.share}%`).join('\n')}
129
151
  - Developers never pay to be picked.
130
152
 
131
153
  ## A game that passes every check
132
- Start from this: a whole game in four small files, also at ${STARTER_URL}
154
+ Start from this: a whole game in a few small files, also at ${STARTER_URL} (with its cover.jpg)
133
155
  The comments name the rule each line is there for.
134
- ${Object.entries(starterFiles()).filter(([name]) => name !== 'README.txt').map(([name, text]) => `
156
+ ${Object.entries(starterFiles()).filter(([name, text]) => typeof text === 'string' && name !== 'README.txt').map(([name, text]) => `
135
157
  ### ${name}
136
158
  \`\`\`
137
159
  ${text.trimEnd()}
138
160
  \`\`\``).join('\n')}
139
161
 
140
162
  ## 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
163
+ At firstbyte.games/send: sign in with an email, drop the zip, and say in one sentence
164
+ what's new. The name, the hook, the controls, the kinds and the cover fill themselves in from
165
+ game.json and cover.jpg, or the developer types them there. The same checks run on it there, the
143
166
  report shows in a minute or two, and our team answers within a week.
144
167
  `;
145
168
  }
@@ -60,6 +60,12 @@ export const RULES = [
60
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
61
  fix: 'Fix each line above in achievements.json, or leave the file out.',
62
62
  },
63
+ {
64
+ id: 'F8', key: 'game-file', check: 'files',
65
+ title: 'game.json and cover.jpg are right',
66
+ brief: "If the build carries game.json or cover.jpg next to index.html, they are right: game.json has any of the game's name, one line on what you do, its controls and its kinds, and cover.jpg is a 16:9 JPEG, at least 640 wide, under 1 MB. They fill in the boxes when the game is sent. A game without them needs neither.",
67
+ fix: 'Fix each line above, or leave the file out and fill in the boxes when you send.',
68
+ },
63
69
  {
64
70
  id: 'P1', key: 'loads', check: 'play',
65
71
  title: 'Loads without errors',
@@ -9,11 +9,14 @@ import { writeZip } from '../../load/Zip/Zip.js';
9
9
  export const STARTER_URL = 'https://firstbyte.games/starter.zip';
10
10
 
11
11
  /* In the order a person reads them. */
12
- const FILES = ['index.html', 'game.js', 'style.css', 'achievements.json', 'README.txt'];
12
+ const FILES = ['index.html', 'game.js', 'style.css', 'achievements.json', 'game.json', 'cover.jpg', 'README.txt'];
13
+ /* The cover is a picture (scripts/make-starter-cover.js): bytes, where the rest is text. */
14
+ const BINARY = /\.jpg$/;
13
15
 
14
16
  export function starterFiles() {
15
17
  /* 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')]));
18
+ const at = (name) => new URL(`./game/${name}`, import.meta.url);
19
+ return Object.fromEntries(FILES.map((name) => [name, BINARY.test(name) ? readFileSync(at(name)) : readFileSync(at(name), 'utf8').replace(/\r\n/g, '\n')]));
17
20
  }
18
21
 
19
22
  export const starterZip = () => writeZip(starterFiles());
@@ -3,6 +3,9 @@ First Byte starter game
3
3
  A tiny game that passes every First Byte check. Make it yours: change game.js,
4
4
  keep the lines marked with a rule id (P2, P4, P5...) and it keeps passing.
5
5
 
6
- Check it: zip this folder and drop it at firstbyte.games/developers (Just check it)
6
+ Check it: zip this folder and drop it at firstbyte.games/send (Just check it)
7
7
  or run: npx firstbyte check .
8
8
  For an AI: paste firstbyte.games/ai.txt into it first.
9
+
10
+ game.json and cover.jpg fill in the boxes when you send it (name, one line on
11
+ what you do, controls, kinds, cover). Change them to match your game.
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "My First Byte game",
3
+ "hook": "Collect coins before the time runs out.",
4
+ "controls": [
5
+ { "keys": ["arrows", "wasd"], "does": "Move" },
6
+ { "keys": ["tap"], "does": "Walk there" }
7
+ ],
8
+ "kinds": ["quick-runs"]
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firstbyte",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "First Byte: the game SDK, the checker that tells a developer exactly what to fix, and the site.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -15,6 +15,7 @@
15
15
  "index.js",
16
16
  "blocks/achievements/Achievements/",
17
17
  "blocks/catalog/Kinds/",
18
+ "blocks/catalog/Listing/",
18
19
  "blocks/catalog/Needs/",
19
20
  "blocks/check/",
20
21
  "blocks/dev/Levels/",