50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
// The parts of DESIGN mode that are data rather than presentation.
|
|
//
|
|
// ExcitebikeDesign.js is a Phaser screen and cannot be loaded under Node, so
|
|
// the palette strip, the blank-track shape and the save slot live here where
|
|
// tools/verifyExcitebike.js can reach them. The editor's contract is then
|
|
// pinned by the harness rather than left untested — the same arrangement
|
|
// docs/gootower-build-plan.md settled on for its editor.
|
|
|
|
import { HURDLE_IDS } from './ExcitebikeTrack.js';
|
|
|
|
export const SLOT_KEY = 'excitebike-design';
|
|
export const DESIGN_LENGTH = 4800;
|
|
|
|
// The strip the editor prints along the bottom of the screen, exactly as the
|
|
// original's reads: ABCDEFGHIJKLMNOPQRS CL END LP.
|
|
export const TOOL_CLEAR = 'CL';
|
|
export const TOOL_END = 'END';
|
|
export const TOOL_LAPS = 'LP';
|
|
export const TOOLS = [...HURDLE_IDS, TOOL_CLEAR, TOOL_END, TOOL_LAPS];
|
|
|
|
/** An untouched design: flat, two laps, no hurdles. */
|
|
export function blankTrack() {
|
|
return {
|
|
version: 1,
|
|
id: 'design',
|
|
name: 'YOUR TRACK',
|
|
theme: 'day',
|
|
length: DESIGN_LENGTH,
|
|
laps: 2,
|
|
mainLaps: 2,
|
|
qualifyMs: 60000,
|
|
hurdles: [],
|
|
rough: [],
|
|
};
|
|
}
|
|
|
|
/** One save slot, as on the Famicom's tape. Saving overwrites what was there. */
|
|
export function readSlot() {
|
|
try {
|
|
const raw = globalThis.localStorage?.getItem(SLOT_KEY);
|
|
if (!raw) return null;
|
|
const json = JSON.parse(raw);
|
|
return json && Array.isArray(json.hurdles) ? json : null;
|
|
} catch (_) { return null; }
|
|
}
|
|
|
|
export function saveSlot(track) {
|
|
try { globalThis.localStorage?.setItem(SLOT_KEY, JSON.stringify(track)); } catch (_) { /* blocked or full */ }
|
|
}
|