diff --git a/arena.php b/arena.php index 4b3312a..1af0ca1 100644 --- a/arena.php +++ b/arena.php @@ -6,7 +6,46 @@ use Battles\Arena; use Battles\Template; +if (isset($_POST['startTime']) && isset($_POST['teamMembersQuantity'])) { + Arena::fight()->addNew((int)$_POST['teamMembersQuantity'], 2, (int)$_POST['startTime']); +} +if (isset($_POST['fight_id']) && isset($_POST['team_id'])) { + Arena::fight()->join((int)$_POST['fight_id'], (int)$_POST['team_id']); +} Template::header('Арена'); +?> -$dbname = new SQLite3('name.db'); -Arena::$current = new Arena($dbname); \ No newline at end of file +hasNoPendingFights()): ?> +
+

Подать заявку на поединок

+ + +

+ +

+ + +getPendingList() ?> +getPendingList() as $row): ?> + +
+ User1, User2, User3 +
+ + +
+ против + User4, User5, User6 +
+ + +
+ +
\ No newline at end of file diff --git a/classes/Battles/Database/Db.php b/classes/Battles/Database/Db.php index a6c6a4d..ec183d4 100644 --- a/classes/Battles/Database/Db.php +++ b/classes/Battles/Database/Db.php @@ -74,7 +74,7 @@ class Db // Allows the user to retrieve results using a // column from the results as a key for the array if (!is_null($key) && $results[0][$key]) { - $keyed_results = array(); + $keyed_results = []; foreach ($results as $result) { $keyed_results[$result[$key]] = $result; } @@ -94,7 +94,7 @@ class Db return $stmt->fetch(PDO::FETCH_OBJ); } - public function ofetchAll($query, $values = null, $key = null): object + public function ofetchAll($query, $values = null) { if (is_null($values)) { $values = []; @@ -102,18 +102,7 @@ class Db $values = [$values]; } $stmt = $this->execute($query, $values); - $results = $stmt->fetchAll(PDO::FETCH_OBJ); - - // Allows the user to retrieve results using a - // column from the results as a key for the array - if (!is_null($key) && $results[0][$key]) { - $keyed_results = (object)[]; - foreach ($results as $result) { - $keyed_results->$result[$key] = $result; - } - $results = $keyed_results; - } - return $results; + return $stmt->fetchAll(PDO::FETCH_OBJ); } public function lastInsertId() diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 5440af0..d3236a5 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -28,7 +28,6 @@ class User // Пока несуществующие, для совместимости. protected int $experience = 0; - protected int $battle = 0; protected int $in_tower = 0; // Скорее башню похороним чем запустим... protected int $zayavka = 0; @@ -77,6 +76,7 @@ class User { if (Db::getInstance()->fetchColumn('SELECT 1 FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type])) { Db::getInstance()->execute('DELETE FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type]); + return true; } return false; } @@ -218,7 +218,7 @@ class User public function getBattle(): int { - return $this->battle; + return Arena::fight()->hasNoActiveFights(); } public function getInTower(): int diff --git a/functions.php b/functions.php index 7057804..f329793 100644 --- a/functions.php +++ b/functions.php @@ -24,7 +24,7 @@ if (User::getInstance()->getBlock()) { } //Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам. -Travel::roomRedirects(User::$current->getRoom(), User::$current->getBattle(), User::$current->getInTower()); +Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle(), User::getInstance()->getInTower()); ///* // * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.