Add structured talent mechanics

This commit is contained in:
JB
2026-07-25 17:54:37 -04:00
parent 1465a8c9b3
commit 9f295e4321
9 changed files with 112 additions and 26 deletions
+12
View File
@@ -222,6 +222,18 @@ if (gearColumns.some((column) => column.name === 'level')) {
await database.exec('ALTER TABLE gear DROP COLUMN level');
}
const talentColumns = await (await database.prepare("PRAGMA table_info('talents')")).all();
for (const [name, definition] of [
['cooldown_seconds', 'REAL CHECK(cooldown_seconds IS NULL OR cooldown_seconds > 0)'],
['duration_seconds', 'REAL CHECK(duration_seconds IS NULL OR duration_seconds > 0)'],
['max_stacks', 'INTEGER CHECK(max_stacks IS NULL OR max_stacks > 0)']
]) {
if (!talentColumns.some((column) => column.name === name)) {
console.log(`Adding optional Talent mechanic: ${name}.`);
await database.exec(`ALTER TABLE talents ADD COLUMN ${name} ${definition}`);
}
}
console.log(`Applied ${statements.length} schema statements to ${databasePath}`);
if (!databaseAlreadyExisted) {