diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcaeb05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +game.db diff --git a/config.php b/config.php index 27a3181..0fcab2d 100644 --- a/config.php +++ b/config.php @@ -25,7 +25,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { exit; } -$stmt = $db->query('SELECT * FROM configuration'); +$stmt = $db->query('SELECT name, value FROM configuration'); $config = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); ?> diff --git a/database.php b/database.php index 27804ac..ce2ed75 100644 --- a/database.php +++ b/database.php @@ -12,7 +12,13 @@ * @link https://git.keithsolomon.net/keith/Warframe_Shopping_List */ -$db = new PDO('sqlite:game.db'); +$dbFile = 'game.db'; + +if (!file_exists($dbFile)) { + touch($dbFile); +} + +$db = new PDO('sqlite:' . $dbFile); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/game.php b/game.php index e40d012..e31458f 100644 --- a/game.php +++ b/game.php @@ -17,7 +17,7 @@ session_start(); require_once 'database.php'; // Fetch configuration from the database -$stmt = $db->query('SELECT * FROM configuration'); +$stmt = $db->query('SELECT name, value FROM configuration'); $config = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); if (!isset($_SESSION['scores'])) { @@ -31,7 +31,7 @@ if (!isset($_SESSION['scores'])) { $action = $_GET['action'] ?? ''; if ($action === 'roll_dice') { - $event = roll_dice($config); + $event = rollDice($config); $gameState = checkGameState($config); if ($gameState !== 'ongoing') { diff --git a/script.js b/script.js index d11bce6..b6c5db8 100644 --- a/script.js +++ b/script.js @@ -71,7 +71,7 @@ document.addEventListener('DOMContentLoaded', () => { if (gameState !== 'ongoing') { rollButton.disabled = true; assassinateButton.disabled = true; - newGameButton.style.display = 'block'; + newGameButton.style.display = 'inline-block'; let message = ''; if (gameState === 'win') { message = 'You have escaped the city! You win!'; @@ -87,4 +87,4 @@ document.addEventListener('DOMContentLoaded', () => { setTimeout(() => alert(message), 100); } } -}); \ No newline at end of file +});