From e8c332042978d6c05e13239e6b88f75d1af6c86f Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Sat, 13 Jul 2024 22:37:40 -0500 Subject: [PATCH] Finish database setup rewrite --- public/install/doodie.php | 516 ---------------------------- server/app/database.php | 4 +- server/modules/InstallModule.php | 203 ++++++++--- server/templates/install/second.php | 2 +- 4 files changed, 161 insertions(+), 564 deletions(-) diff --git a/public/install/doodie.php b/public/install/doodie.php index 699fb1c..5d76312 100644 --- a/public/install/doodie.php +++ b/public/install/doodie.php @@ -1,521 +1,5 @@ 'Intro', 'step' => 'first']); - exit; -} - -// Database setup; create tables and default data (if requested) -if ($step == 'second') { - $istart = microtime(true); // time the database setup - if (!required(['mode'])) redirect('/install/'); // dont run step two if a button wasnt clicked - $complete = $_POST['mode'] == 'complete'; // complete or partial setup - - // Create Control table - $db->table('control')->create([ - 'id INTEGER PRIMARY KEY', - "game_name TEXT DEFAULT 'Dragon Knight'", - 'game_size INTEGER DEFAULT 250', - 'game_open INTEGER DEFAULT 1', - "admin_email TEXT DEFAULT ''", - 'forum_type INTEGER DEFAULT 1', - "forum_addr TEXT DEFAULT ''", - 'verify_email INTEGER DEFAULT 1', - 'show_news INTEGER DEFAULT 1', - 'show_online INTEGER DEFAULT 1', - 'show_babble INTEGER DEFAULT 1' - ]); - - // Insert default control row - $db->insertDefaultValues(); - - // Create classes table - $db->table('classes')->create([ - 'id INTEGER PRIMARY KEY', - 'name TEXT NOT NULL', - 'start_hp INTEGER DEFAULT 0', - 'start_mp INTEGER DEFAULT 0', - 'start_str INTEGER DEFAULT 0', - 'start_atk INTEGER DEFAULT 0', - 'start_def INTEGER DEFAULT 0', - 'start_dex INTEGER DEFAULT 0', - 'growth_hp INTEGER DEFAULT 0', - 'growth_mp INTEGER DEFAULT 0', - 'growth_str INTEGER DEFAULT 0', - 'growth_atk INTEGER DEFAULT 0', - 'growth_def INTEGER DEFAULT 0', - 'growth_dex INTEGER DEFAULT 0', - "spells TEXT DEFAULT ''" - ]); - - // Add default classes if complete install - if ($complete) { - $db->insert([ - ['name' => 'Mage', 'start_hp' => 10, 'start_mp' => 10, 'start_str' => 5, 'start_atk' => 5, 'start_def' => 5, 'start_dex' => 5, 'growth_hp' => 3, 'growth_mp' => 5, 'growth_str' => 1, 'growth_atk' => 3, 'growth_def' => 1, 'growth_dex' => 3, 'spells' => '1:6,18'], - ['name' => 'Warrior', 'start_hp' => 20, 'start_mp' => 0, 'start_str' => 10, 'start_atk' => 5, 'start_def' => 10, 'start_dex' => 5, 'growth_hp' => 6, 'growth_mp' => 2, 'growth_str' => 3, 'growth_atk' => 1, 'growth_def' => 3, 'growth_dex' => 1, 'spells' => ''], - ['name' => 'Paladin', 'start_hp' => 15, 'start_mp' => 5, 'start_str' => 5, 'start_atk' => 5, 'start_def' => 10, 'start_dex' => 10, 'growth_hp' => 4, 'growth_mp' => 4, 'growth_str' => 2, 'growth_atk' => 2, 'growth_def' => 2, 'growth_dex' => 2, 'spells' => '1:1,15,18'] - ]); - } else { - // There must be at least one class, for user creation to work - $db->insert(['name' => 'Adventurer']); - } - - // Create Babble table - $db->table('babble')->create([ - 'id INTEGER PRIMARY KEY', - 'posted DATETIME DEFAULT CURRENT_TIMESTAMP', - 'author INTEGER DEFAULT 1', - 'babble TEXT NOT NULL' - ]); - - // Create Drops table - $db->table('drops')->create([ - 'id INTEGER PRIMARY KEY', - 'name TEXT NOT NULL', - 'level INTEGER DEFAULT 1', - 'type INTEGER DEFAULT 1', - "attr TEXT DEFAULT ''" - ]); - - // Add default drops if complete install - if ($complete) { - $db->insert([ - ['name' => 'Life Pebble', 'level' => 1, 'type' => 1, 'attr' => 'hp,10'], - ['name' => 'Life Stone', 'level' => 10, 'type' => 1, 'attr' => 'hp,25'], - ['name' => 'Life Rock', 'level' => 25, 'type' => 1, 'attr' => 'hp,50'], - ['name' => 'Life Ore', 'level' => 50, 'type' => 1, 'attr' => 'hp,100'], - ['name' => 'Life Gem', 'level' => 75, 'type' => 1, 'attr' => 'hp,150'], - ['name' => 'Magic Pebble', 'level' => 1, 'type' => 1, 'attr' => 'mp,10'], - ['name' => 'Magic Stone', 'level' => 10, 'type' => 1, 'attr' => 'mp,25'], - ['name' => 'Magic Rock', 'level' => 25, 'type' => 1, 'attr' => 'mp,50'], - ['name' => 'Magic Ore', 'level' => 50, 'type' => 1, 'attr' => 'mp,100'], - ['name' => 'Magic Gem', 'level' => 75, 'type' => 1, 'attr' => 'mp,150'], - ['name' => "Dragon's Scale", 'level' => 10, 'type' => 1, 'attr' => 'def,25'], - ['name' => "Dragon's Plate", 'level' => 30, 'type' => 1, 'attr' => 'def,50'], - ['name' => "Dragon's Claw", 'level' => 10, 'type' => 1, 'attr' => 'atk,25'], - ['name' => "Dragon's Fang", 'level' => 30, 'type' => 1, 'attr' => 'atk,50'], - ['name' => "Dragon's Tear", 'level' => 35, 'type' => 1, 'attr' => 'str,75'], - ['name' => "Dragon's Wing", 'level' => 35, 'type' => 1, 'attr' => 'dex,75'], - ['name' => "Demon's Sin", 'level' => 35, 'type' => 1, 'attr' => 'hp,-50|str,65'], - ['name' => "Demon's Fall", 'level' => 35, 'type' => 1, 'attr' => 'mp,-50|str,65'], - ['name' => "Demon's Lie", 'level' => 45, 'type' => 1, 'attr' => 'hp,-100|str,125'], - ['name' => "Demon's Hate", 'level' => 45, 'type' => 1, 'attr' => 'mp,-100|str,125'], - ['name' => "Angel's Joy", 'level' => 25, 'type' => 1, 'attr' => 'hp,25|str,25'], - ['name' => "Angel's Rise", 'level' => 30, 'type' => 1, 'attr' => 'hp,50|str,50'], - ['name' => "Angel's Truth", 'level' => 35, 'type' => 1, 'attr' => 'hp,75|str,75'], - ['name' => "Angel's Grace", 'level' => 40, 'type' => 1, 'attr' => 'hp,100|str,100'], - ['name' => "Seraph's Strength", 'level' => 25, 'type' => 1, 'attr' => 'mp,25|dex,25'], - ['name' => "Seraph's Power", 'level' => 30, 'type' => 1, 'attr' => 'mp,50|dex,50'], - ['name' => "Seraph's Justice", 'level' => 35, 'type' => 1, 'attr' => 'mp,75|dex,75'], - ['name' => "Seraph's Judgement", 'level' => 40, 'type' => 1, 'attr' => 'mp,100|dex,100'], - ['name' => 'Ruby', 'level' => 50, 'type' => 1, 'attr' => 'hp,150'], - ['name' => 'Sapphire', 'level' => 50, 'type' => 1, 'attr' => 'mp,150'], - ['name' => 'Emerald', 'level' => 50, 'type' => 1, 'attr' => 'str,150'], - ['name' => 'Amethyst', 'level' => 50, 'type' => 1, 'attr' => 'dex,150'], - ['name' => 'Topaz', 'level' => 50, 'type' => 1, 'attr' => 'atk,150'], - ['name' => 'Diamond', 'level' => 50, 'type' => 1, 'attr' => 'def,150'], - ['name' => "Ocean Blessing", 'level' => 77, 'type' => 1, 'attr' => 'str,7007|dex,7007'], - ['name' => 'Memory Tonic', 'level' => 5, 'type' => 1, 'attr' => 'exp,10',], - ['name' => 'Memory Potion', 'level' => 30, 'type' => 1, 'attr' => 'exp,20',], - ['name' => 'Memory Elixir', 'level' => 50, 'type' => 1, 'attr' => 'exp,30',], - ['name' => 'Gold Tonic', 'level' => 5, 'type' => 1, 'attr' => 'gold,10'], - ['name' => 'Gold Potion', 'level' => 30, 'type' => 1, 'attr' => 'gold,20'], - ['name' => 'Gold Elixir', 'level' => 50, 'type' => 1, 'attr' => 'gold,30'], - ]); - } - - // Create Forum table - $db->table('forum')->create([ - 'id INTEGER PRIMARY KEY', - 'posted DATETIME DEFAULT CURRENT_TIMESTAMP', - 'new_post DATETIME DEFAULT CURRENT_TIMESTAMP', - 'author INTEGER DEFAULT 1', - "subject TEXT DEFAULT ''", - "message TEXT DEFAULT ''", - 'locked INTEGER DEFAULT 0', - 'sticky INTEGER DEFAULT 0', - 'parent INTEGER DEFAULT 0' - ]); - - // Create Items table - $db->table('items')->create([ - 'id INTEGER PRIMARY KEY', - 'type INTEGER DEFAULT 1', - 'name TEXT NOT NULL', - 'cost INTEGER DEFAULT 0', - "attr TEXT DEFAULT ''", - "icon TEXT DEFAULT ''" - ]); - - // Create default items, if complete install - if ($complete) { - $db->insert([ - // Type 1 - weapons - ['type' => 1, 'name' => 'Stick', 'cost' => 10, 'attr' => 'atk,2', 'icon' => 'stick.png' ], // 1 - ['type' => 1, 'name' => 'Branch', 'cost' => 30, 'attr' => 'atk,4', 'icon' => 'branch.png' ], // 2 - ['type' => 1, 'name' => 'Club', 'cost' => 40, 'attr' => 'atk,6', 'icon' => 'club.png' ], // 3 - ['type' => 1, 'name' => 'Dagger', 'cost' => 80, 'attr' => 'atk,8', 'icon' => 'dagger.png' ], // 4 - ['type' => 1, 'name' => 'Hatchet', 'cost' => 120, 'attr' => 'atk,12', 'icon' => 'hatchet.png' ], // 5 - ['type' => 1, 'name' => 'Axe', 'cost' => 200, 'attr' => 'atk,18', 'icon' => 'axe.png' ], // 6 - ['type' => 1, 'name' => 'Spear', 'cost' => 300, 'attr' => 'atk,25', 'icon' => 'spear.png' ], // 7 - ['type' => 1, 'name' => 'Poleaxe', 'cost' => 500, 'attr' => 'atk,35', 'icon' => 'poleaxe.png' ], // 8 - ['type' => 1, 'name' => 'Warhammer', 'cost' => 800, 'attr' => 'atk,50', 'icon' => 'warhammer.png' ], // 9 - ['type' => 1, 'name' => 'Longsword', 'cost' => 1200, 'attr' => 'atk,65', 'icon' => 'longsword.png' ], // 10 - ['type' => 1, 'name' => 'Claymore', 'cost' => 1800, 'attr' => 'atk,85', 'icon' => 'claymore.png' ], // 11 - ['type' => 1, 'name' => 'Demon Axe', 'cost' => 2800, 'attr' => 'atk,125|exp,-5', 'icon' => 'demonaxe.png' ], // 12 - ['type' => 1, 'name' => 'Dark Sword', 'cost' => 4500, 'attr' => 'atk,225|exp,-10', 'icon' => 'darksword.png' ], // 13 - ['type' => 1, 'name' => 'Magic Axe', 'cost' => 2800, 'attr' => 'atk,95|exp,5', 'icon' => 'magicaxe.png' ], // 14 - ['type' => 1, 'name' => 'Bright Sword', 'cost' => 4500, 'attr' => 'atk,185|exp,10', 'icon' => 'brightsword.png'], // 15 - ['type' => 1, 'name' => 'Dragonbane', 'cost' => 10000, 'attr' => 'atk,300|str,50', 'icon' => 'dragonbane.png' ], // 16 - - // Type 2 - armors - ['type' => 2, 'name' => 'Underwear', 'cost' => 25, 'attr' => 'def,2|gold,10', 'icon' => 'underwear.png' ], // 17 - ['type' => 2, 'name' => 'Clothes', 'cost' => 50, 'attr' => 'def,5', 'icon' => 'clothes.png' ], // 18 - ['type' => 2, 'name' => 'Leather', 'cost' => 75, 'attr' => 'def,10', 'icon' => 'leather.png' ], // 19 - ['type' => 2, 'name' => 'Hard Leather', 'cost' => 150, 'attr' => 'def,25', 'icon' => 'hardleather.png' ], // 20 - ['type' => 2, 'name' => 'Chainmail', 'cost' => 300, 'attr' => 'def,35', 'icon' => 'chainmail.png' ], // 21 - ['type' => 2, 'name' => 'Scale Armor', 'cost' => 900, 'attr' => 'def,50', 'icon' => 'scalearmor.png' ], // 22 - ['type' => 2, 'name' => 'Platemail', 'cost' => 1800, 'attr' => 'def,100', 'icon' => 'platemail.png' ], // 23 - ['type' => 2, 'name' => 'Magic Plate', 'cost' => 3000, 'attr' => 'def,125|mp,50', 'icon' => 'magicplate.png' ], // 24 - ['type' => 2, 'name' => 'Darkmail', 'cost' => 5000, 'attr' => 'def,200|exp,-10', 'icon' => 'darkmail.png' ], // 25 - ['type' => 2, 'name' => 'Dragon Plate', 'cost' => 10000, 'attr' => 'def,165|exp,10', 'icon' => 'dragonplate.png' ], // 26 - ['type' => 2, 'name' => 'Destiny Raiment', 'cost' => 50000, 'attr' => 'def,200|dex,50', 'icon' => 'destinyraiment.png'], // 27 - - // Type 3 - shields - ['type' => 3, 'name' => 'Reed Shield', 'cost' => 50, 'attr' => 'def,5', 'icon' => 'reedshield.png' ], // 28 - ['type' => 3, 'name' => 'Buckler', 'cost' => 100, 'attr' => 'def,10', 'icon' => 'nuckler.png' ], // 29 - ['type' => 3, 'name' => 'Round Shield', 'cost' => 500, 'attr' => 'def,25', 'icon' => 'roundshield.png' ], // 30 - ['type' => 3, 'name' => 'Tower Shield', 'cost' => 2500, 'attr' => 'def,50', 'icon' => 'towershield.png' ], // 31 - ['type' => 3, 'name' => 'Silver Shield', 'cost' => 10000, 'attr' => 'def,100', 'icon' => 'silvershield.png'], // 32 - ['type' => 3, 'name' => 'Dragon Shield', 'cost' => 25000, 'attr' => 'def,125|mp,100', 'icon' => 'dragonshield.png'], // 33 - ['type' => 3, 'name' => 'Aegis', 'cost' => 50000, 'attr' => 'def,225|exp,10', 'icon' => 'aegis.png' ] // 34 - ]); - } - - // Create Monsters table - $db->table('monsters')->create([ - 'id INTEGER PRIMARY KEY', - 'name TEXT NOT NULL', - 'level INTEGER DEFAULT 1', - 'hp INTEGER DEFAULT 1', - 'atk INTEGER DEFAULT 1', - 'def INTEGER DEFAULT 1', - 'exp INTEGER DEFAULT 1', - 'gold INTEGER DEFAULT 1', - 'immune INTEGER DEFAULT 0', - "image TEXT DEFAULT ''" - ]); - - // Fill monsters table if complete install - if ($complete) { - $db->insert([ - ['name' => 'Blue Slime', 'level' => 1, 'hp' => 4, 'atk' => 3, 'def' => 1, 'exp' => 1, 'gold' => 1, 'immune' => 0], - ['name' => 'Red Slime', 'level' => 1, 'hp' => 6, 'atk' => 5, 'def' => 1, 'exp' => 2, 'gold' => 1, 'immune' => 0], - ['name' => 'Critter', 'level' => 1, 'hp' => 6, 'atk' => 5, 'def' => 2, 'exp' => 4, 'gold' => 2, 'immune' => 0], - ['name' => 'Creature', 'level' => 2, 'hp' => 10, 'atk' => 8, 'def' => 2, 'exp' => 4, 'gold' => 2, 'immune' => 0], - ['name' => 'Shadow', 'level' => 2, 'hp' => 10, 'atk' => 9, 'def' => 3, 'exp' => 6, 'gold' => 2, 'immune' => 1], - ['name' => 'Drake', 'level' => 2, 'hp' => 11, 'atk' => 10, 'def' => 3, 'exp' => 8, 'gold' => 3, 'immune' => 0], - ['name' => 'Shade', 'level' => 3, 'hp' => 12, 'atk' => 10, 'def' => 3, 'exp' => 10, 'gold' => 3, 'immune' => 1], - ['name' => 'Drakelor', 'level' => 3, 'hp' => 14, 'atk' => 12, 'def' => 4, 'exp' => 10, 'gold' => 3, 'immune' => 0], - ['name' => 'Silver Slime', 'level' => 30, 'hp' => 15, 'atk' => 100, 'def' => 200, 'exp' => 15, 'gold' => 1000, 'immune' => 2], - ['name' => 'Scamp', 'level' => 4, 'hp' => 16, 'atk' => 13, 'def' => 5, 'exp' => 15, 'gold' => 5, 'immune' => 0], - ['name' => 'Raven', 'level' => 4, 'hp' => 16, 'atk' => 13, 'def' => 5, 'exp' => 18, 'gold' => 6, 'immune' => 0], - ['name' => 'Scorpion', 'level' => 5, 'hp' => 18, 'atk' => 14, 'def' => 6, 'exp' => 20, 'gold' => 7, 'immune' => 0], - ['name' => 'Illusion', 'level' => 5, 'hp' => 20, 'atk' => 15, 'def' => 6, 'exp' => 20, 'gold' => 7, 'immune' => 1], - ['name' => 'Nightshade', 'level' => 6, 'hp' => 22, 'atk' => 16, 'def' => 6, 'exp' => 24, 'gold' => 8, 'immune' => 0], - ['name' => 'Drakemal', 'level' => 6, 'hp' => 22, 'atk' => 18, 'def' => 7, 'exp' => 24, 'gold' => 8, 'immune' => 0], - ['name' => 'Shadow Raven', 'level' => 6, 'hp' => 24, 'atk' => 18, 'def' => 7, 'exp' => 26, 'gold' => 9, 'immune' => 1], - ['name' => 'Ghost', 'level' => 6, 'hp' => 24, 'atk' => 20, 'def' => 8, 'exp' => 28, 'gold' => 9, 'immune' => 0], - ['name' => 'Frost Raven', 'level' => 7, 'hp' => 26, 'atk' => 20, 'def' => 8, 'exp' => 30, 'gold' => 10, 'immune' => 0], - ['name' => 'Rogue Scorpion', 'level' => 7, 'hp' => 28, 'atk' => 22, 'def' => 9, 'exp' => 32, 'gold' => 11, 'immune' => 0], - ['name' => 'Ghoul', 'level' => 7, 'hp' => 29, 'atk' => 24, 'def' => 9, 'exp' => 34, 'gold' => 11, 'immune' => 0], - ['name' => 'Magician', 'level' => 8, 'hp' => 30, 'atk' => 24, 'def' => 10, 'exp' => 36, 'gold' => 12, 'immune' => 0], - ['name' => 'Rogue', 'level' => 8, 'hp' => 30, 'atk' => 25, 'def' => 12, 'exp' => 40, 'gold' => 13, 'immune' => 0], - ['name' => 'Drakefin', 'level' => 8, 'hp' => 32, 'atk' => 26, 'def' => 12, 'exp' => 40, 'gold' => 13, 'immune' => 0], - ['name' => 'Shimmer', 'level' => 8, 'hp' => 32, 'atk' => 26, 'def' => 14, 'exp' => 45, 'gold' => 15, 'immune' => 1], - ['name' => 'Fire Raven', 'level' => 9, 'hp' => 34, 'atk' => 28, 'def' => 14, 'exp' => 45, 'gold' => 15, 'immune' => 0], - ['name' => 'Dybbuk', 'level' => 9, 'hp' => 34, 'atk' => 28, 'def' => 14, 'exp' => 50, 'gold' => 17, 'immune' => 0], - ['name' => 'Knave', 'level' => 9, 'hp' => 36, 'atk' => 30, 'def' => 15, 'exp' => 52, 'gold' => 17, 'immune' => 0], - ['name' => 'Goblin', 'level' => 10, 'hp' => 36, 'atk' => 30, 'def' => 15, 'exp' => 54, 'gold' => 18, 'immune' => 0], - ['name' => 'Skeleton', 'level' => 10, 'hp' => 38, 'atk' => 30, 'def' => 18, 'exp' => 58, 'gold' => 19, 'immune' => 0], - ['name' => 'Dark Slime', 'level' => 10, 'hp' => 38, 'atk' => 32, 'def' => 18, 'exp' => 62, 'gold' => 21, 'immune' => 0], - ['name' => 'Silver Scorpion', 'level' => 40, 'hp' => 30, 'atk' => 160, 'def' => 350, 'exp' => 63, 'gold' => 2000, 'immune' => 2], - ['name' => 'Mirage', 'level' => 11, 'hp' => 40, 'atk' => 32, 'def' => 20, 'exp' => 64, 'gold' => 21, 'immune' => 1], - ['name' => 'Sorceror', 'level' => 11, 'hp' => 41, 'atk' => 33, 'def' => 22, 'exp' => 68, 'gold' => 23, 'immune' => 0], - ['name' => 'Imp', 'level' => 12, 'hp' => 42, 'atk' => 34, 'def' => 22, 'exp' => 70, 'gold' => 23, 'immune' => 0], - ['name' => 'Nymph', 'level' => 12, 'hp' => 43, 'atk' => 35, 'def' => 22, 'exp' => 70, 'gold' => 23, 'immune' => 0], - ['name' => 'Scoundrel', 'level' => 12, 'hp' => 43, 'atk' => 35, 'def' => 22, 'exp' => 75, 'gold' => 25, 'immune' => 0], - ['name' => 'Megaskeleton', 'level' => 13, 'hp' => 44, 'atk' => 36, 'def' => 24, 'exp' => 78, 'gold' => 26, 'immune' => 0], - ['name' => 'Grey Wolf', 'level' => 13, 'hp' => 44, 'atk' => 36, 'def' => 24, 'exp' => 82, 'gold' => 27, 'immune' => 0], - ['name' => 'Phantom', 'level' => 14, 'hp' => 46, 'atk' => 38, 'def' => 24, 'exp' => 85, 'gold' => 28, 'immune' => 1], - ['name' => 'Specter', 'level' => 14, 'hp' => 46, 'atk' => 38, 'def' => 24, 'exp' => 90, 'gold' => 30, 'immune' => 0], - ['name' => 'Dark Scorpion', 'level' => 15, 'hp' => 48, 'atk' => 40, 'def' => 26, 'exp' => 95, 'gold' => 32, 'immune' => 1], - ['name' => 'Warlock', 'level' => 15, 'hp' => 48, 'atk' => 40, 'def' => 26, 'exp' => 100, 'gold' => 33, 'immune' => 1], - ['name' => 'Orc', 'level' => 15, 'hp' => 49, 'atk' => 42, 'def' => 28, 'exp' => 104, 'gold' => 35, 'immune' => 0], - ['name' => 'Sylph', 'level' => 15, 'hp' => 49, 'atk' => 42, 'def' => 28, 'exp' => 106, 'gold' => 35, 'immune' => 0], - ['name' => 'Wraith', 'level' => 16, 'hp' => 50, 'atk' => 45, 'def' => 30, 'exp' => 108, 'gold' => 36, 'immune' => 0], - ['name' => 'Hellion', 'level' => 16, 'hp' => 50, 'atk' => 45, 'def' => 30, 'exp' => 110, 'gold' => 37, 'immune' => 0], - ['name' => 'Bandit', 'level' => 16, 'hp' => 52, 'atk' => 45, 'def' => 30, 'exp' => 114, 'gold' => 38, 'immune' => 0], - ['name' => 'Ultraskeleton', 'level' => 16, 'hp' => 52, 'atk' => 46, 'def' => 32, 'exp' => 116, 'gold' => 39, 'immune' => 0], - ['name' => 'Dark Wolf', 'level' => 17, 'hp' => 54, 'atk' => 47, 'def' => 36, 'exp' => 120, 'gold' => 40, 'immune' => 1], - ['name' => 'Troll', 'level' => 17, 'hp' => 56, 'atk' => 48, 'def' => 36, 'exp' => 120, 'gold' => 40, 'immune' => 0], - ['name' => 'Werewolf', 'level' => 17, 'hp' => 56, 'atk' => 48, 'def' => 38, 'exp' => 124, 'gold' => 41, 'immune' => 0], - ['name' => 'Hellcat', 'level' => 18, 'hp' => 58, 'atk' => 50, 'def' => 38, 'exp' => 128, 'gold' => 43, 'immune' => 0], - ['name' => 'Spirit', 'level' => 18, 'hp' => 58, 'atk' => 50, 'def' => 38, 'exp' => 132, 'gold' => 44, 'immune' => 0], - ['name' => 'Nisse', 'level' => 19, 'hp' => 60, 'atk' => 52, 'def' => 40, 'exp' => 132, 'gold' => 44, 'immune' => 0], - ['name' => 'Dawk', 'level' => 19, 'hp' => 60, 'atk' => 54, 'def' => 40, 'exp' => 136, 'gold' => 45, 'immune' => 0], - ['name' => 'Figment', 'level' => 19, 'hp' => 64, 'atk' => 55, 'def' => 42, 'exp' => 140, 'gold' => 47, 'immune' => 1], - ['name' => 'Hellhound', 'level' => 20, 'hp' => 66, 'atk' => 56, 'def' => 44, 'exp' => 140, 'gold' => 47, 'immune' => 0], - ['name' => 'Wizard', 'level' => 20, 'hp' => 66, 'atk' => 56, 'def' => 44, 'exp' => 144, 'gold' => 48, 'immune' => 0], - ['name' => 'Uruk', 'level' => 20, 'hp' => 68, 'atk' => 58, 'def' => 44, 'exp' => 146, 'gold' => 49, 'immune' => 0], - ['name' => 'Siren', 'level' => 50, 'hp' => 68, 'atk' => 400, 'def' => 800, 'exp' => 10000, 'gold' => 50, 'immune' => 2], - ['name' => 'Megawraith', 'level' => 21, 'hp' => 70, 'atk' => 60, 'def' => 46, 'exp' => 155, 'gold' => 52, 'immune' => 0], - ['name' => 'Dawkin', 'level' => 21, 'hp' => 70, 'atk' => 60, 'def' => 46, 'exp' => 155, 'gold' => 52, 'immune' => 0], - ['name' => 'Grey Bear', 'level' => 21, 'hp' => 70, 'atk' => 62, 'def' => 48, 'exp' => 160, 'gold' => 53, 'immune' => 0], - ['name' => 'Haunt', 'level' => 22, 'hp' => 72, 'atk' => 62, 'def' => 48, 'exp' => 160, 'gold' => 53, 'immune' => 0], - ['name' => 'Hellbeast', 'level' => 22, 'hp' => 74, 'atk' => 64, 'def' => 50, 'exp' => 165, 'gold' => 55, 'immune' => 0], - ['name' => 'Fear', 'level' => 23, 'hp' => 76, 'atk' => 66, 'def' => 52, 'exp' => 165, 'gold' => 55, 'immune' => 0], - ['name' => 'Beast', 'level' => 23, 'hp' => 76, 'atk' => 66, 'def' => 52, 'exp' => 170, 'gold' => 57, 'immune' => 0], - ['name' => 'Ogre', 'level' => 23, 'hp' => 78, 'atk' => 68, 'def' => 54, 'exp' => 170, 'gold' => 57, 'immune' => 0], - ['name' => 'Dark Bear', 'level' => 24, 'hp' => 80, 'atk' => 70, 'def' => 56, 'exp' => 175, 'gold' => 58, 'immune' => 1], - ['name' => 'Fire', 'level' => 24, 'hp' => 80, 'atk' => 72, 'def' => 56, 'exp' => 175, 'gold' => 58, 'immune' => 0], - ['name' => 'Polgergeist', 'level' => 25, 'hp' => 84, 'atk' => 74, 'def' => 58, 'exp' => 180, 'gold' => 60, 'immune' => 0], - ['name' => 'Fright', 'level' => 25, 'hp' => 86, 'atk' => 76, 'def' => 58, 'exp' => 180, 'gold' => 60, 'immune' => 0], - ['name' => 'Lycan', 'level' => 25, 'hp' => 88, 'atk' => 78, 'def' => 60, 'exp' => 185, 'gold' => 62, 'immune' => 0], - ['name' => 'Terra Elemental', 'level' => 25, 'hp' => 88, 'atk' => 80, 'def' => 62, 'exp' => 185, 'gold' => 62, 'immune' => 1], - ['name' => 'Necromancer', 'level' => 26, 'hp' => 90, 'atk' => 80, 'def' => 62, 'exp' => 190, 'gold' => 63, 'immune' => 0], - ['name' => 'Ultrawraith', 'level' => 26, 'hp' => 90, 'atk' => 82, 'def' => 64, 'exp' => 190, 'gold' => 63, 'immune' => 0], - ['name' => 'Dawkor', 'level' => 26, 'hp' => 92, 'atk' => 82, 'def' => 64, 'exp' => 195, 'gold' => 65, 'immune' => 0], - ['name' => 'Werebear', 'level' => 26, 'hp' => 92, 'atk' => 84, 'def' => 65, 'exp' => 195, 'gold' => 65, 'immune' => 0], - ['name' => 'Brute', 'level' => 27, 'hp' => 94, 'atk' => 84, 'def' => 65, 'exp' => 200, 'gold' => 67, 'immune' => 0], - ['name' => 'Large Beast', 'level' => 27, 'hp' => 96, 'atk' => 88, 'def' => 66, 'exp' => 200, 'gold' => 67, 'immune' => 0], - ['name' => 'Horror', 'level' => 27, 'hp' => 96, 'atk' => 88, 'def' => 68, 'exp' => 210, 'gold' => 70, 'immune' => 0], - ['name' => 'Flame', 'level' => 28, 'hp' => 100, 'atk' => 90, 'def' => 70, 'exp' => 210, 'gold' => 70, 'immune' => 0], - ['name' => 'Lycanthor', 'level' => 28, 'hp' => 100, 'atk' => 90, 'def' => 70, 'exp' => 210, 'gold' => 70, 'immune' => 0], - ['name' => 'Wyrm', 'level' => 28, 'hp' => 100, 'atk' => 92, 'def' => 72, 'exp' => 220, 'gold' => 73, 'immune' => 0], - ['name' => 'Aero Elemental', 'level' => 29, 'hp' => 104, 'atk' => 94, 'def' => 74, 'exp' => 220, 'gold' => 73, 'immune' => 1], - ['name' => 'Dawkare', 'level' => 29, 'hp' => 106, 'atk' => 96, 'def' => 76, 'exp' => 220, 'gold' => 73, 'immune' => 0], - ['name' => 'Large Brute', 'level' => 29, 'hp' => 108, 'atk' => 98, 'def' => 78, 'exp' => 230, 'gold' => 77, 'immune' => 0], - ['name' => 'Frost Wyrm', 'level' => 30, 'hp' => 110, 'atk' => 100, 'def' => 80, 'exp' => 230, 'gold' => 77, 'immune' => 0], - ['name' => 'Knight', 'level' => 30, 'hp' => 110, 'atk' => 102, 'def' => 80, 'exp' => 240, 'gold' => 80, 'immune' => 0], - ['name' => 'Lycanthra', 'level' => 30, 'hp' => 112, 'atk' => 104, 'def' => 82, 'exp' => 240, 'gold' => 80, 'immune' => 0], - ['name' => 'Terror', 'level' => 31, 'hp' => 115, 'atk' => 108, 'def' => 84, 'exp' => 250, 'gold' => 83, 'immune' => 0], - ['name' => 'Blaze', 'level' => 31, 'hp' => 118, 'atk' => 108, 'def' => 84, 'exp' => 250, 'gold' => 83, 'immune' => 0], - ['name' => 'Aqua Elemental', 'level' => 31, 'hp' => 120, 'atk' => 110, 'def' => 90, 'exp' => 260, 'gold' => 87, 'immune' => 1], - ['name' => 'Fire Wyrm', 'level' => 32, 'hp' => 120, 'atk' => 110, 'def' => 90, 'exp' => 260, 'gold' => 87, 'immune' => 0], - ['name' => 'Lesser Wyvern', 'level' => 32, 'hp' => 122, 'atk' => 110, 'def' => 92, 'exp' => 270, 'gold' => 90, 'immune' => 0], - ['name' => 'Doomer', 'level' => 32, 'hp' => 124, 'atk' => 112, 'def' => 92, 'exp' => 270, 'gold' => 90, 'immune' => 0], - ['name' => 'Armor Knight', 'level' => 33, 'hp' => 130, 'atk' => 115, 'def' => 95, 'exp' => 280, 'gold' => 93, 'immune' => 0], - ['name' => 'Wyvern', 'level' => 33, 'hp' => 134, 'atk' => 120, 'def' => 95, 'exp' => 290, 'gold' => 97, 'immune' => 0], - ['name' => 'Nightmare', 'level' => 33, 'hp' => 138, 'atk' => 125, 'def' => 100, 'exp' => 300, 'gold' => 100, 'immune' => 0], - ['name' => 'Fira Elemental', 'level' => 34, 'hp' => 140, 'atk' => 125, 'def' => 100, 'exp' => 310, 'gold' => 103, 'immune' => 1], - ['name' => 'Megadoomer', 'level' => 34, 'hp' => 140, 'atk' => 128, 'def' => 105, 'exp' => 320, 'gold' => 107, 'immune' => 0], - ['name' => 'Greater Wyvern', 'level' => 34, 'hp' => 145, 'atk' => 130, 'def' => 105, 'exp' => 335, 'gold' => 112, 'immune' => 0], - ['name' => 'Advocate', 'level' => 35, 'hp' => 148, 'atk' => 132, 'def' => 108, 'exp' => 350, 'gold' => 117, 'immune' => 0], - ['name' => 'Strong Knight', 'level' => 35, 'hp' => 150, 'atk' => 135, 'def' => 110, 'exp' => 365, 'gold' => 122, 'immune' => 0], - ['name' => 'Liche', 'level' => 35, 'hp' => 150, 'atk' => 135, 'def' => 110, 'exp' => 380, 'gold' => 127, 'immune' => 0], - ['name' => 'Ultradoomer', 'level' => 36, 'hp' => 155, 'atk' => 140, 'def' => 115, 'exp' => 395, 'gold' => 132, 'immune' => 0], - ['name' => 'Fanatic', 'level' => 36, 'hp' => 160, 'atk' => 140, 'def' => 115, 'exp' => 410, 'gold' => 137, 'immune' => 0], - ['name' => 'Green Dragon', 'level' => 36, 'hp' => 160, 'atk' => 140, 'def' => 115, 'exp' => 425, 'gold' => 142, 'immune' => 0], - ['name' => 'Fiend', 'level' => 37, 'hp' => 160, 'atk' => 145, 'def' => 120, 'exp' => 445, 'gold' => 148, 'immune' => 0], - ['name' => 'Greatest Wyvern', 'level' => 37, 'hp' => 162, 'atk' => 150, 'def' => 120, 'exp' => 465, 'gold' => 155, 'immune' => 0], - ['name' => 'Lesser Devil', 'level' => 37, 'hp' => 164, 'atk' => 150, 'def' => 120, 'exp' => 485, 'gold' => 162, 'immune' => 0], - ['name' => 'Liche Master', 'level' => 38, 'hp' => 168, 'atk' => 155, 'def' => 125, 'exp' => 505, 'gold' => 168, 'immune' => 0], - ['name' => 'Zealot', 'level' => 38, 'hp' => 168, 'atk' => 155, 'def' => 125, 'exp' => 530, 'gold' => 177, 'immune' => 0], - ['name' => 'Serafiend', 'level' => 38, 'hp' => 170, 'atk' => 155, 'def' => 125, 'exp' => 555, 'gold' => 185, 'immune' => 0], - ['name' => 'Pale Knight', 'level' => 39, 'hp' => 175, 'atk' => 160, 'def' => 130, 'exp' => 580, 'gold' => 193, 'immune' => 0], - ['name' => 'Blue Dragon', 'level' => 39, 'hp' => 180, 'atk' => 160, 'def' => 130, 'exp' => 605, 'gold' => 202, 'immune' => 0], - ['name' => 'Obsessive', 'level' => 40, 'hp' => 180, 'atk' => 160, 'def' => 135, 'exp' => 630, 'gold' => 210, 'immune' => 0], - ['name' => 'Devil', 'level' => 40, 'hp' => 184, 'atk' => 164, 'def' => 135, 'exp' => 666, 'gold' => 222, 'immune' => 0], - ['name' => 'Liche Prince', 'level' => 40, 'hp' => 190, 'atk' => 168, 'def' => 138, 'exp' => 660, 'gold' => 220, 'immune' => 0], - ['name' => 'Cherufiend', 'level' => 41, 'hp' => 195, 'atk' => 170, 'def' => 140, 'exp' => 690, 'gold' => 230, 'immune' => 0], - ['name' => 'Red Dragon', 'level' => 41, 'hp' => 200, 'atk' => 180, 'def' => 145, 'exp' => 720, 'gold' => 240, 'immune' => 0], - ['name' => 'Greater Devil', 'level' => 41, 'hp' => 200, 'atk' => 180, 'def' => 145, 'exp' => 750, 'gold' => 250, 'immune' => 0], - ['name' => 'Renegade', 'level' => 42, 'hp' => 205, 'atk' => 185, 'def' => 150, 'exp' => 780, 'gold' => 260, 'immune' => 0], - ['name' => 'Archfiend', 'level' => 42, 'hp' => 210, 'atk' => 190, 'def' => 150, 'exp' => 810, 'gold' => 270, 'immune' => 0], - ['name' => 'Liche Lord', 'level' => 42, 'hp' => 210, 'atk' => 190, 'def' => 155, 'exp' => 850, 'gold' => 283, 'immune' => 0], - ['name' => 'Greatest Devil', 'level' => 43, 'hp' => 215, 'atk' => 195, 'def' => 160, 'exp' => 890, 'gold' => 297, 'immune' => 0], - ['name' => 'Dark Knight', 'level' => 43, 'hp' => 220, 'atk' => 200, 'def' => 160, 'exp' => 930, 'gold' => 310, 'immune' => 0], - ['name' => 'Giant', 'level' => 43, 'hp' => 220, 'atk' => 200, 'def' => 165, 'exp' => 970, 'gold' => 323, 'immune' => 0], - ['name' => 'Shadow Dragon', 'level' => 44, 'hp' => 225, 'atk' => 200, 'def' => 170, 'exp' => 1010, 'gold' => 337, 'immune' => 0], - ['name' => 'Liche King', 'level' => 44, 'hp' => 225, 'atk' => 205, 'def' => 170, 'exp' => 1050, 'gold' => 350, 'immune' => 0], - ['name' => 'Incubus', 'level' => 44, 'hp' => 230, 'atk' => 205, 'def' => 175, 'exp' => 1100, 'gold' => 367, 'immune' => 1], - ['name' => 'Traitor', 'level' => 45, 'hp' => 230, 'atk' => 205, 'def' => 175, 'exp' => 1150, 'gold' => 383, 'immune' => 0], - ['name' => 'Demon', 'level' => 45, 'hp' => 240, 'atk' => 210, 'def' => 180, 'exp' => 1200, 'gold' => 400, 'immune' => 0], - ['name' => 'Dark Dragon', 'level' => 45, 'hp' => 245, 'atk' => 215, 'def' => 180, 'exp' => 1250, 'gold' => 417, 'immune' => 1], - ['name' => 'Insurgent', 'level' => 46, 'hp' => 250, 'atk' => 220, 'def' => 190, 'exp' => 1300, 'gold' => 433, 'immune' => 0], - ['name' => 'Leviathan', 'level' => 46, 'hp' => 255, 'atk' => 225, 'def' => 190, 'exp' => 1350, 'gold' => 450, 'immune' => 0], - ['name' => 'Grey Daemon', 'level' => 46, 'hp' => 260, 'atk' => 230, 'def' => 190, 'exp' => 1400, 'gold' => 467, 'immune' => 0], - ['name' => 'Succubus', 'level' => 47, 'hp' => 265, 'atk' => 240, 'def' => 200, 'exp' => 1460, 'gold' => 487, 'immune' => 1], - ['name' => 'Demon Prince', 'level' => 47, 'hp' => 270, 'atk' => 240, 'def' => 200, 'exp' => 1520, 'gold' => 507, 'immune' => 0], - ['name' => 'Black Dragon', 'level' => 47, 'hp' => 275, 'atk' => 250, 'def' => 205, 'exp' => 1580, 'gold' => 527, 'immune' => 1], - ['name' => 'Nihilist', 'level' => 47, 'hp' => 280, 'atk' => 250, 'def' => 205, 'exp' => 1640, 'gold' => 547, 'immune' => 0], - ['name' => 'Behemoth', 'level' => 48, 'hp' => 285, 'atk' => 260, 'def' => 210, 'exp' => 1700, 'gold' => 567, 'immune' => 0], - ['name' => 'Demagogue', 'level' => 48, 'hp' => 290, 'atk' => 260, 'def' => 210, 'exp' => 1760, 'gold' => 587, 'immune' => 0], - ['name' => 'Demon Lord', 'level' => 48, 'hp' => 300, 'atk' => 270, 'def' => 220, 'exp' => 1820, 'gold' => 607, 'immune' => 0], - ['name' => 'Red Daemon', 'level' => 48, 'hp' => 310, 'atk' => 280, 'def' => 230, 'exp' => 1880, 'gold' => 627, 'immune' => 0], - ['name' => 'Colossus', 'level' => 49, 'hp' => 320, 'atk' => 300, 'def' => 240, 'exp' => 1940, 'gold' => 647, 'immune' => 0], - ['name' => 'Demon King', 'level' => 49, 'hp' => 330, 'atk' => 300, 'def' => 250, 'exp' => 2000, 'gold' => 667, 'immune' => 0], - ['name' => 'Dark Daemon', 'level' => 49, 'hp' => 340, 'atk' => 320, 'def' => 260, 'exp' => 2200, 'gold' => 733, 'immune' => 1], - ['name' => 'Titan', 'level' => 50, 'hp' => 360, 'atk' => 340, 'def' => 270, 'exp' => 2400, 'gold' => 800, 'immune' => 0], - ['name' => 'Black Daemon', 'level' => 50, 'hp' => 400, 'atk' => 400, 'def' => 280, 'exp' => 3000, 'gold' => 1000, 'immune' => 1], - ['name' => 'Lucifuge', 'level' => 50, 'hp' => 600, 'atk' => 600, 'def' => 400, 'exp' => 10000, 'gold' => 10000, 'immune' => 2], - ]); - } - - // Create News table - $db->table('news')->create([ - 'id INTEGER PRIMARY KEY', - 'posted DATETIME DEFAULT CURRENT_TIMESTAMP', - 'author INTEGER DEFAULT 1', - "title TEXT DEFAULT ''", - "content TEXT DEFAULT ''" - ]); - - // Create Spells table - $db->table('spells')->create([ - 'id INTEGER PRIMARY KEY', - 'name TEXT NOT NULL', - 'type INTEGER DEFAULT 1', - 'mp INTEGER DEFAULT 0', - "effect TEXT DEFAULT ''", - "icon TEXT DEFAULT ''" - ]); - - // Fill spells if complete install - if ($complete) { - $db->table('spells')->insert([ - // Type 1 = healing - ['name' => 'Heal', 'type' => 1, 'mp' => 5, 'effect' => 'heal:self,10', 'icon' => 'heal.png' ], // 1 - ['name' => 'Cure', 'type' => 1, 'mp' => 10, 'effect' => 'heal:self,25', 'icon' => 'cure.png' ], // 2 - ['name' => 'Breath', 'type' => 1, 'mp' => 25, 'effect' => 'heal:self,50', 'icon' => 'breath.png'], // 3 - ['name' => 'Revive', 'type' => 1, 'mp' => 50, 'effect' => 'heal:self,100', 'icon' => 'revive.png'], // 4 - ['name' => 'Gaia', 'type' => 1, 'mp' => 75, 'effect' => 'heal:self,150', 'icon' => 'gaia.png' ], // 5 - - // Type 2 = damage - ['name' => 'Slash', 'type' => 2, 'mp' => 5, 'effect' => 'damage:opp,10', 'icon' => 'slash.png' ], // 6 - ['name' => 'Magic Missile', 'type' => 2, 'mp' => 12, 'effect' => 'damage:opp,35', 'icon' => 'missile.png' ], // 7 - ['name' => 'Fireball', 'type' => 2, 'mp' => 25, 'effect' => 'damage:opp,70', 'icon' => 'fireball.png' ], // 8 - ['name' => 'Pain', 'type' => 2, 'mp' => 40, 'effect' => 'damage:opp,100', 'icon' => 'pain.png' ], // 9 - ['name' => 'Lightning', 'type' => 2, 'mp' => 50, 'effect' => 'damage:opp,130', 'icon' => 'lightning.png'], // 10 - ['name' => 'Chaos', 'type' => 2, 'mp' => 75, 'effect' => 'damage:opp,200', 'icon' => 'chaos.png' ], // 11 - - // Type 3 = sleep - ['name' => 'Sleep', 'type' => 3, 'mp' => 10, 'effect' => 'sleep:opp,3', 'icon' => 'sleep.png' ], // 12 - ['name' => 'Dream', 'type' => 3, 'mp' => 30, 'effect' => 'sleep:opp,6', 'icon' => 'dream.png' ], // 13 - ['name' => 'Nightmare', 'type' => 3, 'mp' => 60, 'effect' => 'sleep:opp,13', 'icon' => 'nightmare.png'], // 14 - - // Type 4 = rage - ['name' => 'Craze', 'type' => 4, 'mp' => 10, 'effect' => 'rage:self,3', 'icon' => 'craze.png'], // 15 - ['name' => 'Rage', 'type' => 4, 'mp' => 30, 'effect' => 'rage:self,6', 'icon' => 'rage.png' ], // 16 - ['name' => 'Fury', 'type' => 4, 'mp' => 60, 'effect' => 'rage:self,13', 'icon' => 'fury.png' ], // 17 - - // Type 5 = protect - ['name' => 'Ward', 'type' => 5, 'mp' => 10, 'effect' => 'protect:self,3', 'icon' => 'ward.png' ], // 18 - ['name' => 'Guard', 'type' => 5, 'mp' => 30, 'effect' => 'protect:self,6', 'icon' => 'guard.png' ], // 19 - ['name' => 'Barrier', 'type' => 5, 'mp' => 60, 'effect' => 'protect:self,13', 'icon' => 'barrier.png'] // 20 - ]); - } - - // Create Towns table - $db->table('towns')->create([ - 'id INTEGER PRIMARY KEY', - 'name TEXT NOT NULL', - 'x INTEGER DEFAULT 0', - 'y INTEGER DEFAULT 0', - 'inn_cost INTEGER DEFAULT 0', - 'map_cost INTEGER DEFAULT 5', - 'tp_cost INTEGER DEFAULT 0', - "shop_list TEXT DEFAULT ''", - "image TEXT DEFAULT ''", - ]); - - // Fill towns table if complete install - if ($complete) { - $db->insert([ - ['name' => 'Midworld', 'x' => 0, 'y' => 0, 'inn_cost' => 5, 'map_cost' => 5, 'tp_cost' => 0, 'shop_list' => '1,2,3,17,18,19,28,29', 'image' => 'midworld.png'], - ['name' => 'Roma', 'x' => 30, 'y' => 30, 'inn_cost' => 10, 'map_cost' => 25, 'tp_cost' => 5, 'shop_list' => '2,3,4,18,19,29', 'image' => 'roma.png' ], - ['name' => 'Bris', 'x' => 70, 'y' => -70, 'inn_cost' => 25, 'map_cost' => 50, 'tp_cost' => 15, 'shop_list' => '2,3,4,5,18,19,20,29,30', 'image' => 'bris.png' ], - ['name' => 'Kalle', 'x' => -100, 'y' => 100, 'inn_cost' => 40, 'map_cost' => 100, 'tp_cost' => 30, 'shop_list' => '5,6,8,10,12,21,22,23,29,30', 'image' => 'kalle.png' ], - ['name' => 'Narcissa', 'x' => -130, 'y' => -130, 'inn_cost' => 60, 'map_cost' => 500, 'tp_cost' => 50, 'shop_list' => '4,7,9,11,13,21,22,23,29,30,31', 'image' => 'narcissa.png'], - ['name' => 'Hambry', 'x' => 170, 'y' => 170, 'inn_cost' => 90, 'map_cost' => 1000, 'tp_cost' => 80, 'shop_list' => '10,11,12,13,14,23,24,30,31', 'image' => 'hambry.png' ], - ['name' => 'Gilead', 'x' => 200, 'y' => -200, 'inn_cost' => 100, 'map_cost' => 3000, 'tp_cost' => 110,'shop_list' => '12,13,14,15,24,25,26,32', 'image' => 'gilead.png' ], - ['name' => 'Endworld', 'x' => -250, 'y' => -250, 'inn_cost' => 150, 'map_cost' => 9000, 'tp_cost' => 160,'shop_list' => '16,27,33', 'image' => 'endworld.png'], - ]); - } - - // Create Players table - $db->table('players')->create([ - 'id INTEGER PRIMARY KEY', - 'username TEXT NOT NULL', - 'password TEXT NOT NULL', - "email TEXT DEFAULT ''", - 'verified INTEGER DEFAULT 1', - 'registered DATETIME DEFAULT CURRENT_TIMESTAMP', - 'last_online DATETIME DEFAULT CURRENT_TIMESTAMP', - 'currently INTEGER DEFAULT 0', - 'role INTEGER DEFAULT 1', - 'class_id INTEGER DEFAULT 1', - 'level INTEGER DEFAULT 1', - 'exp INTEGER DEFAULT 0', - 'gold INTEGER DEFAULT 0', - 'stat_points INTEGER DEFAULT 0', - 'hp INTEGER DEFAULT 0', - 'max_hp INTEGER DEFAULT 0', - 'mp INTEGER DEFAULT 0', - 'max_mp INTEGER DEFAULT 0', - 'tp INTEGER DEFAULT 0', - 'max_tp INTEGER DEFAULT 0', - 'str INTEGER DEFAULT 0', - 'atk INTEGER DEFAULT 0', - 'dex INTEGER DEFAULT 0', - 'def INTEGER DEFAULT 0', - 'weapon_id INTEGER DEFAULT 0', - 'armor_id INTEGER DEFAULT 0', - 'shield_id INTEGER DEFAULT 0', - 'slot_1_id INTEGER DEFAULT 0', - 'slot_2_id INTEGER DEFAULT 0', - 'slot_3_id INTEGER DEFAULT 0', - "spells TEXT DEFAULT ''", - "maps TEXT DEFAULT ''", - ]); - - // Create Fights table - $db->table('fights')->create([ - 'id INTEGER PRIMARY KEY', - 'player_id INTEGER DEFAULT 1', - 'monster_id INTEGER DEFAULT 1', - 'turn INTEGER DEFAULT 1', - 'player_hp INTEGER DEFAULT 0', - 'player_mp INTEGER DEFAULT 0', - 'monster_hp INTEGER DEFAULT 0', - 'monster_mp INTEGER DEFAULT 0', - 'player_uber_dmg INTEGER DEFAULT 0', - 'monster_uber_dmg INTEGER DEFAULT 0', - 'player_uber_def INTEGER DEFAULT 0', - 'monster_uber_def INTEGER DEFAULT 0', - 'monster_immune INTEGER DEFAULT 0', - 'monster_sleep INTEGER DEFAULT 0', - ]); - - echo render('install/layout', ['title' => 'Database Setup', 'step' => 'second', 'complete' => $complete, 'start' => $istart]); - exit; -} - // Admin account; create it from the provided info if ($step == 'third') { $errors = []; diff --git a/server/app/database.php b/server/app/database.php index c70eafa..893f922 100644 --- a/server/app/database.php +++ b/server/app/database.php @@ -101,7 +101,7 @@ class Database // go through the row and put strings into single quotes $row = array_map(function ($column) { if (is_numeric($column)) return $column; - return "'" . str_replace("'", "\'", $column) . "'"; + return "'" . str_replace("'", "''", $column) . "'"; }, $row); // add the row to the query @@ -111,8 +111,6 @@ class Database // remove the trailing comma $query = rtrim($query, ',') . ';'; - dd($query); - // execute the insert return $this->q($query); } diff --git a/server/modules/InstallModule.php b/server/modules/InstallModule.php index a5a05d2..8a25d20 100644 --- a/server/modules/InstallModule.php +++ b/server/modules/InstallModule.php @@ -25,36 +25,29 @@ class InstallModule $istart = microtime(true); // time the database setup if (!isset($_POST['mode'])) redirect('/install'); // redirect if no mode $complete = $_POST['mode'] == 'complete'; // complete or partial setup - $resFmt = '%s (%ss)
'; $defaults = SERVER.'/database/packs/Default/'; - $results = ''; - // @Settings App::$db->q("CREATE TABLE IF NOT EXISTS 'settings' ( - id INTEGER PRIMARY KEY, - game_name TEXT DEFAULT 'Dragon Knight', - game_version TEXT DEFAULT '1.0', - game_dev TEXT DEFAULT 'Sharkk', - game_url TEXT DEFAULT 'https://dragonknight.dev', - game_size INT DEFAULT 250, - game_open INT DEFAULT 1, - admin_email TEXT DEFAULT 'admin@dragonknight.dev', - forum_type INT DEFAULT 1, - forum_url TEXT DEFAULT '', - verify_email INT DEFAULT 1, - show_news INT DEFAULT 1, - show_online INT DEFAULT 1, - show_babble INT DEFAULT 1 + 'id' INTEGER PRIMARY KEY, + 'game_name' TEXT DEFAULT 'Dragon Knight', + 'game_version' TEXT DEFAULT '1.0', + 'game_dev' TEXT DEFAULT 'Sharkk', + 'game_url' TEXT DEFAULT 'https://dragonknight.dev', + 'game_size' INT DEFAULT 250, + 'game_open' INT DEFAULT 1, + 'admin_email' TEXT DEFAULT 'admin@dragonknight.dev', + 'forum_type' INT DEFAULT 1, + 'forum_url' TEXT DEFAULT '', + 'verify_email' INT DEFAULT 1, + 'show_news' INT DEFAULT 1, + 'show_online' INT DEFAULT 1, + 'show_babble' INT DEFAULT 1 );"); - $results .= sprintf($resFmt, 'Settings table created', stopwatch($istart)); - // insert default settings App::$db->q("INSERT INTO settings DEFAULT VALUES;"); - $results .= sprintf($resFmt, 'Default settings inserted', stopwatch($istart)); - // @Classes App::$db->q("CREATE TABLE IF NOT EXISTS 'classes' ( 'id' INTEGER PRIMARY KEY, @@ -74,47 +67,169 @@ class InstallModule 'spells' TEXT DEFAULT '' );"); - $results .= sprintf($resFmt, 'Classes table created', stopwatch($istart)); - if ($complete) { // add default classes if complete install App::$db->insertFromCSV('classes', "$defaults/classes.csv"); } else { - // there must be at least one class, for user creation to work + // there must be at least one class for user creation to work App::$db->q("INSERT INTO classes (name) VALUES ('Adventurer');"); } - $results .= sprintf($resFmt, 'Default classes inserted', stopwatch($istart)); - // @Babble App::$db->q("CREATE TABLE IF NOT EXISTS 'babble' ( - id INTEGER PRIMARY KEY, - author INTEGER NOT NULL, - babble TEXT NOT NULL, - posted DATETIME DEFAULT CURRENT_TIMESTAMP + 'id' INTEGER PRIMARY KEY, + 'author' INTEGER NOT NULL, + 'babble' TEXT NOT NULL, + 'posted' DATETIME DEFAULT CURRENT_TIMESTAMP );"); - $results .= sprintf($resFmt, 'Babble table created', stopwatch($istart)); - // @Drops App::$db->q("CREATE TABLE IF NOT EXISTS 'drops' ( - id INTEGER PRIMARY KEY, - name TEXT NOT NULL, - level INTEGER DEFAULT 1, - type INTEGER DEFAULT 1, - attr TEXT DEFAULT '' + 'id' INTEGER PRIMARY KEY, + 'name' TEXT NOT NULL, + 'level' INTEGER DEFAULT 1, + 'type' INTEGER DEFAULT 1, + 'attr' TEXT DEFAULT '' );"); + // add default drops if complete install + if ($complete) App::$db->insertFromCSV('drops', "$defaults/drops.csv"); - $results .= sprintf($resFmt, 'Drops table created', stopwatch($istart)); + // @Forum + App::$db->q("CREATE TABLE IF NOT EXISTS 'forum' ( + 'id' INTEGER PRIMARY KEY, + 'posted' DATETIME DEFAULT CURRENT_TIMESTAMP, + 'new_post' DATETIME DEFAULT CURRENT_TIMESTAMP, + 'author' INTEGER NOT NULL, + 'subject' TEXT DEFAULT '', + 'message' TEXT DEFAULT '', + 'locked' INTEGER DEFAULT 0, + 'sticky' INTEGER DEFAULT 0, + 'parent' INTEGER DEFAULT 0, + 'posts' INTEGER DEFAULT 0, + 'views' INTEGER DEFAULT 0, + 'hidden' INTEGER DEFAULT 0 + );"); - if ($complete) { - // add default drops if complete install - App::$db->insertFromCSV('drops', "$defaults/drops.csv"); + // @Items + App::$db->q("CREATE TABLE IF NOT EXISTS 'items' ( + 'id' INTEGER PRIMARY KEY, + 'type' INTEGER DEFAULT 1, + 'name' TEXT NOT NULL, + 'cost' INTEGER DEFAULT 0, + 'attr' TEXT DEFAULT '', + 'icon' TEXT DEFAULT '' + );"); - $results .= sprintf($resFmt, 'Default drops inserted', stopwatch($istart)); - } + // add default items if complete install + if ($complete) App::$db->insertFromCSV('items', "$defaults/items.csv"); - echo $results; + // @Monsters + App::$db->q("CREATE TABLE IF NOT EXISTS 'monsters' ( + 'id' INTEGER PRIMARY KEY, + 'name' TEXT NOT NULL, + 'level' INTEGER DEFAULT 1, + 'hp' INTEGER DEFAULT 1, + 'atk' INTEGER DEFAULT 1, + 'def' INTEGER DEFAULT 1, + 'exp' INTEGER DEFAULT 1, + 'gold' INTEGER DEFAULT 1, + 'immune' INTEGER DEFAULT 0, + 'image' TEXT DEFAULT '' + );"); + + // add default monsters if complete install + if ($complete) App::$db->insertFromCSV('monsters', "$defaults/monsters.csv"); + + // @News + App::$db->q("CREATE TABLE IF NOT EXISTS 'news' ( + 'id' INTEGER PRIMARY KEY, + 'author' INTEGER DEFAULT 1, + 'title' TEXT DEFAULT '', + 'content' TEXT DEFAULT '', + 'posted' DATETIME DEFAULT CURRENT_TIMESTAMP + );"); + + // @Spells + App::$db->q("CREATE TABLE IF NOT EXISTS 'spells' ( + 'id' INTEGER PRIMARY KEY, + 'name' TEXT NOT NULL, + 'type' INTEGER DEFAULT 1, + 'mp' INTEGER DEFAULT 0, + 'effect' TEXT DEFAULT '', + 'icon' TEXT DEFAULT '' + );"); + + // add default spells if complete install + if ($complete) App::$db->insertFromCSV('spells', "$defaults/spells.csv"); + + // @Towns + App::$db->q("CREATE TABLE IF NOT EXISTS 'towns' ( + 'id' INTEGER PRIMARY KEY, + 'name' TEXT NOT NULL, + 'x' INTEGER DEFAULT 0, + 'y' INTEGER DEFAULT 0, + 'inn_cost' INTEGER DEFAULT 0, + 'map_cost' INTEGER DEFAULT 5, + 'tp_cost' INTEGER DEFAULT 0, + 'shop_list' TEXT DEFAULT '', + 'image' TEXT DEFAULT '' + );"); + + // add default towns if complete install + if ($complete) App::$db->insertFromCSV('towns', "$defaults/towns.csv"); + + // @Players + App::$db->q("CREATE TABLE IF NOT EXISTS 'players' ( + 'id' INTEGER PRIMARY KEY, + 'username' TEXT NOT NULL, + 'password' TEXT NOT NULL, + 'email' TEXT DEFAULT '', + 'verified' INTEGER DEFAULT 1, + 'registered' DATETIME DEFAULT CURRENT_TIMESTAMP, + 'last_online' DATETIME DEFAULT CURRENT_TIMESTAMP, + 'currently' INTEGER DEFAULT 0, + 'role' INTEGER DEFAULT 1, + 'class_id' INTEGER DEFAULT 1, + 'level' INTEGER DEFAULT 1, + 'exp' INTEGER DEFAULT 0, + 'gold' INTEGER DEFAULT 0, + 'stat_points' INTEGER DEFAULT 0, + 'hp' INTEGER DEFAULT 0, + 'max_hp' INTEGER DEFAULT 0, + 'mp' INTEGER DEFAULT 0, + 'max_mp' INTEGER DEFAULT 0, + 'tp' INTEGER DEFAULT 0, + 'max_tp' INTEGER DEFAULT 0, + 'str' INTEGER DEFAULT 0, + 'atk' INTEGER DEFAULT 0, + 'dex' INTEGER DEFAULT 0, + 'def' INTEGER DEFAULT 0, + 'weapon_id' INTEGER DEFAULT 0, + 'armor_id' INTEGER DEFAULT 0, + 'shield_id' INTEGER DEFAULT 0, + 'slot_1_id' INTEGER DEFAULT 0, + 'slot_2_id' INTEGER DEFAULT 0, + 'slot_3_id' INTEGER DEFAULT 0, + 'spells' TEXT DEFAULT '', + 'maps' TEXT DEFAULT '' + );"); + + // @Fights + App::$db->q("CREATE TABLE IF NOT EXISTS 'fights' ( + 'id' INTEGER PRIMARY KEY, + 'p_id' INTEGER DEFAULT 1, + 'm_id' INTEGER DEFAULT 1, + 'turn' INTEGER DEFAULT 1, + 'p_hp' INTEGER DEFAULT 0, + 'p_maxhp' INTEGER DEFAULT 0, + 'p_mp' INTEGER DEFAULT 0, + 'p_maxmp' INTEGER DEFAULT 0, + 'm_hp' INTEGER DEFAULT 0, + 'm_maxhp' INTEGER DEFAULT 0, + 'condi' TEXT DEFAULT '' + );"); + + echo render('install/layout', ['title' => 'Database Setup', 'step' => 'second', 'complete' => $complete, 'start' => $istart]); } } \ No newline at end of file diff --git a/server/templates/install/second.php b/server/templates/install/second.php index 1121510..497840b 100644 --- a/server/templates/install/second.php +++ b/server/templates/install/second.php @@ -22,4 +22,4 @@ panel.

- $complete]) ?> + $complete]) ?> \ No newline at end of file