ui/phase-20: ship-group inspector actions
Eight ship-group operations land on the inspector behind a single inline-form panel: split, send, load, unload, modernize, dismantle, transfer, join fleet. Each action either appends a typed command to the local order draft or surfaces a tooltip explaining the disabled state. Partial-ship operations emit an implicit breakShipGroup command before the targeted action so the engine sees a clean (Break, Action) pair on the wire. `pkg/calc.BlockUpgradeCost` migrates from `game/internal/controller/ship_group_upgrade.go` so the calc bridge can wrap a pure pkg/calc formula; the controller now imports it. The bridge surfaces the function as `core.blockUpgradeCost`, which the inspector calls once per ship block to render the modernize cost preview. `GameReport.otherRaces` is decoded from the report's player block (non-extinct, ≠ self) and feeds the transfer-to-race picker. The planet inspector's stationed-ship rows become clickable for own groups so the actions panel is reachable from the standard click flow (the renderer continues to hide on-planet groups). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -12,12 +12,15 @@ variant — for Phase 19 the inspector is intentionally read-only.
|
||||
<script lang="ts">
|
||||
import type {
|
||||
ReportIncomingShipGroup,
|
||||
ReportLocalFleet,
|
||||
ReportLocalShipGroup,
|
||||
ReportOtherShipGroup,
|
||||
ReportPlanet,
|
||||
ReportUnidentifiedShipGroup,
|
||||
ShipClassSummary,
|
||||
} from "../../api/game-state";
|
||||
import { i18n, type TranslationKey } from "$lib/i18n/index.svelte";
|
||||
import Actions from "./ship-group/actions.svelte";
|
||||
|
||||
export type ShipGroupSelection =
|
||||
| { variant: "local"; group: ReportLocalShipGroup }
|
||||
@@ -28,8 +31,29 @@ variant — for Phase 19 the inspector is intentionally read-only.
|
||||
type Props = {
|
||||
selection: ShipGroupSelection;
|
||||
planets: ReportPlanet[];
|
||||
localShipClass?: ShipClassSummary[];
|
||||
localFleets?: ReportLocalFleet[];
|
||||
otherRaces?: string[];
|
||||
mapWidth?: number;
|
||||
mapHeight?: number;
|
||||
localPlayerDrive?: number;
|
||||
localPlayerWeapons?: number;
|
||||
localPlayerShields?: number;
|
||||
localPlayerCargo?: number;
|
||||
};
|
||||
let { selection, planets }: Props = $props();
|
||||
let {
|
||||
selection,
|
||||
planets,
|
||||
localShipClass = [],
|
||||
localFleets = [],
|
||||
otherRaces = [],
|
||||
mapWidth = 1,
|
||||
mapHeight = 1,
|
||||
localPlayerDrive = 0,
|
||||
localPlayerWeapons = 0,
|
||||
localPlayerShields = 0,
|
||||
localPlayerCargo = 0,
|
||||
}: Props = $props();
|
||||
|
||||
const kindKeyMap: Record<ShipGroupSelection["variant"], TranslationKey> = {
|
||||
local: "game.inspector.ship_group.kind.local",
|
||||
@@ -86,6 +110,22 @@ variant — for Phase 19 the inspector is intentionally read-only.
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
{#if selection.variant === "local"}
|
||||
<Actions
|
||||
group={selection.group}
|
||||
{planets}
|
||||
{localShipClass}
|
||||
{localFleets}
|
||||
{otherRaces}
|
||||
{mapWidth}
|
||||
{mapHeight}
|
||||
{localPlayerDrive}
|
||||
{localPlayerWeapons}
|
||||
{localPlayerShields}
|
||||
{localPlayerCargo}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if selection.variant === "local" || selection.variant === "other"}
|
||||
{@const g = selection.group}
|
||||
{@const onPlanet = g.origin === null || g.range === null}
|
||||
|
||||
Reference in New Issue
Block a user