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>
43 lines
1.9 KiB
Go
43 lines
1.9 KiB
Go
package calc
|
|
|
|
import "galaxy/calc"
|
|
|
|
// This file bridges the inverse ("goal-seek") solvers from
|
|
// `pkg/calc/solve.go`. The ship-class calculator lets a player pin one
|
|
// derived result and back-solve the single input it claims; each wrapper
|
|
// is a one-line passthrough so the inverse math stays in `pkg/calc`. Every
|
|
// solver returns ok == false when the request is infeasible.
|
|
|
|
// WeaponsForAttack wraps `calc.WeaponsForAttack`: the weapons block that
|
|
// yields targetAttack at weapons tech weaponsTech.
|
|
func WeaponsForAttack(targetAttack, weaponsTech float64) (float64, bool) {
|
|
return calc.WeaponsForAttack(targetAttack, weaponsTech)
|
|
}
|
|
|
|
// DriveForSpeed wraps `calc.DriveForSpeed`: the drive block that yields
|
|
// targetSpeed for a ship whose mass excluding the drive block is restMass,
|
|
// at drive tech driveTech.
|
|
func DriveForSpeed(targetSpeed, driveTech, restMass float64) (float64, bool) {
|
|
return calc.DriveForSpeed(targetSpeed, driveTech, restMass)
|
|
}
|
|
|
|
// ShieldsForDefence wraps `calc.ShieldsForDefence`: the shields block that
|
|
// yields targetDefence for a ship whose mass excluding the shields block
|
|
// is restMass, at shields tech shieldsTech.
|
|
func ShieldsForDefence(targetDefence, shieldsTech, restMass float64) (float64, bool) {
|
|
return calc.ShieldsForDefence(targetDefence, shieldsTech, restMass)
|
|
}
|
|
|
|
// CargoForEmptyMass wraps `calc.CargoForEmptyMass`: the cargo block that
|
|
// brings empty mass to targetEmptyMass given restMass, the mass of the
|
|
// other blocks.
|
|
func CargoForEmptyMass(targetEmptyMass, restMass float64) (float64, bool) {
|
|
return calc.CargoForEmptyMass(targetEmptyMass, restMass)
|
|
}
|
|
|
|
// LoadForFullMass wraps `calc.LoadForFullMass`: the cargo load that brings
|
|
// full mass to targetFullMass given the ship's empty mass and cargo tech.
|
|
func LoadForFullMass(targetFullMass, emptyMass, cargoTech float64) (float64, bool) {
|
|
return calc.LoadForFullMass(targetFullMass, emptyMass, cargoTech)
|
|
}
|