ui/phase-16: pick any planet in reach + stronger pick-mode dim
The cargo-route picker filtered out unidentified planets, so an early-game player who had spotted but not surveyed a destination could not configure a route to it — the engine has no such restriction (`game/internal/controller/route.go.PlanetRouteSet` only checks ownership of the origin and `util.ShortDistance(...) <= FligthDistance`). Drop the unidentified guard and document the contract in `cargo-routes-ux.md` plus a comment over `reachableSet()`. Pick-mode dim now drops both alpha and tint on out-of-reach planets so bright shapes (`STYLE_LOCAL` is `0x6dd2ff`) collapse into a single muted gray. The single-channel `dimAlpha=0.3` was too gentle against the dark theme — the user reported the dim wasn't visible. Tighten to `dimAlpha=0.35 + dimTint=0x303841`; restore both on tear-down. Also threads through the user's `pkg/calc/race.go.FligthDistance` addition: `calc-bridge.md` records the new Go-side reference (the engine's `Race.FlightDistance()` already wraps it), and the picker comment points at the canonical formula location. Tests: - `inspector-planet-cargo-routes.test.ts` adds two cases — a reach-spans-every-kind case (own + foreign + uninhabited + unidentified all picked when in range) and a successful pick to an unidentified destination. - All 356 vitest cases + chromium-desktop / webkit-desktop e2e cargo-routes pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -221,6 +221,100 @@ describe("planet inspector — cargo routes", () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("the reachable set spans every planet kind in range, not only own", async () => {
|
||||
// Reach = 40 * 1.5 = 60. Each candidate at distance 50 — in
|
||||
// reach. The picker must include the foreign-race planet,
|
||||
// the uninhabited rock, and the unidentified target so the
|
||||
// engine's "destinations may be any planet" rule is honoured
|
||||
// (route.go: only the source's ownership is enforced).
|
||||
const { ui, pick } = mount(
|
||||
makePlanet({
|
||||
number: 1,
|
||||
name: "Earth",
|
||||
x: 100,
|
||||
y: 100,
|
||||
kind: "local",
|
||||
}),
|
||||
[
|
||||
makePlanet({
|
||||
number: 1,
|
||||
name: "Earth",
|
||||
x: 100,
|
||||
y: 100,
|
||||
kind: "local",
|
||||
}),
|
||||
makePlanet({
|
||||
number: 2,
|
||||
name: "Alpha",
|
||||
x: 150,
|
||||
y: 100,
|
||||
kind: "other",
|
||||
owner: "Aliens",
|
||||
}),
|
||||
makePlanet({
|
||||
number: 3,
|
||||
name: "Rock",
|
||||
x: 100,
|
||||
y: 150,
|
||||
kind: "uninhabited",
|
||||
}),
|
||||
makePlanet({
|
||||
number: 4,
|
||||
name: "",
|
||||
x: 50,
|
||||
y: 100,
|
||||
kind: "unidentified",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
1.5,
|
||||
);
|
||||
await fireEvent.click(ui.getByTestId("inspector-planet-cargo-slot-col-add"));
|
||||
await waitFor(() => expect(pick.invocations.length).toBe(1));
|
||||
expect(
|
||||
Array.from(pick.invocations[0]!.request.reachableIds).sort(),
|
||||
).toEqual([2, 3, 4]);
|
||||
});
|
||||
|
||||
test("the picker accepts an unidentified destination", async () => {
|
||||
const { ui, pick } = mount(
|
||||
makePlanet({
|
||||
number: 1,
|
||||
name: "Earth",
|
||||
x: 100,
|
||||
y: 100,
|
||||
kind: "local",
|
||||
}),
|
||||
[
|
||||
makePlanet({
|
||||
number: 1,
|
||||
name: "Earth",
|
||||
x: 100,
|
||||
y: 100,
|
||||
kind: "local",
|
||||
}),
|
||||
makePlanet({
|
||||
number: 9,
|
||||
name: "",
|
||||
x: 130,
|
||||
y: 100,
|
||||
kind: "unidentified",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
1.5,
|
||||
);
|
||||
await fireEvent.click(ui.getByTestId("inspector-planet-cargo-slot-mat-add"));
|
||||
await waitFor(() => expect(pick.invocations.length).toBe(1));
|
||||
pick.invocations[0]!.resolve(9);
|
||||
await waitFor(() => expect(draft.commands).toHaveLength(1));
|
||||
const cmd = draft.commands[0]!;
|
||||
expect(cmd.kind).toBe("setCargoRoute");
|
||||
if (cmd.kind !== "setCargoRoute") return;
|
||||
expect(cmd.destinationPlanetNumber).toBe(9);
|
||||
expect(cmd.loadType).toBe("MAT");
|
||||
});
|
||||
|
||||
test("a successful pick emits setCargoRoute and closes the prompt", async () => {
|
||||
const { ui, pick } = mount(
|
||||
makePlanet({ number: 1, name: "Earth", x: 100, y: 100 }),
|
||||
|
||||
Reference in New Issue
Block a user