112 lines
3.0 KiB
PHP
112 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* Database configuration for the Last Days of Rome.
|
|
*
|
|
* PHP version: 8.0+
|
|
*
|
|
* @category Database
|
|
* @package Rome
|
|
* @author Keith Solomon <keith@keithsolmon.net>
|
|
* @license MIT License
|
|
* @version GIT: $Id$
|
|
* @link https://git.keithsolomon.net/keith/Warframe_Shopping_List
|
|
*/
|
|
|
|
$dbFile = 'game.db';
|
|
|
|
if (!file_exists($dbFile)) {
|
|
touch($dbFile);
|
|
}
|
|
|
|
$db = new PDO('sqlite:' . $dbFile);
|
|
|
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
// Create tables if they don't exist
|
|
$db->exec(
|
|
'CREATE TABLE IF NOT EXISTS game_logs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
date_played DATETIME,
|
|
flames_score INTEGER,
|
|
desolation_score INTEGER,
|
|
relocation_score INTEGER,
|
|
end_condition TEXT
|
|
)'
|
|
);
|
|
|
|
$db->exec(
|
|
'CREATE TABLE IF NOT EXISTS configuration (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT,
|
|
value TEXT
|
|
)'
|
|
);
|
|
|
|
// Check if configuration is already seeded
|
|
$stmt = $db->query('SELECT COUNT(*) FROM configuration');
|
|
$count = $stmt->fetchColumn();
|
|
|
|
if ($count === 0) {
|
|
// Seed the configuration table
|
|
$config = [
|
|
['flames_win', '10'],
|
|
['desolation_win', '10'],
|
|
['relocation_win', '10'],
|
|
['assassination_win', '20'],
|
|
[
|
|
'imperial_palace_event_1',
|
|
'The emperor fiddles with manic glee. +1 Flames.'
|
|
],
|
|
[
|
|
'imperial_palace_event_2',
|
|
'The emperor raises another horse to the position of senator. +1 Desolation, +1 Relocation.'
|
|
],
|
|
[
|
|
'imperial_palace_event_3',
|
|
'It\'s execution night at the palace. +1 Relocation.'
|
|
],
|
|
[
|
|
'imperial_palace_event_4',
|
|
'The emperor screams like a baby. +1 Desolation.'
|
|
],
|
|
[
|
|
'imperial_palace_event_5',
|
|
'The emperor sits in front of the flame and commands it to obey. It does not. +1 Flames, +1 Relocation.'
|
|
],
|
|
[
|
|
'imperial_palace_event_6',
|
|
'Work continues on a house made of pure gold. It keeps melting. +1 Flames.'
|
|
],
|
|
[
|
|
'relative_unrest_event_1',
|
|
'People complain - this is unacceptable. Then they go about their business. +1 Relocation.'
|
|
],
|
|
[
|
|
'relative_unrest_event_2',
|
|
'There are no goods at market. +1 Desolation.'
|
|
],
|
|
[
|
|
'relative_unrest_event_3',
|
|
'You receive a letter asking you to reassert your faith in the emperor. In writing. +1 Relocation.'
|
|
],
|
|
[
|
|
'relative_unrest_event_4',
|
|
'Lions are released onto the streets. +1 Desolation, +1 Flames.'
|
|
],
|
|
[
|
|
'relative_unrest_event_5',
|
|
'Is Rome really over? +1 Desolation.'
|
|
],
|
|
[
|
|
'relative_unrest_event_6',
|
|
'The burnings will continue until morale improves. +1 Flames.'
|
|
],
|
|
];
|
|
|
|
$stmt = $db->prepare('INSERT INTO configuration (name, value) VALUES (?, ?)');
|
|
|
|
foreach ($config as $item) {
|
|
$stmt->execute($item);
|
|
}
|
|
}
|