Persist games across reloads and announce new releases

- Autosave every five seconds while playing, plus on pagehide and when
  the tab is hidden. On load, a saved game resumes immediately (same
  speed and camera) instead of waiting behind the title screen.
- The build turns this version's CHANGELOG section into release notes:
  baked into the page for a one-time "What's new" card for returning
  players, and published as /version.json.
- Open games poll /version.json every 10 minutes and when the tab comes
  back into view; if a newer release is out, a banner offers to save
  and reload.
- "Start a new network" moves into the help screen, behind a confirm.
This commit is contained in:
Frederic Jung 2026-10-23 11:42:28 +02:00
parent b52d20e536
commit e082d6fc60
No known key found for this signature in database
9 changed files with 145 additions and 9 deletions

View file

@ -14,6 +14,16 @@ for f in _site/index.html _site/sitemap.xml _site/llms.txt; do
rm -f "$f.bak"
done
# Release notes for this version, baked into the page ("What's new") and
# published as version.json so open games can spot a newer release.
NOTES="$(node scripts/release-notes.js "$VERSION")"
node -e '
const fs=require("fs"),[,v,d,notes]=process.argv;
const f="_site/index.html";
fs.writeFileSync(f,fs.readFileSync(f,"utf8").replace("/*__RELEASE_NOTES__*/[]",notes));
fs.writeFileSync("_site/version.json",JSON.stringify({version:v,date:d,notes:JSON.parse(notes)},null,2)+"\n");
' "$VERSION" "$BUILD_DATE" "$NOTES"
if grep -rl "__VERSION__\|__BUILD_DATE__" _site >/dev/null; then
echo "error: unreplaced placeholders left in _site" >&2
exit 1

19
scripts/release-notes.js Normal file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env node
// Prints the CHANGELOG.md bullets for one version as a JSON array of strings.
// Usage: node scripts/release-notes.js 1.2.0
const fs = require('node:fs');
const path = require('node:path');
const version = process.argv[2];
const text = fs.readFileSync(path.join(__dirname, '..', 'CHANGELOG.md'), 'utf8');
const lines = text.split('\n');
const start = lines.findIndex((l) => l.startsWith(`## [${version}]`));
const notes = [];
if (start >= 0) {
for (let i = start + 1; i < lines.length && !lines[i].startsWith('## ['); i++) {
const l = lines[i];
if (/^\s*-\s+/.test(l)) notes.push(l.replace(/^\s*-\s+/, '').trim());
else if (/^\s{2,}\S/.test(l) && notes.length) notes[notes.length - 1] += ' ' + l.trim();
}
}
process.stdout.write(JSON.stringify(notes));