-- Migration 3: new spell system
-- Created: 2025-08-25 22:13:03

DROP TABLE IF EXISTS spells;

CREATE TABLE spells (
	`id`    INTEGER PRIMARY KEY AUTOINCREMENT,
	`type`  INTEGER NOT NULL DEFAULT 0,
	`name`  TEXT NOT NULL,
	`lore`  TEXT DEFAULT '',
	`icon`  TEXT DEFAULT '',
	`mp`    INTEGER NOT NULL DEFAULT 0,
	`power` INTEGER NOT NULL DEFAULT 0
);

-- Types: 0 (Heal), 1 (Damage), 2 (Sleep), 3 (Uber Attack), 4 (Uber Defense)
INSERT INTO spells VALUES
(1,  0, 'Heal',          '', '',  5, 10),
(2,  0, 'Revive',        '', '', 10, 25),
(3,  0, 'Life',          '', '', 25, 50),
(4,  0, 'Breath',        '', '', 50, 100),
(5,  0, 'Gaia',          '', '', 75, 150),
(6,  1, 'Hurt',          '', '',  5, 15),
(7,  1, 'Pain',          '', '', 12, 35),
(8,  1, 'Maim',          '', '', 25, 70),
(9,  1, 'Rend',          '', '', 40, 100),
(10, 1, 'Chaos',         '', '', 50, 130),
(11, 2, 'Sleep',         '', '', 10, 5),
(12, 2, 'Dream',         '', '', 30, 9),
(13, 2, 'Nightmare',     '', '', 60, 13),
(14, 3, 'Craze',         '', '', 10, 10),
(15, 3, 'Rage',          '', '', 20, 25),
(16, 3, 'Fury',          '', '', 30, 50),
(17, 4, 'Ward',          '', '', 10, 10),
(18, 4, 'Fend',          '', '', 20, 25),
(19, 4, 'Barrier',       '', '', 30, 50),
(20, 2, 'Spark',         'Small jolt of electric energy.',       '',  5, 10),
(21, 2, 'Firebolt',      'Blast of concentrated fire.',          '', 10, 30),
(22, 2, 'Geyser',        'Explosion of high-pressure water.',    '', 15, 60),
(23, 2, 'Magic Missile', 'Fast, tracking bolt of arcane force.', '', 20, 85);

CREATE TABLE spell_unlocks (
	`spell_id` INTEGER NOT NULL,
	`class_id` INTEGER NOT NULL,
	`level`    INTEGER NOT NULL
);

-- Classes: 1 (Adventurer), 2 (Mage), 3 (Warrior), 4 (Paladin)
INSERT INTO spell_unlocks VALUES
(1, 1, 3), (6, 1, 3), (11, 1, 7), (14, 1, 7), (17, 1, 7),
(20, 2, 1), (21, 2, 5), (22, 2, 12), (23, 2, 22), (11, 2, 7), (17, 2, 10), (19, 2, 24),
(1, 4, 1), (2, 4, 5), (3, 4, 10), (4, 4, 20);

CREATE TABLE user_spells (
	`user_id`  INTEGER NOT NULL,
	`spell_id` INTEGER NOT NULL
);
