ui/phase-17: ship-class CRUD without calc
Phase 17 lights up the ship-class table and designer active views, extends the order-draft pipeline with createShipClass and removeShipClass commands, and projects pending Save/Delete actions through applyOrderOverlay so the table reflects the player's intent before auto-sync lands. The plan is corrected in the same patch: per game/rules.txt, ship classes are designed once and cannot be edited — the engine has no Update command, so the UI exposes only Create + Delete. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+49
-17
@@ -1947,35 +1947,67 @@ Decisions baked into Phase 16 (vs. the original stage description):
|
||||
|
||||
Status: pending.
|
||||
|
||||
Goal: list, view, and edit ship classes through a dedicated table view
|
||||
and a designer view; numeric calculations are stubbed pending Phase
|
||||
18.
|
||||
Goal: list, view, create, and delete ship classes through a
|
||||
dedicated table view and a designer view; numeric calculations are
|
||||
stubbed pending Phase 18.
|
||||
|
||||
Per `game/rules.txt`, ship classes are designed once and cannot be
|
||||
modified after creation — values are baked into existing ships at
|
||||
build time. The future "upgrade" command (Phase 19/20,
|
||||
`CommandShipGroupUpgrade`) raises an existing ship group's tech
|
||||
levels but does not edit the class blueprint. Phase 17 therefore
|
||||
exposes only Create and Delete; an "edit" affordance is
|
||||
deliberately absent and the designer renders an existing class
|
||||
read-only.
|
||||
|
||||
Artifacts:
|
||||
|
||||
- `ui/frontend/src/routes/games/[id]/table/ship-classes/+page.svelte`
|
||||
table of ship classes with sort and filter
|
||||
- `ui/frontend/src/routes/games/[id]/designer/ship-class/[id]/+page.svelte`
|
||||
designer form with all five fields (Drive, Armament, Weapons,
|
||||
Shields, Cargo) plus name; validation rules from [`rules.txt`](../game/rules.txt)
|
||||
(each field 0 or ≥1; armament integer; weapons and armament both
|
||||
zero or both nonzero)
|
||||
- `ui/frontend/src/lib/active-view/table-ship-classes.svelte`
|
||||
table of ship classes with sort and filter, plus per-row Delete
|
||||
affordance (the existing `routes/games/[id]/table/[entity]/+page.svelte`
|
||||
already wires this active view through the `[entity]` parameter,
|
||||
so no new route file lands).
|
||||
- `ui/frontend/src/lib/active-view/designer-ship-class.svelte`
|
||||
rewritten from the Phase 10 stub: empty form for the Create flow
|
||||
(name plus the five fields Drive, Armament, Weapons, Shields,
|
||||
Cargo) and read-only view + Delete affordance for an existing
|
||||
class. Validation rules from [`rules.txt`](../game/rules.txt) live
|
||||
in `lib/util/ship-class-validation.ts` (TS port of
|
||||
`pkg/calc/validator.go.ValidateShipTypeValues`): each of drive /
|
||||
weapons / shields / cargo is 0 or ≥ 1; armament is a non-negative
|
||||
integer; armament and weapons are both zero or both nonzero;
|
||||
not all five values may be zero. The existing
|
||||
`routes/games/[id]/designer/ship-class/[[classId]]/+page.svelte`
|
||||
is already wired and consumes the optional `classId` URL segment
|
||||
through `page.params`.
|
||||
- `ui/frontend/src/sync/order-types.ts` extends with
|
||||
`CreateShipClass` and `UpdateShipClass` command variants
|
||||
`CreateShipClassCommand` and `RemoveShipClassCommand` variants
|
||||
(mapped to `CommandShipClassCreate` and `CommandShipClassRemove`
|
||||
on the wire by `sync/submit.ts` and `sync/order-load.ts`).
|
||||
- `ui/frontend/src/api/game-state.ts` widens `ShipClassSummary`
|
||||
to carry the full attribute set; `applyOrderOverlay` projects
|
||||
pending Save / Delete actions onto `localShipClass` so the table
|
||||
reflects the player's intent before auto-sync lands.
|
||||
|
||||
Dependencies: Phase 14.
|
||||
|
||||
Acceptance criteria:
|
||||
|
||||
- the user can create, list, edit, and delete ship classes;
|
||||
- field validation matches [`rules.txt`](../game/rules.txt) constraints with disabled
|
||||
Submit + tooltip when invalid;
|
||||
- double-tapping a row in the ship-classes table opens its designer.
|
||||
- the user can create, list, view, and delete ship classes;
|
||||
- field validation matches [`rules.txt`](../game/rules.txt)
|
||||
constraints with disabled Submit + tooltip when invalid;
|
||||
- double-tapping a row in the ship-classes table opens its
|
||||
designer (read-only view of the existing class).
|
||||
|
||||
Targeted tests:
|
||||
|
||||
- Vitest component tests for designer field validation;
|
||||
- Playwright e2e: create a class, list it, edit it, delete it.
|
||||
- Vitest component tests for designer field validation
|
||||
(`tests/designer-ship-class.test.ts`) and the table
|
||||
(`tests/table-ship-classes.test.ts`); Vitest unit tests for the
|
||||
validator (`tests/ship-class-validation.test.ts`);
|
||||
- Playwright e2e (`tests/e2e/ship-classes.spec.ts`): create a
|
||||
class, list it, delete it; rejected-submit kept; field-validation
|
||||
kept (Save disabled with localised tooltip).
|
||||
|
||||
## Phase 18. Ship Classes — Calc Bridge
|
||||
|
||||
|
||||
Reference in New Issue
Block a user