From 0cdb25029f745dd1dfb664a23cdf7953d40586b2 Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Thu, 11 Jul 2024 21:53:36 -0500 Subject: [PATCH] Continue working on new install --- server/modules/InstallModule.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/server/modules/InstallModule.php b/server/modules/InstallModule.php index 20a3797..bd07a1c 100644 --- a/server/modules/InstallModule.php +++ b/server/modules/InstallModule.php @@ -25,10 +25,11 @@ 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 (%fs)
'; $results = ''; - // create Settings table + // @Settings App::$db->q("CREATE TABLE IF NOT EXISTS settings ( id INTEGER PRIMARY KEY, game_name TEXT DEFAULT 'Dragon Knight', @@ -46,14 +47,14 @@ class InstallModule show_babble INT DEFAULT 1 );"); - $results .= 'Settings table created. ('. stopwatch($istart) .'s)
'; + $results .= sprintf($resFmt, 'Settings table created', stopwatch($istart)); // insert default settings App::$db->q("INSERT INTO settings DEFAULT VALUES;"); - $results .= 'Default settings inserted. ('. stopwatch($istart) .'s)
'; + $results .= sprintf($resFmt, 'Default settings inserted', stopwatch($istart)); - // create Classes table + // @Classes App::$db->q("CREATE TABLE IF NOT EXISTS classes ( id INTEGER PRIMARY KEY, name TEXT DEFAULT '', @@ -72,21 +73,29 @@ class InstallModule spells TEXT DEFAULT '', );"); - $results .= 'Classes table created. ('. stopwatch($istart) .'s)
'; + $results .= sprintf($resFmt, 'Classes table created', stopwatch($istart)); if ($complete) { // add default classes if complete install App::$db->q("INSERT INTO classes VALUES - (1, 'Mage', 10, 10, 5, 5, 5, 5, 3, 5, 1, 3, 1, 3, '1:6,18'), - (2, 'Warrior', 20, 0, 10, 5, 10, 5, 6, 2, 3, 1, 3, 1, ''), - (3, 'Paladin', 15, 5, 5, 5, 10, 10, 4, 4, 2, 2, 2, 2, '1:1,15,18');"); + (1, 'Mage', 10, 10, 5, 5, 5, 5, 3, 5, 1, 3, 1, 3, '1:6,18'), + (2, 'Warrior', 20, 0, 10, 5, 10, 5, 6, 2, 3, 1, 3, 1, ''), + (3, 'Paladin', 15, 5, 5, 5, 10, 10, 4, 4, 2, 2, 2, 2, '1:1,15,18');"); } else { // there must be at least one class, for user creation to work App::$db->q("INSERT INTO classes (name) VALUES ('Adventurer');"); } - $results .= 'Default classes inserted. ('. stopwatch($istart) .'s)
'; + $results .= sprintf($resFmt, 'Default classes inserted', stopwatch($istart)); - echo $results; + // @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 + );"); + + $results .= sprintf($resFmt, 'Babble table created', stopwatch($istart)); } } \ No newline at end of file