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:
@@ -27,11 +27,13 @@ import { UUID } from "../proto/galaxy/fbs/common";
|
||||
import {
|
||||
CommandItem,
|
||||
CommandPayload,
|
||||
CommandPlanetProduce,
|
||||
CommandPlanetRename,
|
||||
PlanetProduction,
|
||||
UserGamesOrder,
|
||||
UserGamesOrderResponse,
|
||||
} from "../proto/galaxy/fbs/order";
|
||||
import type { OrderCommand } from "./order-types";
|
||||
import type { OrderCommand, ProductionType } from "./order-types";
|
||||
|
||||
const MESSAGE_TYPE = "user.games.order";
|
||||
|
||||
@@ -148,6 +150,19 @@ function encodeCommandPayload(
|
||||
payloadOffset: offset,
|
||||
};
|
||||
}
|
||||
case "setProductionType": {
|
||||
const subjectOffset = builder.createString(cmd.subject);
|
||||
const offset = CommandPlanetProduce.createCommandPlanetProduce(
|
||||
builder,
|
||||
BigInt(cmd.planetNumber),
|
||||
productionTypeToFBS(cmd.productionType),
|
||||
subjectOffset,
|
||||
);
|
||||
return {
|
||||
payloadType: CommandPayload.CommandPlanetProduce,
|
||||
payloadOffset: offset,
|
||||
};
|
||||
}
|
||||
case "placeholder":
|
||||
throw new SubmitError(
|
||||
"invalid_request",
|
||||
@@ -157,6 +172,34 @@ function encodeCommandPayload(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* productionTypeToFBS converts the wire-stable `ProductionType` literal
|
||||
* to the FlatBuffers enum value. Mirrors `planetProductionToFBS` in
|
||||
* `pkg/transcoder/order.go`. The two sides are kept in lock-step so the
|
||||
* gateway can decode whatever the frontend produces without a
|
||||
* translation step.
|
||||
*/
|
||||
export function productionTypeToFBS(value: ProductionType): PlanetProduction {
|
||||
switch (value) {
|
||||
case "MAT":
|
||||
return PlanetProduction.MAT;
|
||||
case "CAP":
|
||||
return PlanetProduction.CAP;
|
||||
case "DRIVE":
|
||||
return PlanetProduction.DRIVE;
|
||||
case "WEAPONS":
|
||||
return PlanetProduction.WEAPONS;
|
||||
case "SHIELDS":
|
||||
return PlanetProduction.SHIELDS;
|
||||
case "CARGO":
|
||||
return PlanetProduction.CARGO;
|
||||
case "SCIENCE":
|
||||
return PlanetProduction.SCIENCE;
|
||||
case "SHIP":
|
||||
return PlanetProduction.SHIP;
|
||||
}
|
||||
}
|
||||
|
||||
function decodeOrderResponse(
|
||||
payload: Uint8Array,
|
||||
commands: OrderCommand[],
|
||||
|
||||
Reference in New Issue
Block a user