SKILL TREE tab: technology research unlocks #9

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

Goal

Make the SKILL TREE tab functional: researching technologies that unlock new possibilities to build and upgrade ship systems.

Scope

  • DB: tech table (id, name, cost, prerequisites, unlock effect) + researched state on the save; starting tech list seeded on new game.
  • Action: POST /api/research {techId} — prerequisite check, cost validation against inventory, turn cost, event write.
  • Gating: SHIP SYSTEMS actions (from that issue) respect researched techs — some build/upgrade options locked until the matching tech is researched.
  • API: GET /api/tech (all techs with state: AVAILABLE/LOCKED/RESEARCHED), POST /api/research. Update OpenAPI spec.
  • Frontend: cards show real state + UNLOCKS line; RESEARCH button enabled only when affordable and prerequisites met. No placeholder data for this tab.

Acceptance criteria

  • Unit tests: prerequisite chains, cost validation, researched-state persistence, gating of ship actions.
  • e2e: research a tech → an otherwise-disabled ship action becomes available (or the card flips to RESEARCHED); persists across restart.
  • Local verify green: tsc / vitest / playwright --list (+ build DOM check).

Dependencies

After SHIP SYSTEMS issue (gating hooks into its actions).

## Goal Make the SKILL TREE tab functional: researching technologies that unlock new possibilities to build and upgrade ship systems. ## Scope - **DB:** `tech` table (id, name, cost, prerequisites, unlock effect) + researched state on the save; starting tech list seeded on new game. - **Action:** `POST /api/research {techId}` — prerequisite check, cost validation against inventory, turn cost, event write. - **Gating:** SHIP SYSTEMS actions (from that issue) respect researched techs — some build/upgrade options locked until the matching tech is researched. - **API:** `GET /api/tech` (all techs with state: AVAILABLE/LOCKED/RESEARCHED), `POST /api/research`. Update OpenAPI spec. - **Frontend:** cards show real state + UNLOCKS line; RESEARCH button enabled only when affordable and prerequisites met. No placeholder data for this tab. ## Acceptance criteria - Unit tests: prerequisite chains, cost validation, researched-state persistence, gating of ship actions. - e2e: research a tech → an otherwise-disabled ship action becomes available (or the card flips to RESEARCHED); persists across restart. - Local verify green: tsc / vitest / playwright --list (+ build DOM check). ## Dependencies After SHIP SYSTEMS issue (gating hooks into its actions).
Author
Owner

Done in v0.7.0 (PR #16, merge commit 5657e89), deployed to https://space-wanderer.dev.kkhost.pl — verified /api/version → 0.7.0 and the live save backfilled its tech tree via schema step v5 (no DB wipe).

What shipped:

  • DB: new tech table (per-save rows, UNIQUE(save_id,slug)); starting tree seeded on new game AND as idempotent backfill step v5 (SCHEMA_VERSION 4→5) — old saves get the tree on first read.
  • Tech list (6 techs, two short chains): WEAPONS SYSTEMS (2 parts, gates BUILD NEW on WEAPONS), REACTOR OVERCLOCK (+2 max level), HULL PLATING (+3 max capacity), NAVIGATION AI (+2 max level), PLASMA CANNON (3 parts, requires WEAPONS SYSTEMS, +2 WEAPONS level), FUSION CORE (4 res, requires REACTOR OVERCLOCK, +3 REACTOR capacity).
  • API: GET /api/tech → per-tech state RESEARCHED|AVAILABLE|LOCKED (+ missingPrereqs); POST /api/research {techId} with 400/404 (unknown)/409 (already researched or prereq missing, named)/422 (insufficient hold) — no mutation on failure; +1 turn + event per success. OpenAPI now documents 12 paths.
  • Gating: pure helpers in lib/game/tech.ts shared by API and UI — WEAPONS build returns 409 "requires WEAPONS SYSTEMS" until researched; level/cap raises apply through the same effective-cap functions the ship endpoints use.
  • UI: SKILL TREE tab renders real cards (state badge, cost, UNLOCKS line, red REQUIRES line when locked); RESEARCH enabled only for AVAILABLE + affordable. SHIP SYSTEMS buttons flip live after research (MissionControl owns both states) with a REQUIRES // <TECH> line on gated builds. Placeholder skill cards removed.
  • Tests: unit 50 → 59 (prereq chains, cost validation w/ no mutation, oldest-first spend + turn + event + persistence, WEAPONS gate 409→success, cap raises); e2e specs 12 → 13 (scan until affordable → assert BUILD NEW gated → research via UI → build enabled and succeeds; restart deep-equal now includes /api/tech).
  • CI note: first run failed on an e2e jump-selection bug (tests always took the first edge = route back to origin, ping-ponging between exhausted systems); fixed with a shared jumpToFreshSystem helper in e2e/helpers.ts that prefers undiscovered neighbours — e2e-only change, no app code touched.
Done in **v0.7.0** (PR #16, merge commit `5657e89`), deployed to https://space-wanderer.dev.kkhost.pl — verified `/api/version` → 0.7.0 and the live save backfilled its tech tree via schema step v5 (no DB wipe). What shipped: - **DB:** new `tech` table (per-save rows, UNIQUE(save_id,slug)); starting tree seeded on new game AND as idempotent backfill step v5 (`SCHEMA_VERSION` 4→5) — old saves get the tree on first read. - **Tech list (6 techs, two short chains):** WEAPONS SYSTEMS (2 parts, gates BUILD NEW on WEAPONS), REACTOR OVERCLOCK (+2 max level), HULL PLATING (+3 max capacity), NAVIGATION AI (+2 max level), PLASMA CANNON (3 parts, requires WEAPONS SYSTEMS, +2 WEAPONS level), FUSION CORE (4 res, requires REACTOR OVERCLOCK, +3 REACTOR capacity). - **API:** `GET /api/tech` → per-tech state RESEARCHED|AVAILABLE|LOCKED (+ missingPrereqs); `POST /api/research {techId}` with 400/404 (unknown)/409 (already researched or prereq missing, named)/422 (insufficient hold) — no mutation on failure; +1 turn + event per success. OpenAPI now documents 12 paths. - **Gating:** pure helpers in `lib/game/tech.ts` shared by API and UI — WEAPONS build returns 409 "requires WEAPONS SYSTEMS" until researched; level/cap raises apply through the same effective-cap functions the ship endpoints use. - **UI:** SKILL TREE tab renders real cards (state badge, cost, UNLOCKS line, red REQUIRES line when locked); RESEARCH enabled only for AVAILABLE + affordable. SHIP SYSTEMS buttons flip live after research (MissionControl owns both states) with a `REQUIRES // <TECH>` line on gated builds. Placeholder skill cards removed. - **Tests:** unit 50 → 59 (prereq chains, cost validation w/ no mutation, oldest-first spend + turn + event + persistence, WEAPONS gate 409→success, cap raises); e2e specs 12 → 13 (scan until affordable → assert BUILD NEW gated → research via UI → build enabled and succeeds; restart deep-equal now includes `/api/tech`). - **CI note:** first run failed on an e2e jump-selection bug (tests always took the *first* edge = route back to origin, ping-ponging between exhausted systems); fixed with a shared `jumpToFreshSystem` helper in `e2e/helpers.ts` that prefers undiscovered neighbours — e2e-only change, no app code touched.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/SpaceWanderer#9