v0.4.0 — LOCAL SYSTEM: planets + exploration (#6) #13
@@ -43,6 +43,24 @@ CREATE TABLE IF NOT EXISTS jump_routes (
|
||||
PRIMARY KEY (from_system, to_system)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS planets (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
system_id INTEGER NOT NULL REFERENCES solar_systems(id),
|
||||
parent_id INTEGER, -- NULL for a planet, set to the parent planet's id for a moon
|
||||
name TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
hazard INTEGER NOT NULL DEFAULT 0,
|
||||
explored INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS inventory_items (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
save_id INTEGER NOT NULL REFERENCES saves(id),
|
||||
kind TEXT NOT NULL, -- 'resource' | 'part'
|
||||
name TEXT NOT NULL,
|
||||
qty INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
save_id INTEGER NOT NULL REFERENCES saves(id),
|
||||
|
||||
@@ -35,6 +35,29 @@ export const jumpRoutes = sqliteTable(
|
||||
(t) => [primaryKey({ columns: [t.fromSystem, t.toSystem] })],
|
||||
)
|
||||
|
||||
// Bodies of a solar system: planets (parent_id NULL) and moons (parent_id = their planet's
|
||||
// id). Generated when the system is generated, so every system has 2–5 planets, some with
|
||||
// 1–3 moons. Insertion order is display order — a moon always follows its parent row.
|
||||
export const planets = sqliteTable('planets', {
|
||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
||||
systemId: integer('system_id').notNull().references(() => solarSystems.id),
|
||||
parentId: integer('parent_id'), // NULL for a planet, set for a moon
|
||||
name: text('name').notNull(),
|
||||
type: text('type').notNull(),
|
||||
hazard: integer('hazard', { mode: 'boolean' }).notNull().default(false),
|
||||
explored: integer('explored', { mode: 'boolean' }).notNull().default(false),
|
||||
})
|
||||
|
||||
// Dumb-simple cargo hold on the save: what exploration has found so far. SHIP SYSTEMS (#8)
|
||||
// will spend parts from here later; nothing consumes it yet.
|
||||
export const inventoryItems = sqliteTable('inventory_items', {
|
||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
||||
saveId: integer('save_id').notNull().references(() => saves.id),
|
||||
kind: text('kind').notNull(), // 'resource' | 'part'
|
||||
name: text('name').notNull(),
|
||||
qty: integer('qty').notNull().default(1),
|
||||
})
|
||||
|
||||
// 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