From 428d111cf75829003d3e2307695e8a0092abea84 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Fri, 15 Aug 2025 18:51:11 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20Update=20functions=20to?= =?UTF-8?q?=20work,=20make=20new=20game=20button=20stay=20inline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + config.php | 2 +- database.php | 8 +++++++- game.php | 4 ++-- script.js | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .gitignore 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 +});