db+game: tech table + starting tech list seeded on new game and v5 backfill step
This commit is contained in:
@@ -81,6 +81,19 @@ CREATE TABLE IF NOT EXISTS ship_systems (
|
||||
UNIQUE (save_id, type)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tech (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
save_id INTEGER NOT NULL REFERENCES saves(id),
|
||||
slug TEXT NOT NULL, -- stable key, e.g. WEAPONS_SYSTEMS
|
||||
name TEXT NOT NULL, -- display name, e.g. 'WEAPONS SYSTEMS'
|
||||
cost_kind TEXT NOT NULL, -- 'resource' | 'part'
|
||||
cost_qty INTEGER NOT NULL DEFAULT 1,
|
||||
prerequisites TEXT NOT NULL DEFAULT '', -- comma-separated tech slugs, '' when none
|
||||
effect TEXT NOT NULL, -- effect slug — semantics in EFFECTS (lib/game/tech.ts)
|
||||
researched INTEGER NOT NULL DEFAULT 0,
|
||||
UNIQUE (save_id, slug)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
save_id INTEGER NOT NULL REFERENCES saves(id),
|
||||
|
||||
@@ -88,6 +88,26 @@ export const shipSystems = sqliteTable(
|
||||
(t) => [uniqueIndex('ship_systems_save_type_unique').on(t.saveId, t.type)],
|
||||
)
|
||||
|
||||
// The technology tree, one row per known tech (see TECHS in lib/game/tech.ts). Definitions are
|
||||
// seeded from the pure module on new game / backfill v5 — same pattern as ship_systems.
|
||||
// `researched` is the per-save progress; prerequisites/effect are stored for completeness but
|
||||
// the canonical semantics live in lib/game/tech.ts (EFFECTS).
|
||||
export const tech = sqliteTable(
|
||||
'tech',
|
||||
{
|
||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
||||
saveId: integer('save_id').notNull().references(() => saves.id),
|
||||
slug: text('slug').notNull(), // stable key, e.g. WEAPONS_SYSTEMS
|
||||
name: text('name').notNull(), // display name, e.g. 'WEAPONS SYSTEMS'
|
||||
costKind: text('cost_kind').notNull(), // 'resource' | 'part'
|
||||
costQty: integer('cost_qty').notNull().default(1),
|
||||
prerequisites: text('prerequisites').notNull().default(''), // comma-separated tech slugs, '' when none
|
||||
effect: text('effect').notNull(), // effect slug — semantics in EFFECTS (lib/game/tech.ts)
|
||||
researched: integer('researched', { mode: 'boolean' }).notNull().default(false),
|
||||
},
|
||||
(t) => [uniqueIndex('tech_save_slug_unique').on(t.saveId, t.slug)],
|
||||
)
|
||||
|
||||
// Append-only game log. Writers so far: new-game + jump events; later issues add more
|
||||
// writers and a read endpoint.
|
||||
export const events = sqliteTable('events', {
|
||||
|
||||
Reference in New Issue
Block a user