Phase 30 — Ship Class Calculator (goal-seek, reach circles, planet build) #24

Merged
developer merged 4 commits from feature/ui-calculator into development 2026-05-21 19:47:16 +00:00
Owner

Fuses the standalone ship-class designer (Phases 17/18) into a sidebar ship-class calculator.

  • Live results: empty/loaded mass, empty/loaded speed, attack, defence, bombing, cargo capacity.
  • Single-target goal-seek: pin one result, the model back-solves the one input it claims (attack→weapons, defence→shields, speed→drive, mass→cargo, loaded-mass→load); inverse math in pkg/calc/solve.go.
  • Modernization mode (per-block + total upgrade cost) reusing the design-area component.
  • Planet area: MAT-overridable single-turn ships/turn + turns/ship (pure ProduceShipsInTurn ported from the engine).
  • Auto reach circles on the map (1–3 turns) from the selected planet, driven by the design's speed.
  • pkg/calc single source: BombingPower and the per-turn ship-production loop extracted from the engine (engine now delegates); Ceil3 display rounding bridged to wasm.
  • Standalone designer view/route removed; table + menus open the calculator; long-lived calculator state survives tab switches.
  • Input validation (per-field red borders + tooltips), load capped at cargo capacity, ceil-to-3 display.

Go parity + Vitest + Playwright e2e green on gitea; deployed to dev. CAP/COL + realistic multi-turn forecast deferred to Phase 34.

🤖 Generated with Claude Code

Fuses the standalone ship-class designer (Phases 17/18) into a sidebar ship-class calculator. - Live results: empty/loaded mass, empty/loaded speed, attack, defence, bombing, cargo capacity. - Single-target goal-seek: pin one result, the model back-solves the one input it claims (attack→weapons, defence→shields, speed→drive, mass→cargo, loaded-mass→load); inverse math in pkg/calc/solve.go. - Modernization mode (per-block + total upgrade cost) reusing the design-area component. - Planet area: MAT-overridable single-turn ships/turn + turns/ship (pure ProduceShipsInTurn ported from the engine). - Auto reach circles on the map (1–3 turns) from the selected planet, driven by the design's speed. - pkg/calc single source: BombingPower and the per-turn ship-production loop extracted from the engine (engine now delegates); Ceil3 display rounding bridged to wasm. - Standalone designer view/route removed; table + menus open the calculator; long-lived calculator state survives tab switches. - Input validation (per-field red borders + tooltips), load capped at cargo capacity, ceil-to-3 display. Go parity + Vitest + Playwright e2e green on gitea; deployed to dev. CAP/COL + realistic multi-turn forecast deferred to Phase 34. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
developer added 4 commits 2026-05-21 19:40:46 +00:00
feat(ui): Phase 30 ship-class calculator with goal-seek and reach circles
Tests · UI / test (push) Successful in 2m14s
Tests · Go / test (push) Successful in 2m25s
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>
Move the calculator's inputs into a page-level calculatorState singleton so they survive the sidebar unmounting the tab on a tab switch (the inspector auto-opens on a planet click). ensureGame resets the design when the active game changes.

While on the calculator, a planet click no longer switches to the inspector — the calculator consumes the selection in its planet area / reach circles. Halve the reach-circle stroke width.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(ui-calculator): input validation, load caps, ceil display, modernization layout
Tests · Go / test (push) Successful in 2m26s
Tests · UI / test (push) Successful in 2m26s
b1b87c8521
- custom load capped at cargo capacity (error when exceeded); full load shows the cargo capacity; zero cargo pins load to empty and disables the toggle

- per-input red border + tooltip for every invalid value (blocks, techs, load, MAT, modernization target); no value may be negative; locking a speed is disabled when drive is zero

- display every computed number (results + goal-seek back-solved input) rounded up to 3 decimals via a shared pkg/calc Ceil3 bridged to wasm; engine keeps its own round-to-nearest util.Fixed*

- modernization total upgrade cost spans two columns (single line)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
docs(ui): mark Phase 30 (ship-class calculator) done in PLAN.md
Tests · Integration / integration (pull_request) Successful in 1m47s
Tests · Go / test (pull_request) Successful in 2m10s
Tests · UI / test (pull_request) Successful in 1m59s
4d3cfd11a3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
developer added 1 commit 2026-05-21 19:40:47 +00:00
docs(ui): mark Phase 30 (ship-class calculator) done in PLAN.md
Tests · Integration / integration (pull_request) Successful in 1m47s
Tests · Go / test (pull_request) Successful in 2m10s
Tests · UI / test (pull_request) Successful in 1m59s
4d3cfd11a3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
developer merged commit 51865b8cf4 into development 2026-05-21 19:47:16 +00:00
developer deleted branch feature/ui-calculator 2026-05-21 19:47:16 +00:00
Sign in to join this conversation.