ui/phase-23: turn-report view with twenty sections and TOC
Replaces the Phase 10 report stub with a scrollable orchestrator that renders every FBS array as a dedicated section (galaxy summary, votes, player status, my/foreign sciences, my/foreign ship classes, battles, bombings, approaching groups, my/foreign/uninhabited/unknown planets, ships in production, cargo routes, my fleets, my/foreign/unidentified ship groups). A sticky table of contents (a <select> on mobile), "back to map" affordance, IntersectionObserver-driven active-section highlight, and SvelteKit Snapshot-based scroll save/restore round out the view. GameReport gains six new fields (players, otherScience, otherShipClass, battleIds, bombings, shipProductions); decodeReport, the synthetic- report loader, the e2e fixture builder, and EMPTY_SHIP_GROUPS extend in lockstep. ~90 new i18n keys land in en + ru together. The legacy-report parser is extended to populate the new sections from the dg/gplus text formats (Your Sciences, <Race> Sciences, <Race> Ship Types, Bombings, Ships In Production). Ships-in-production prod_used is derived through a new pkg/calc.ShipBuildCost helper; the engine's controller.ProduceShip refactors to call the same helper without any behaviour change (engine tests stay unchanged and green). Battles remain in the parser's Skipped list — the legacy text carries no stable per-battle UUID. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package calc_test
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"galaxy/calc"
|
||||
)
|
||||
|
||||
func TestShipBuildCost(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
shipMass float64
|
||||
material float64
|
||||
resources float64
|
||||
want float64
|
||||
}{
|
||||
{
|
||||
name: "material exceeds mass: no farming needed",
|
||||
shipMass: 5,
|
||||
material: 10,
|
||||
resources: 0.5,
|
||||
want: 50, // ShipProductionCost(5) = 50; matFarm = 0.
|
||||
},
|
||||
{
|
||||
name: "material equal to mass: no farming needed",
|
||||
shipMass: 5,
|
||||
material: 5,
|
||||
resources: 0.5,
|
||||
want: 50,
|
||||
},
|
||||
{
|
||||
name: "material short of mass: farming term added",
|
||||
shipMass: 10,
|
||||
material: 3,
|
||||
resources: 0.5,
|
||||
want: 114, // 100 + (7 / 0.5).
|
||||
},
|
||||
{
|
||||
name: "no material at all: full mass farmed",
|
||||
shipMass: 4,
|
||||
material: 0,
|
||||
resources: 0.5,
|
||||
want: 48, // 40 + (4 / 0.5).
|
||||
},
|
||||
{
|
||||
name: "zero resources collapses farming term to zero",
|
||||
shipMass: 10,
|
||||
material: 3,
|
||||
resources: 0,
|
||||
want: 100, // 100 + 0; resources == 0 is a pathological guard.
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := calc.ShipBuildCost(tc.shipMass, tc.material, tc.resources)
|
||||
if math.Abs(got-tc.want) > 1e-9 {
|
||||
t.Errorf("ShipBuildCost(%v, %v, %v) = %v, want %v",
|
||||
tc.shipMass, tc.material, tc.resources, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user