import Phaser from './vendor/phaser.js'; import { config } from './config/Config.js'; import { ConfigLoader } from './config/ConfigLoader.js'; import { createGameConfig } from './config/GameConfig.js'; import { MenuScene } from './scenes/MenuScene.js'; import { GameScene } from './scenes/GameScene.js'; import { SurfaceScene } from './scenes/SurfaceScene.js'; import { installBuildDiag } from './dev/BuildDiag.js'; import { installNavDiag } from './dev/NavDiag.js'; import { awaitFonts } from './utils/Fonts.js'; import { bootCombat } from './combat/main.js'; /** * Orbit — entry point. * * 1. Load config JSON (data/manifest.json → data/*.json) * 2. Initialize the global config singleton * 3. Build the Phaser game config and attach the scenes * 4. Boot */ async function boot() { const data = await ConfigLoader.load(); config.init(data); console.info('orbit — config loaded', Object.keys(data).join(', ')); // Read-only console diagnostics (orbitDiag / orbitDiagBrief). See // js/dev/BuildDiag.js — it also self-logs a one-line report whenever // the Build console opens. installBuildDiag(); // The SYSTEM category's NAV chart (orbitNav / orbitNavBrief). See // js/dev/NavDiag.js — which NAV points of the current system are still // undiscovered, i.e. why the jumpgate tech may still be locked. installNavDiag(); await awaitFonts(); console.info('orbit — fonts ready (or timed out)'); const gameConfig = createGameConfig(); gameConfig.scene = [MenuScene, GameScene, SurfaceScene]; const game = new Phaser.Game(gameConfig); // Handy for console debugging. window.game = game; window.config = config; console.info( `%c${config.get('game.name', 'Orbit')} %c${config.get('game.version', '')}`, 'font-weight:bold;font-size:14px', 'color:#8fa0c9', ); } // --------------------------------------------------------------------- // Boot — the game, or the COMBAT SANDBOX (data/combat.json + js/combat/): // a standalone training range, reachable without touching the main game: // /combat (dev server alias → combat.html, dev/server.mjs) // index.html?combat (this file — ?combat=1 works too) // The sandbox boots ONLY CombatScene. Tune the feel in data/combat.json; // port the survivors into the real game when combat ships. function showBootError(err) { console.error(err); const pre = document.createElement('pre'); pre.style.cssText = 'color:#ff9b9b;font:14px/1.6 monospace;padding:2rem;white-space:pre-wrap;margin:0'; pre.textContent = `Failed to start Orbit:\n${(err && (err.stack || err.message)) || err}`; document.body.appendChild(pre); } const loc = typeof location !== 'undefined' ? location : null; const wantsCombat = loc && ( /[?&]combat(\b|=)/.test(loc.search) || /\/combat\/?$/.test(loc.pathname) ); if (wantsCombat) bootCombat().catch(showBootError); else boot().catch(showBootError);