🐞 fix: Update functions to work, make new game button stay inline

This commit is contained in:
Keith Solomon
2025-08-15 18:51:11 -05:00
parent 17e925ec8e
commit 428d111cf7
5 changed files with 13 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
game.db

View File

@@ -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);
?>

View File

@@ -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);

View File

@@ -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') {

View File

@@ -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!';