Dragon-Knight/server/app/app.php

33 lines
732 B
PHP
Raw Normal View History

<?php
/*
The app container exists to be a dependency container for the game.
*/
class App
{
public static Database $db;
2024-07-13 23:15:25 -05:00
private static string $dbPath;
public static Request $req;
public static array $s = []; // game settings
public function __construct(string $dbPath)
{
self::$req = new Request(); // the current request
self::$db = new Database($dbPath); // the database
2024-07-13 23:15:25 -05:00
self::$dbPath = $dbPath; // the database path
// load game settings
$s = self::$db->q('SELECT * FROM settings WHERE id = 1;');
self::$s = $s ? $s->fetch() : [];
2024-07-13 23:15:25 -05:00
}
public static function performDatabaseReset(): void
{
if (file_exists(self::$dbPath)) {
unlink(self::$dbPath);
self::$db = new Database(self::$dbPath);
}
}
}