SHIP SYSTEMS tab: expand / upgrade / build ship systems #8

Closed
opened 2026-09-28 23:13:13 +02:00 by kamilkrzywda · 1 comment
Owner

Goal

Make the SHIP SYSTEMS tab functional: real ship systems that can be expanded, upgraded or newly built using resources/parts found during exploration.

Scope

  • DB: ship_systems table (id, type, level, status) + inventory of resources/parts from findings; starting ship seeded on new game.
  • Actions: POST /api/ship/expand, /api/ship/upgrade, /api/ship/build — cost validation against inventory, turn cost, event writes. Some options gated by researched tech (see SKILL TREE issue).
  • API: GET /api/ship (systems + levels + inventory), the three action endpoints. Update OpenAPI spec.
  • Frontend: cards show real level/status; EXPAND/UPGRADE/BUILD NEW buttons call the API and are disabled when unaffordable/gated. Left column SHIP SYSTEMS + VESSEL METRICS panels mirror real state (progress bars = real values). No placeholder data for this tab or the left column.

Acceptance criteria

  • Unit tests: cost validation, inventory deduction, level caps, turn cost, event writes.
  • e2e: with resources in hand, an upgrade works and is reflected on the card + left column; persists across restart.
  • Local verify green: tsc / vitest / playwright --list (+ build DOM check).

Dependencies

After LOCAL SYSTEM issue (needs inventory from exploration). Tech gating lands with SKILL TREE.

## Goal Make the SHIP SYSTEMS tab functional: real ship systems that can be expanded, upgraded or newly built using resources/parts found during exploration. ## Scope - **DB:** `ship_systems` table (id, type, level, status) + inventory of resources/parts from findings; starting ship seeded on new game. - **Actions:** `POST /api/ship/expand`, `/api/ship/upgrade`, `/api/ship/build` — cost validation against inventory, turn cost, event writes. Some options gated by researched tech (see SKILL TREE issue). - **API:** `GET /api/ship` (systems + levels + inventory), the three action endpoints. Update OpenAPI spec. - **Frontend:** cards show real level/status; EXPAND/UPGRADE/BUILD NEW buttons call the API and are disabled when unaffordable/gated. Left column SHIP SYSTEMS + VESSEL METRICS panels mirror real state (progress bars = real values). No placeholder data for this tab or the left column. ## Acceptance criteria - Unit tests: cost validation, inventory deduction, level caps, turn cost, event writes. - e2e: with resources in hand, an upgrade works and is reflected on the card + left column; persists across restart. - Local verify green: tsc / vitest / playwright --list (+ build DOM check). ## Dependencies After LOCAL SYSTEM issue (needs inventory from exploration). Tech gating lands with SKILL TREE.
Author
Owner

Shipped in v0.6.0 (PR #15, merge bd16d3f), deployed to https://space-wanderer.dev.kkhost.pl — verified /api/version → 0.6.0 and the live save backfilled its starting ship without a DB wipe.

What changed:

  • Backfill plumbing (root-cause fix for the recurring "live save missing new data" problem): schema_version on saves (NULL = v1) + idempotent ALTER TABLE guard; ordered backfill steps in ensureSave — v2 bodies, v3 starting crew, v4 starting ship. All deterministic from the save seed, so a backfilled save is identical to a fresh one. Future features just bump the constant and append a step — no more prod DB wipes.
  • Ship systems: ship_systems table (type/level/capacity, UNIQUE per type; built = level > 0). Starting ship: HULL, REACTOR, LIFE SUPPORT, NAV COMPUTER, COMMS ARRAY at LV1/CAP2; WEAPONS unbuilt.
  • Actions (each +1 turn + event): UPGRADE level×resource → MAX_LEVEL 5 · EXPAND capacity×resource → MAX_CAPACITY 10 · BUILD flat 3 parts, once per type. Costs in pure lib/game/ship-costs.ts, shared by API and UI so buttons disable exactly when the API would reject (404/409/422, no mutation on failure).
  • API: GET /api/ship + POST /api/ship/{upgrade,expand,build}; OpenAPI updated (10 paths).
  • UI: SHIP SYSTEMS tab on live data — real cards with UPGRADE/EXPAND/BUILD NEW, disabled when unaffordable or capped; left column StatusGrid + VESSEL METRICS bars now driven by real values (placeholder constants removed for both).
  • Tests: unit 38→50 (backfill idempotency/determinism vs fresh generation, exact oldest-first deduction, caps, build-once, no-mutation failures), e2e 11→12 (bounded scan loop → affordable action via UI button → card + left column reflect it; full ship state deep-equal across the mid-run container restart).
Shipped in **v0.6.0** (PR #15, merge `bd16d3f`), deployed to https://space-wanderer.dev.kkhost.pl — verified `/api/version` → 0.6.0 and the live save backfilled its starting ship without a DB wipe. What changed: - **Backfill plumbing (root-cause fix for the recurring "live save missing new data" problem):** `schema_version` on `saves` (NULL = v1) + idempotent ALTER TABLE guard; ordered backfill steps in ensureSave — v2 bodies, v3 starting crew, v4 starting ship. All deterministic from the save seed, so a backfilled save is identical to a fresh one. Future features just bump the constant and append a step — no more prod DB wipes. - **Ship systems:** `ship_systems` table (type/level/capacity, UNIQUE per type; built = level > 0). Starting ship: HULL, REACTOR, LIFE SUPPORT, NAV COMPUTER, COMMS ARRAY at LV1/CAP2; WEAPONS unbuilt. - **Actions** (each +1 turn + event): UPGRADE `level`×resource → MAX_LEVEL 5 · EXPAND `capacity`×resource → MAX_CAPACITY 10 · BUILD flat 3 parts, once per type. Costs in pure `lib/game/ship-costs.ts`, shared by API and UI so buttons disable exactly when the API would reject (404/409/422, no mutation on failure). - **API:** GET /api/ship + POST /api/ship/{upgrade,expand,build}; OpenAPI updated (10 paths). - **UI:** SHIP SYSTEMS tab on live data — real cards with UPGRADE/EXPAND/BUILD NEW, disabled when unaffordable or capped; left column StatusGrid + VESSEL METRICS bars now driven by real values (placeholder constants removed for both). - **Tests:** unit 38→50 (backfill idempotency/determinism vs fresh generation, exact oldest-first deduction, caps, build-once, no-mutation failures), e2e 11→12 (bounded scan loop → affordable action via UI button → card + left column reflect it; full ship state deep-equal across the mid-run container restart).
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/SpaceWanderer#8