ui/phase-15: planet inspector production controls + order-draft collapse

Adds the second end-to-end command (`setProductionType`) with a
collapse-by-`planetNumber` rule on the order draft, the segmented
production-controls component on the planet inspector, the FBS
encoder/decoder pair for `CommandPlanetProduce`, and the
`localShipClass` projection on `GameReport`. Forecast number is
deferred and tracked in the new `ui/docs/calc-bridge.md`.
This commit is contained in:
Ilia Denisov
2026-05-09 15:54:30 +02:00
parent c4f1409329
commit 915b4372dd
31 changed files with 2200 additions and 76 deletions
+54 -1
View File
@@ -12,11 +12,13 @@ import { uuidToHiLo } from "../api/game-state";
import { UUID } from "../proto/galaxy/fbs/common";
import {
CommandPayload,
CommandPlanetProduce,
CommandPlanetRename,
PlanetProduction,
UserGamesOrderGet,
UserGamesOrderGetResponse,
} from "../proto/galaxy/fbs/order";
import type { OrderCommand } from "./order-types";
import type { OrderCommand, ProductionType } from "./order-types";
const MESSAGE_TYPE = "user.games.order.get";
@@ -135,6 +137,24 @@ function decodeCommand(item: CommandItemView): OrderCommand | null {
name: inner.name() ?? "",
};
}
case CommandPayload.CommandPlanetProduce: {
const inner = new CommandPlanetProduce();
item.payload(inner);
const productionType = productionTypeFromFBS(inner.production());
if (productionType === null) {
console.warn(
`fetchOrder: skipping CommandPlanetProduce with unknown production enum (${inner.production()})`,
);
return null;
}
return {
kind: "setProductionType",
id,
planetNumber: Number(inner.number()),
productionType,
subject: inner.subject() ?? "",
};
}
default:
console.warn(
`fetchOrder: skipping unknown command kind (payloadType=${payloadType})`,
@@ -143,6 +163,39 @@ function decodeCommand(item: CommandItemView): OrderCommand | null {
}
}
/**
* productionTypeFromFBS reverses `productionTypeToFBS` from
* `submit.ts`. `PlanetProduction.UNKNOWN` and any out-of-band value
* yield `null` so the caller drops the entry instead of fabricating a
* synthetic kind.
*/
export function productionTypeFromFBS(
value: PlanetProduction,
): ProductionType | null {
switch (value) {
case PlanetProduction.MAT:
return "MAT";
case PlanetProduction.CAP:
return "CAP";
case PlanetProduction.DRIVE:
return "DRIVE";
case PlanetProduction.WEAPONS:
return "WEAPONS";
case PlanetProduction.SHIELDS:
return "SHIELDS";
case PlanetProduction.CARGO:
return "CARGO";
case PlanetProduction.SCIENCE:
return "SCIENCE";
case PlanetProduction.SHIP:
return "SHIP";
case PlanetProduction.UNKNOWN:
return null;
default:
return null;
}
}
function decodeError(
payload: Uint8Array,
resultCode: string,