All checks were successful
PR checks / checks (pull_request) Successful in 2m37s
PLAN.md §16 phase 17, built on the org lead's answers of 2026-10-22, recorded as D75-D79 (count of record 79). - D75: core marketing pages describe what a game module adds in core's words. "Game intelligence" became "What a game module adds"; each game's own list moved to src/data/games/ and renders only on the new /modules/uo/ and /modules/rust/. /modules/ is a card per game. - The page-side capability check is per game (assertGameCoverage), the item phase 13 moved here. - D76: the homepage keeps its game screenshot, labelled. screens.mjs entries may carry `game` (D67); Screenshot.astro and the app grid print the game's name and mark the figure data-game. - D77: /app/ describes the Rust screens (released the same day). - D78: /runicnpc/, the standalone page, is in the header and footer; the narrow header was re-measured so five links keep two rows. - D79: checkTerms.mjs --built reads every built page's visible text after the build; game routes and data-game elements allow their game's words. Proven against ten plants. Still the twelfth check. - Re-read fixes: /architecture/'s "two machines is also the maximum", Discord "guild" on /integrations/, and collection.mjs against what Steam sign-in and the Rust module keep (PLAY_DATA_SAFETY.md regenerated; the Play answers are unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
105 lines
4.0 KiB
JavaScript
105 lines
4.0 KiB
JavaScript
/**
|
||
* games/index.mjs — the games the platform supports, and the check that holds each one's
|
||
* feature list to its module's declared capabilities.
|
||
*
|
||
* PLAN.md §16, phase 17. Each game has a file of its own (`uo.mjs`, `rust.mjs`) written in
|
||
* that game's words, which only that game's pages render. This file is what the core pages
|
||
* read instead: the game's name and where its page is, which D63 lets any page say.
|
||
*
|
||
* The order is the order the games were supported in, and every list of games on the site
|
||
* follows it.
|
||
*/
|
||
|
||
import platform from '../platform.json' with { type: 'json' };
|
||
import * as uo from './uo.mjs';
|
||
import * as rust from './rust.mjs';
|
||
|
||
/**
|
||
* @typedef {object} Game
|
||
* @property {'uo'|'rust'} key A key of `platform.json`'s `games`.
|
||
* @property {string} name The game's own name, from `platform.json`.
|
||
* @property {string} href Its marketing page.
|
||
* @property {string} docs Its docs group.
|
||
* @property {string} release Its module's release, from `platform.json`.
|
||
* @property {string} blurb One sentence in core's words, for the core pages' game cards.
|
||
* @property {import('../capabilities.mjs').Capability[]} features
|
||
*/
|
||
|
||
/** @type {Game[]} */
|
||
export const games = [
|
||
{
|
||
key: 'uo',
|
||
name: platform.games.uo.name,
|
||
href: '/modules/uo/',
|
||
docs: '/docs/ultima-online/',
|
||
release: platform.releases['Module-uo'],
|
||
blurb:
|
||
'The first module, and the one the seam was cut around: the server’s live state, its ' +
|
||
'economy and its players’ own groups, extracted from the site without changing a URL.',
|
||
features: uo.features,
|
||
},
|
||
{
|
||
key: 'rust',
|
||
name: platform.games.rust.name,
|
||
href: '/modules/rust/',
|
||
docs: '/docs/rust/',
|
||
release: platform.releases['Module-Rust'],
|
||
blurb:
|
||
'Any number of servers, each with its own sidecar: a live feed, leaderboards that ' +
|
||
'outlast a reset, a live map, and permissions and events run from the site.',
|
||
features: [...rust.features, ...rust.staffFeatures],
|
||
},
|
||
];
|
||
|
||
for (const key of Object.keys(platform.games)) {
|
||
if (!games.some((game) => game.key === key)) {
|
||
throw new Error(`src/data/games/index.mjs has no entry for "${key}", which platform.json's games declares.`);
|
||
}
|
||
}
|
||
|
||
/** One game by key, or a build failure naming it. @param {string} key */
|
||
export function gameByKey(key) {
|
||
const game = games.find((candidate) => candidate.key === key);
|
||
if (game) return game;
|
||
throw new Error(`src/data/games/index.mjs has no game "${key}". Known: ${games.map((g) => g.key).join(', ')}.`);
|
||
}
|
||
|
||
/**
|
||
* Fails the build when a game's feature list and its module's declared capabilities
|
||
* disagree, in either direction.
|
||
*
|
||
* Called from the pages rather than a check script, for the reason phase 3 gave: the failure
|
||
* should reach whoever is editing the page, and an Astro build error names the component. It
|
||
* also means `astro build` alone cannot skip it.
|
||
*
|
||
* @param {string} key
|
||
*/
|
||
export function assertGameCoverage(key) {
|
||
const game = gameByKey(key);
|
||
const declared = platform.games[key].module.capabilities;
|
||
|
||
const claimed = new Set(game.features.flatMap((item) => item.caps || []));
|
||
const unlisted = declared.filter((cap) => !claimed.has(cap));
|
||
const invented = [...claimed].filter((cap) => !declared.includes(cap));
|
||
if (!unlisted.length && !invented.length) return;
|
||
|
||
const lines = [];
|
||
if (unlisted.length) {
|
||
lines.push(
|
||
`the module declares ${unlisted.map((c) => `"${c}"`).join(', ')}, which no feature on ` +
|
||
`its page claims — the site is under-selling what it can show.`,
|
||
);
|
||
}
|
||
if (invented.length) {
|
||
lines.push(
|
||
`the page claims ${invented.map((c) => `"${c}"`).join(', ')}, which the module no ` +
|
||
`longer declares — the site is advertising something that is gone (§1).`,
|
||
);
|
||
}
|
||
throw new Error(
|
||
`src/data/games/${key}.mjs disagrees with platform.json's games.${key}.module.capabilities:\n` +
|
||
lines.map((line) => ` - ${line}`).join('\n') +
|
||
`\n\nUpdate the features in src/data/games/${key}.mjs, or the JSON if the module itself changed.\n`,
|
||
);
|
||
}
|