diff --git a/.gitignore b/.gitignore
index 24cee78..995c1f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
server/database/dragon.db
+server/database/dragon.db-shm
+server/database/dragon.db-wal
server/.installed
\ No newline at end of file
diff --git a/public/css/dragon.css b/public/css/dragon.css
index fe19365..01c72c1 100644
--- a/public/css/dragon.css
+++ b/public/css/dragon.css
@@ -8,7 +8,7 @@ body {
background-repeat: repeat;
}
-#container {
+#install-container {
max-width: 996px;
margin: 0 auto;
}
diff --git a/public/guide/index.php b/public/guide/index.php
deleted file mode 100644
index 9ef6082..0000000
--- a/public/guide/index.php
+++ /dev/null
@@ -1,22 +0,0 @@
-table('control')->select();
-
-const GUIDES = ['main', 'items', 'monsters', 'spells', 'classes'];
-$guide = isset($_GET['guide']) ? $_GET['guide'] : 'main';
-
-const TITLES = [
- 'main' => 'Main',
- 'items' => 'Items & Drops',
- 'monsters' => 'Monsters',
- 'spells' => 'Spells',
- 'classes' => 'Classes'
-];
-
-echo render('/guide/layout', ['guide' => $guide, 'db' => $db, 'control' => $control, 'title' => TITLES[$guide]]);
\ No newline at end of file
diff --git a/public/index.php b/public/index.php
index efdf27e..7d93d20 100644
--- a/public/index.php
+++ b/public/index.php
@@ -12,7 +12,7 @@ $route = App::$req->uri(0);
installRedirect($route);
if ($route == '/') return HomeModule::home();
-if ($route == '/install') return InstallModule::handle();
+if ($route == 'install') return InstallModule::handle();
// 404
http_response_code(404);
diff --git a/public/install/index.php b/public/install/doodie.php
similarity index 100%
rename from public/install/index.php
rename to public/install/doodie.php
diff --git a/server/bootstrap.php b/server/bootstrap.php
index 0dfed75..5217a25 100644
--- a/server/bootstrap.php
+++ b/server/bootstrap.php
@@ -28,7 +28,8 @@ const MAP = [
'Request' => SERVER.'/app/request.php',
// modules
- 'HomeModule' => SERVER.'/modules/HomeModule.php',
+ 'HomeModule' => SERVER.'/modules/HomeModule.php',
+ 'InstallModule' => SERVER.'/modules/InstallModule.php',
];
// autoloader
diff --git a/server/modules/InstallModule.php b/server/modules/InstallModule.php
index e69de29..20a3797 100644
--- a/server/modules/InstallModule.php
+++ b/server/modules/InstallModule.php
@@ -0,0 +1,92 @@
+uri(1) ?? ''; // second segment
+ $m = App::$req->method; // request method
+
+ if ($s == '' || $s == 'intro') return self::intro();
+ if ($s == 'database' && $m == 'POST') return self::database();
+ }
+
+ private static function intro()
+ {
+ echo render('install/layout', ['title' => 'Intro', 'step' => 'first']);
+ }
+
+ private static function database()
+ {
+ $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
+
+ $results = '';
+
+ // create Settings table
+ 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
+ );");
+
+ $results .= 'Settings table created. ('. stopwatch($istart) .'s)
';
+
+ // insert default settings
+ App::$db->q("INSERT INTO settings DEFAULT VALUES;");
+
+ $results .= 'Default settings inserted. ('. stopwatch($istart) .'s)
';
+
+ // create Classes table
+ App::$db->q("CREATE TABLE IF NOT EXISTS classes (
+ id INTEGER PRIMARY KEY,
+ name TEXT DEFAULT '',
+ start_hp INT DEFAULT 0,
+ start_mp INT DEFAULT 0,
+ start_str INT DEFAULT 0,
+ start_atk INT DEFAULT 0,
+ start_dex INT DEFAULT 0,
+ start_def INT DEFAULT 0
+ growth_hp INT DEFAULT 0,
+ growth_mp INT DEFAULT 0,
+ growth_str INT DEFAULT 0,
+ growth_atk INT DEFAULT 0,
+ growth_dex INT DEFAULT 0,
+ growth_def INT DEFAULT 0,
+ spells TEXT DEFAULT '',
+ );");
+
+ $results .= 'Classes table created. ('. stopwatch($istart) .'s)
';
+
+ 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');");
+ } 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)
';
+
+ echo $results;
+ }
+}
\ No newline at end of file
diff --git a/server/templates/install/first.php b/server/templates/install/first.php
index 3fc8f3a..0f0116c 100644
--- a/server/templates/install/first.php
+++ b/server/templates/install/first.php
@@ -25,8 +25,8 @@
Click the appropriate button below for your preferred installation method. -
diff --git a/server/templates/install/layout.php b/server/templates/install/layout.php index 075c3be..235d1e0 100644 --- a/server/templates/install/layout.php +++ b/server/templates/install/layout.php @@ -7,7 +7,7 @@ -