// Package calc is the WASM-side bridge over `galaxy/calc`'s ship math. // Each function is a one-line passthrough: signatures match the // underlying `pkg/calc/ship.go` exactly so the bridge contains zero // math beyond the call. Wrapping `pkg/calc` here keeps the JS/Go // surface in one file and lets the canonical math live in a single // upstream package shared with the engine. package calc import "galaxy/calc" // DriveEffective wraps `calc.DriveEffective` (`pkg/calc/ship.go`): // effective drive power equals the ship's drive block multiplied by // the player's drive tech level. func DriveEffective(drive, driveTech float64) float64 { return calc.DriveEffective(drive, driveTech) } // EmptyMass wraps `calc.EmptyMass` (`pkg/calc/ship.go`): mass of the // ship without cargo. Returns ok == false when the weapons/armament // pair is invalid (one zero, the other non-zero). func EmptyMass(drive, weapons float64, armament uint, shields, cargo float64) (float64, bool) { return calc.EmptyMass(drive, weapons, armament, shields, cargo) } // WeaponsBlockMass wraps `calc.WeaponsBlockMass` (`pkg/calc/ship.go`): // mass of the weapons sub-block. Returns ok == false on the same // invalid pairing as EmptyMass. func WeaponsBlockMass(weapons float64, armament uint) (float64, bool) { return calc.WeaponsBlockMass(weapons, armament) } // FullMass wraps `calc.FullMass` (`pkg/calc/ship.go`): empty mass plus // the mass of the carried cargo. func FullMass(emptyMass, carryingMass float64) float64 { return calc.FullMass(emptyMass, carryingMass) } // Speed wraps `calc.Speed` (`pkg/calc/ship.go`): light-years per turn, // equal to effective drive times 20 divided by the ship's full mass. // Zero when fullMass is non-positive. func Speed(driveEffective, fullMass float64) float64 { return calc.Speed(driveEffective, fullMass) } // CargoCapacity wraps `calc.CargoCapacity` (`pkg/calc/ship.go`): // hold capacity of one ship in cargo units, scaled by the player's // cargo tech. func CargoCapacity(cargo, cargoTech float64) float64 { return calc.CargoCapacity(cargo, cargoTech) } // CarryingMass wraps `calc.CarryingMass` (`pkg/calc/ship.go`): mass of // a payload of `load` cargo units at the player's cargo tech. Used by // the designer preview to derive full-load mass from CargoCapacity. func CarryingMass(load, cargoTech float64) float64 { return calc.CarryingMass(load, cargoTech) } // BlockUpgradeCost wraps `calc.BlockUpgradeCost` (`pkg/calc/ship.go`): // production cost of upgrading a single ship block from currentBlockTech // to targetBlockTech. Returns 0 when blockMass is zero or the target is // not above the current level. Used by the ship-group inspector's // modernize cost preview, with each of the four blocks (drive, weapons, // shields, cargo) priced through a separate call. func BlockUpgradeCost(blockMass, currentBlockTech, targetBlockTech float64) float64 { return calc.BlockUpgradeCost(blockMass, currentBlockTech, targetBlockTech) }