🐞 fix: Update functions to work, make new game button stay inline
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
game.db
|
||||
@@ -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);
|
||||
?>
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
4
game.php
4
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') {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user