9ae7b88b89
Fuse the standalone ship-class designer (Phases 17/18) into a sidebar calculator: live mass/speed/attack/defence/bombing results, a planet build-rate readout, single-target goal-seek, a modernization-cost mode, and auto reach circles on the map for the selected planet. pkg/calc becomes the single source for the new math (no mirroring): extract BombingPower from the engine model and the per-turn ship-production loop from controller.ProduceShip into pkg/calc (engine now delegates), and add inverse goal-seek solvers in pkg/calc/solve.go. Thin-bridge the combat, planet-build, and solver functions through ui/core/calc + ui/wasm and rebuild core.wasm. Remove the standalone designer view/route; the ship-classes table and the view/bottom menus open the calculator via a shared request store. Docs: rewrite ui/PLAN.md Phase 30, adjust Phase 34 (realistic forecast + CAP/COL ownership), add ui/docs/calculator-ux.md, extend calc-bridge.md, fix navigation.md; remove ui/CALCULATOR.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
24 lines
918 B
TypeScript
24 lines
918 B
TypeScript
// Shared signal that asks the sidebar calculator to open and load a ship
|
|
// class. The ship-classes table (row activation, "new" button) and the
|
|
// mobile bottom-tabs entry publish a request here; the in-game layout
|
|
// watches it to flip the sidebar to the calculator tab, and the
|
|
// calculator watches it to load the requested class. A module singleton
|
|
// keeps these siblings decoupled, mirroring `reach.svelte`.
|
|
//
|
|
// `token` increments on every request so a repeat request for the same
|
|
// class still re-triggers the watchers; each watcher records the last
|
|
// token it handled to act exactly once per request.
|
|
|
|
class CalculatorLoadRequest {
|
|
/** The class name to load, or null to start a fresh design. */
|
|
name: string | null = $state(null);
|
|
token = $state(0);
|
|
|
|
request(name: string | null): void {
|
|
this.name = name;
|
|
this.token += 1;
|
|
}
|
|
}
|
|
|
|
export const calculatorLoadRequest = new CalculatorLoadRequest();
|