Add structured talent mechanics
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user