Заявки на поединки. Начало.
This commit is contained in:
parent
1bf7a40fe9
commit
fdaadf69e6
43
arena.php
43
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);
|
||||
<?php if(Arena::fight()->hasNoPendingFights()): ?>
|
||||
<form method='post' id='newbattle'></form>
|
||||
<H3>Подать заявку на поединок</H3>
|
||||
<label for='startTime'>Начало боя</label>
|
||||
<select name='startTime' id='startTime' form='newbattle'>
|
||||
<option value=1 selected>через 1 минуту</option>
|
||||
<option value=3>через 3 минуты</option>
|
||||
<option value=5>через 5 минут</option>
|
||||
<option value=10>через 10 минут</option>
|
||||
</select>
|
||||
<br><br>
|
||||
<label>Размер команды (1-20)
|
||||
<input type='number' min='1' max='20' name='teamMembersQuantity' form='newbattle' value='5'>
|
||||
</label>
|
||||
<br><br>
|
||||
<input type='submit' value='Подать заявку' form='newbattle'>
|
||||
<?php endif; ?>
|
||||
<?= Arena::fight()->getPendingList() ?>
|
||||
<?php foreach (Arena::fight()->getPendingList() as $row): ?>
|
||||
<!-- !!PLACEHOLDER!! -->
|
||||
<div>
|
||||
User1, User2, User3
|
||||
<form method='post' style='display:inline'>
|
||||
<input type='hidden' name='teamId' value='1'>
|
||||
<input type='submit' value='Я за этих'>
|
||||
</form>
|
||||
<em>против</em>
|
||||
User4, User5, User6
|
||||
<form method='post' style='display:inline'>
|
||||
<input type='hidden' name='teamId' value='2'>
|
||||
<input type='submit' value='Я за этих'>
|
||||
</form>
|
||||
<? endforeach; ?>
|
||||
</div>
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
||||
///*
|
||||
// * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
||||
|
Loading…
Reference in New Issue
Block a user