Continue working on new install

This commit is contained in:
Sky Johnson 2024-07-11 21:53:36 -05:00
parent a3819f9e16
commit 0cdb25029f

View File

@ -25,10 +25,11 @@ class InstallModule
$istart = microtime(true); // time the database setup $istart = microtime(true); // time the database setup
if (!isset($_POST['mode'])) redirect('/install'); // redirect if no mode if (!isset($_POST['mode'])) redirect('/install'); // redirect if no mode
$complete = $_POST['mode'] == 'complete'; // complete or partial setup $complete = $_POST['mode'] == 'complete'; // complete or partial setup
$resFmt = '%s <span class="extra-data">(%fs)</span><br />';
$results = ''; $results = '';
// create Settings table // @Settings
App::$db->q("CREATE TABLE IF NOT EXISTS settings ( App::$db->q("CREATE TABLE IF NOT EXISTS settings (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
game_name TEXT DEFAULT 'Dragon Knight', game_name TEXT DEFAULT 'Dragon Knight',
@ -46,14 +47,14 @@ class InstallModule
show_babble INT DEFAULT 1 show_babble INT DEFAULT 1
);"); );");
$results .= 'Settings table created. ('. stopwatch($istart) .'s)<br />'; $results .= sprintf($resFmt, 'Settings table created', stopwatch($istart));
// insert default settings // insert default settings
App::$db->q("INSERT INTO settings DEFAULT VALUES;"); App::$db->q("INSERT INTO settings DEFAULT VALUES;");
$results .= 'Default settings inserted. ('. stopwatch($istart) .'s)<br />'; $results .= sprintf($resFmt, 'Default settings inserted', stopwatch($istart));
// create Classes table // @Classes
App::$db->q("CREATE TABLE IF NOT EXISTS classes ( App::$db->q("CREATE TABLE IF NOT EXISTS classes (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
name TEXT DEFAULT '', name TEXT DEFAULT '',
@ -72,21 +73,29 @@ class InstallModule
spells TEXT DEFAULT '', spells TEXT DEFAULT '',
);"); );");
$results .= 'Classes table created. ('. stopwatch($istart) .'s)<br />'; $results .= sprintf($resFmt, 'Classes table created', stopwatch($istart));
if ($complete) { if ($complete) {
// add default classes if complete install // add default classes if complete install
App::$db->q("INSERT INTO classes VALUES App::$db->q("INSERT INTO classes VALUES
(1, 'Mage', 10, 10, 5, 5, 5, 5, 3, 5, 1, 3, 1, 3, '1:6,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, ''), (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');"); (3, 'Paladin', 15, 5, 5, 5, 10, 10, 4, 4, 2, 2, 2, 2, '1:1,15,18');");
} else { } 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');"); App::$db->q("INSERT INTO classes (name) VALUES ('Adventurer');");
} }
$results .= 'Default classes inserted. ('. stopwatch($istart) .'s)<br />'; $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));
} }
} }