Merge remote-tracking branch 'origin/master' into dev-arena

This commit is contained in:
Ivor Barhansky 2022-06-11 03:24:36 +03:00
commit f3e0b73931
19 changed files with 377 additions and 355 deletions

View File

@ -1,10 +1,17 @@
<?php <?php
# Date: 31.01.2021 (20:21) # Date: 31.01.2021 (20:21)
require_once '../config.php';
use Battles\Admin\Item;
if (isset($_POST)) {
Item::add($_POST);
}
?> ?>
<form method=post> <form method=post>
<div> <div>
<table> <table>
<caption>Добавление вещей в магазин</caption> <caption>Добавление вещей в игру</caption>
<tr> <tr>
<th id="main">Основное <th id="main">Основное
<tr> <tr>
@ -18,7 +25,7 @@
<option value="2">Цветной</option> <option value="2">Цветной</option>
</select> </select>
<tr> <tr>
<td><input name=count placeholder="Количество (шт.)"> <td><input name=count placeholder="Количество (шт.)" disabled>
<tr> <tr>
<td><select name="item_type"> <td><select name="item_type">
<option value="0" selected disabled>Тип предмета</option> <option value="0" selected disabled>Тип предмета</option>
@ -41,7 +48,7 @@
<tr> <tr>
<td><input name=durability placeholder="Макс. износ"> <td><input name=durability placeholder="Макс. износ">
<tr> <tr>
<td><input name=price placeholder="Цена (кр.)"> <td><input name=price placeholder="Цена (кр.)" disabled>
<tr> <tr>
<th id="needs">Требования <th id="needs">Требования
<tr> <tr>
@ -65,79 +72,29 @@
<tr> <tr>
<td><input name=maxu placeholder="Макс.урон"> <td><input name=maxu placeholder="Макс.урон">
<tr> <tr>
<td><input name=gsila placeholder="Сила"> <td><input name=add_strength placeholder="Сила">
<tr> <tr>
<td><input name=glovk placeholder="Ловкость"> <td><input name=add_dexterity placeholder="Ловкость">
<tr> <tr>
<td><input name=ginta placeholder="Интуиция"> <td><input name=add_intuition placeholder="Интуиция">
<tr> <tr>
<td><input name=gintel placeholder="Интеллект"> <td><input name=add_endurance placeholder="Выносливость">
<tr> <tr>
<td><input name=ghp placeholder="НР"> <td><input name=add_intelligence placeholder="Интеллект">
<tr> <tr>
<td><input name=mfkrit placeholder="Мф.крит"> <td><input name=add_wisdom placeholder="Мудрость">
<tr> <tr>
<td><input name=mfakrit placeholder="Мф.антикрит"> <td><input name=add_accuracy placeholder="Точность">
<tr> <tr>
<td><input name=mfuvorot placeholder="Мф.уворот"> <td><input name=add_evasion placeholder="Уворот">
<tr> <tr>
<td><input name=mfauvorot placeholder="Мф.антиуворот"> <td><input name=add_criticals placeholder="Крит">
<tr> <tr>
<td><input name=gnoj placeholder="Ум.ножи"> <td><input name=add_min_physical_damage placeholder="Мин.удар">
<tr> <tr>
<td><input name=gtopor placeholder="Ум.топоры"> <td><input name=add_min_physical_damage placeholder="Макс.удар">
<tr>
<td><input name=gdubina placeholder="Ум.дубины">
<tr>
<td><input name=gmech placeholder="Ум.мечи">
<tr>
<td><input name=bron1 placeholder="Броня головы">
<tr>
<td><input name=bron2 placeholder="Броня корпуса">
<tr>
<td><input name=bron3 placeholder="Броня пояса">
<tr>
<td><input name=bron4 placeholder="Броня ног">
<tr>
<td><input name=gfire placeholder="Мастерство огня">
<tr>
<td><input name=gwater placeholder="Мастерство воды">
<tr>
<td><input name=gair placeholder="Мастерство воздуха">
<tr>
<td><input name=gearth placeholder="Мастерство земли">
<tr>
<td><input name=glight placeholder="Светлая магия">
<tr>
<td><input name=ggray placeholder="Серая магия">
<tr>
<td><input name=gdark placeholder="Темная магия">
<tr>
<td><input name=encicl placeholder="В энциклопедию">
<tr>
<td><input name=magic placeholder="Наложенно заклятие">
</table> </table>
<INPUT TYPE="submit" value="Добавить"> <INPUT TYPE="submit" value="Добавить">
</div> </div>
</form> </form>
<?php
if (isset($_POST)) {
echo "Ждём лучших времён!";
//if($_POST['razdel'] !=7) $goden_tmp=0; else */
// $goden_tmp = $_POST['goden'];
//
// if ($_POST['shop'] == 1) if (mysql_query("INSERT INTO shop(name,duration,maxdur,cost,ecost,nlevel,nsila,nlovk,ninta,nvinos,nintel,nmudra,nnoj,ntopor,ndubina,nmech,nalign,minu,maxu,goden,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,gnoj,gtopor,gdubina,gmech,img,count,bron1,bron2,bron3,bron4,magic,type,massa,needident,nfire,nwater,nair,nearth,nlight,ngray,ndark,gfire,gwater,gair,gearth,glight,ggray,gdark,encicl,artefact,letter,isrep,razdel) VALUES ('" . $_POST['name'] . "','" . $_POST['duration'] . "','" . $_POST['maxdur'] . "','" . $_POST['cost'] . "','" . $_POST['ecost'] . "','" . $_POST['nlevel'] . "','" . $_POST['nsila'] . "','" . $_POST['nlovk'] . "','" . $_POST['ninta'] . "','" . $_POST['nvinos'] . "','" . $_POST['nintel'] . "','" . $_POST['nmudra'] . "','" . $_POST['nnoj'] . "','" . $_POST['ntopor'] . "','" . $_POST['ndubina'] . "','" . $_POST['nmech'] . "','" . $_POST['nalign'] . "','" . $_POST['minu'] . "','" . $_POST['maxu'] . "','" . $goden_tmp . "','" . $_POST['gsila'] . "','" . $_POST['glovk'] . "','" . $_POST['ginta'] . "','" . $_POST['gintel'] . "','" . $_POST['ghp'] . "','" . $_POST['mfkrit'] . "','" . $_POST['mfakrit'] . "','" . $_POST['mfuvorot'] . "','" . $_POST['mfauvorot'] . "','" . $_POST['gnoj'] . "','" . $_POST['gtopor'] . "','" . $_POST['gdubina'] . "','" . $_POST['gmech'] . "','" . $_POST['img'] . "','" . $_POST['count'] . "','" . $_POST['bron1'] . "','" . $_POST['bron2'] . "','" . $_POST['bron3'] . "','" . $_POST['bron4'] . "','" . $_POST['magic'] . "','" . $_POST['type'] . "','" . $_POST['massa'] . "','" . $_POST['needident'] . "','" . $_POST['nfire'] . "','" . $_POST['nwater'] . "','" . $_POST['nair'] . "','" . $_POST['nearth'] . "','" . $_POST['nlight'] . "','" . $_POST['ngray'] . "','" . $_POST['ndark'] . "','" . $_POST['gfire'] . "','" . $_POST['gwater'] . "','" . $_POST['gair'] . "','" . $_POST['gearth'] . "','" . $_POST['glight'] . "','" . $_POST['ggray'] . "','" . $_POST['gdark'] . "','" . $_POST['encicl'] . "','0','" . $_POST['letter'] . "','" . $_POST['isrep'] . "','" . $_POST['razdel'] . "');")) {
// echo "Предмет успешно добавлен";
// } else {
// echo "Предмет не был добавлен!-1";
// };
//
// if ($_POST['shop'] == 2) if (mysql_query("INSERT INTO fshop(name,duration,maxdur,cost,ecost,nlevel,nsila,nlovk,ninta,nvinos,nintel,nmudra,nnoj,ntopor,ndubina,nmech,nalign,minu,maxu,goden,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,gnoj,gtopor,gdubina,gmech,img,count,bron1,bron2,bron3,bron4,magic,type,massa,needident,nfire,nwater,nair,nearth,nlight,ngray,ndark,gfire,gwater,gair,gearth,glight,ggray,gdark,letter,isrep,razdel) VALUES ('" . $_POST['name'] . "','" . $_POST['duration'] . "','" . $_POST['maxdur'] . "','" . $_POST['cost'] . "','" . $_POST['ecost'] . "','" . $_POST['nlevel'] . "','" . $_POST['nsila'] . "','" . $_POST['nlovk'] . "','" . $_POST['ninta'] . "','" . $_POST['nvinos'] . "','" . $_POST['nintel'] . "','" . $_POST['nmudra'] . "','" . $_POST['nnoj'] . "','" . $_POST['ntopor'] . "','" . $_POST['ndubina'] . "','" . $_POST['nmech'] . "','" . $_POST['nalign'] . "','" . $_POST['minu'] . "','" . $_POST['maxu'] . "','" . $goden_tmp . "','" . $_POST['gsila'] . "','" . $_POST['glovk'] . "','" . $_POST['ginta'] . "','" . $_POST['gintel'] . "','" . $_POST['ghp'] . "','" . $_POST['mfkrit'] . "','" . $_POST['mfakrit'] . "','" . $_POST['mfuvorot'] . "','" . $_POST['mfauvorot'] . "','" . $_POST['gnoj'] . "','" . $_POST['gtopor'] . "','" . $_POST['gdubina'] . "','" . $_POST['gmech'] . "','" . $_POST['img'] . "','" . $_POST['count'] . "','" . $_POST['bron1'] . "','" . $_POST['bron2'] . "','" . $_POST['bron3'] . "','" . $_POST['bron4'] . "','" . $_POST['magic'] . "','" . $_POST['type'] . "','" . $_POST['massa'] . "','" . $_POST['needident'] . "','" . $_POST['nfire'] . "','" . $_POST['nwater'] . "','" . $_POST['nair'] . "','" . $_POST['nearth'] . "','" . $_POST['nlight'] . "','" . $_POST['ngray'] . "','" . $_POST['ndark'] . "','" . $_POST['gfire'] . "','" . $_POST['gwater'] . "','" . $_POST['gair'] . "','" . $_POST['gearth'] . "','" . $_POST['glight'] . "','" . $_POST['ggray'] . "','" . $_POST['gdark'] . "','" . $_POST['letter'] . "','" . $_POST['isrep'] . "','" . $_POST['razdel'] . "');")) {
// echo "Предмет успешно добавлен";
// } else {
// echo "Предмет не был добавлен!" . mysql_error();
// };
//
}
//End item adder

View File

@ -4,13 +4,12 @@
* Author: Igor Barkov <lopar.4ever@gmail.com> * Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game * Project name: Battles-Game
*/ */
require_once '../functions.php'; require_once '../config.php';
use Battles\Bank; use Battles\Admin\Clan;
use Battles\Database\Db; use Battles\Admin\User as AUser;
use Battles\GameConfigs; use Battles\Chat;
use Battles\Moderation; use Battles\Moderation;
use Battles\Nick;
use Battles\Template; use Battles\Template;
use Battles\User; use Battles\User;
@ -31,72 +30,24 @@ if (isset($_POST['syschatmsg'])) {
} }
//clans to reg //clans to reg
$unregisteredClans = new class { Clan::getUnapprovedList();
public function getList()
{
$row = Db::getInstance()->ofetchAll('SELECT * FROM clans WHERE status = 0');
$i = 0;
while ($i < count($row)) {
$id = $row[$i]->owner_id;
$login = User::getInstance($row[$i]->owner_id)->getLogin();
$fullName = $row[$i]->full_name;
$shortName = $row[$i]->short_name;
$info = nl2br($row[$i]->info);
$i++;
echo <<<UNREGCLANLIST
<div>
<fieldset style="display: inline;">
<legend>$fullName [$shortName]</legend>
Глава клана: <span class="abils">$login</span><br>
Описание:<div class="abils">$info</div>
<BR>
<button onclick="location.href='?regclan=$id'">Зарегистрировать</button>
<button onclick="location.href='?remclan=$id'">Отказать</button>
</fieldset>
</div>
UNREGCLANLIST;
}
unset($i);
}
public function allowRegister($id)
{
Db::getInstance()->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
}
public function disallowRegister($id)
{
$bank = new Bank($id);
Db::getInstance()->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
$bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id);
}
};
$unregisteredClans->getList();
if (isset($_GET['regclan'])) { if (isset($_GET['regclan'])) {
$unregisteredClans->allowRegister($_GET['regclan']); Clan::allowRegister($_GET['regclan']);
header('Location:/admin/admin.php'); header('Location:/admin/admin.php');
exit; exit;
} }
if (isset($_GET['remclan'])) { if (isset($_GET['remclan'])) {
$unregisteredClans->disallowRegister($_GET['remclan']); Clan::disallowRegister($_GET['remclan']);
header('Location:/admin/admin.php'); header('Location:/admin/admin.php');
exit; exit;
} }
# Телеграф. # Телеграф.
if (!empty($_POST['receiver']) && !empty($_POST['tgmsg'])) { if (!empty($_POST['receiver']) && !empty($_POST['tgmsg'])) {
$receiver = Db::getInstance()->ofetch('SELECT id FROM users WHERE login= ?', $_POST['receiver']); Chat::sendTelegraf($_POST['tgmsg'], User::getInstance($_POST['receiver'])->getId());
telegraph($receiver->id, $_POST['tgmsg']);
echo "Успешно."; echo "Успешно.";
} }
# Показывает невидимок.
$row = Db::getInstance()->ofetchAll('SELECT id,login FROM users LEFT JOIN users_effects ue on users.id = ue.owner_id WHERE type = 1022 ORDER BY `id` DESC');
foreach ($row as $r) {
$invisList .= '<b>[id] = ' .$r->id. ', ' .$r->login. '</b><br>';
}
Template::header('ᐰdminка'); Template::header('ᐰdminка');
?> ?>
@ -126,27 +77,50 @@ Template::header('ᐰdminка');
<button disabled><img src="../i/magic/check.gif" alt="check"> Проверка</button> <button disabled><img src="../i/magic/check.gif" alt="check"> Проверка</button>
<form method='post'> <form method='post'>
<fieldset>
<legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend> <legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend>
<input name='ldnick' placeholder='Логин'> <input name='ldtext' size='50' placeholder='Сообщение'> <label>
<input name='ldnick' placeholder='Логин'>
</label>
<label>
<input name='ldtext' size='50' placeholder='Сообщение'>
</label>
<input type='submit' value='Добавить'><br> <input type='submit' value='Добавить'><br>
</fieldset>
</form> </form>
<form method='post'> <form method='post'>
<fieldset>
<legend>Отправить системное сообщение в чат</legend> <legend>Отправить системное сообщение в чат</legend>
<label>
<input name='syschatmsg' size='74' placeholder='Введите сообщение'> <input name='syschatmsg' size='74' placeholder='Введите сообщение'>
</label>
<input type='submit' value='Отправить'> <input type='submit' value='Отправить'>
</fieldset>
</form> </form>
<form method='post'> <form method='post'>
<fieldset>
<legend>Телеграф</legend> <legend>Телеграф</legend>
<label>
<input name='receiver' placeholder='Логин'> <input name='receiver' placeholder='Логин'>
</label>
<label>
<input name='tgmsg' size='50' placeholder='Сообщение'> <input name='tgmsg' size='50' placeholder='Сообщение'>
</label>
<input type='submit' value='Отправить'> <input type='submit' value='Отправить'>
</fieldset>
</form> </form>
<form method='post'> <form method='post'>
<fieldset>
<legend>Поменять статус</legend> <legend>Поменять статус</legend>
<label>
<input name='login' placeholder='Логин'> <input name='login' placeholder='Логин'>
</label>
<label>
<input name='status' placeholder='Статус'> <input name='status' placeholder='Статус'>
</label>
<input type='submit' value='Изменить статус'> <input type='submit' value='Изменить статус'>
</fieldset>
</form> </form>
<span class="legend">Невидимки</span><br> <span class="legend">Невидимки</span><br>
<div class="abils" style="width: fit-content;"><?= $invisList ?></div> <div class="abils" style="width: fit-content; font-weight: bold;"><?= AUser::getInvisiblesList() ?></div>

View File

@ -67,7 +67,7 @@ if ($_POST['pay']) {
if ($_POST['adm_start_raid'] && $user['id'] == 1256) { if ($_POST['adm_start_raid'] && $user['id'] == 1256) {
mysql_query("DELETE FROM `cit_haos_status`;"); mysql_query("DELETE FROM `cit_haos_status`;");
mysql_query("DELETE FROM `cit_haos_var`;"); mysql_query("DELETE FROM `cit_haos_var`;");
Chat::addSYSMessage('Начинается прием заявок в рейд на Цитадель Хаоса! Начало рейда через 15 минут.'); Chat::sendSys('Начинается прием заявок в рейд на Цитадель Хаоса! Начало рейда через 15 минут.');
$ch_time = time(); $ch_time = time();
mysql_query("UPDATE variables SET value='{$ch_time}' where var='cit_haos_time';"); mysql_query("UPDATE variables SET value='{$ch_time}' where var='cit_haos_time';");
} }

View File

@ -12,7 +12,7 @@ use Battles\Template;
require_once "config.php"; require_once "config.php";
$chat = new Chat(Db::getInstance()); $chat = new Chat(Db::getInstance());
if (!empty($_POST['msg'])) { if (!empty($_POST['msg'])) {
$chat->addMessage($_POST['msg']); $chat->sendMessage($_POST['msg']);
} }
Template::header('chat'); Template::header('chat');

View File

@ -0,0 +1,49 @@
<?php
namespace Battles\Admin;
use Battles\Bank;
use Battles\Database\Db;
use Battles\GameConfigs;
use Battles\User;
class Clan
{
public static function getUnapprovedList(): string
{
$list = '';
$rows = Db::getInstance()->ofetchAll('select * from clans where status = 0');
foreach ($rows as $row) {
$id = $row->owner_id;
$login = User::getInstance($id)->getLogin();
$full = $row->full_name;
$short = $row->short_name;
$info = nl2br($row->info);
$list .= <<<UNREGCLANLIST
<div>
<fieldset style="display: inline;">
<legend>$full [$short]</legend>
Глава клана: <span class="abils">$login</span><br>
Описание:<div class="abils">$info</div>
<BR>
<button onclick="location.href='?regclan=$id'">Зарегистрировать</button>
<button onclick="location.href='?remclan=$id'">Отказать</button>
</fieldset>
</div>
UNREGCLANLIST;
}
return $list;
}
public static function allowRegister($id)
{
Db::getInstance()->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
}
public static function disallowRegister($id)
{
$bank = new Bank($id);
Db::getInstance()->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
$bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id);
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Battles\Admin;
use Battles\Database\Db;
class Item
{
public static function add(array $params): void
{
$query = 'insert into items (
name, item_type, durability,
need_strength, need_dexterity, need_intuition, need_endurance, need_intelligence, need_wisdom,
add_strength, add_dexterity, add_intuition, add_endurance, add_intelligence, add_wisdom,
add_accuracy, add_evasion, add_criticals, add_min_physical_damage, add_max_physical_damage,
image, weight)
values (
:name, :item_type, :durability,
:need_strength, :need_dexterity, :need_intuition, :need_endurance, :need_intelligence, :need_wisdom,
:add_strength, :add_dexterity, :add_intuition, :add_endurance, :add_intelligence, :add_wisdom,
:add_accuracy, :add_evasion, :add_criticals, :add_min_physical_damage, :add_max_physical_damage,
:image, :weight)';
$values = [
'name' => $params['name'] ?? uniqid(),
'item_type' => $params['item_type'],
'durability' => $params['durability'] ?? 1,
'need_strength' => $params['need_strength'] ?? 0,
'need_dexterity' => $params['need_dexterity'] ?? 0,
'need_intuition' => $params['need_intuition'] ?? 0,
'need_endurance' => $params['need_endurance'] ?? 0,
'need_intelligence' => $params['need_intelligence'] ?? 0,
'need_wisdom' => $params['need_wisdom'] ?? 0,
'add_strength' => $params['add_strength'] ?? 0,
'add_dexterity' => $params['add_dexterity'] ?? 0,
'add_intuition' => $params['add_intuition'] ?? 0,
'add_endurance' => $params['add_endurance'] ?? 0,
'add_intelligence' => $params['add_intelligence'] ?? 0,
'add_wisdom' => $params['add_wisdom'] ?? 0,
'add_accuracy' => $params['add_accuracy'] ?? 0,
'add_evasion' => $params['add_evasion'] ?? 0,
'add_criticals' => $params['add_criticals'] ?? 0,
'add_min_physical_damage' => $params['add_min_physical_damage'] ?? 0,
'add_max_physical_damage' => $params['add_max_physical_damage'] ?? 0,
'image' => $params['image'] ?? 'noitem.png',
'weight' => $params['weight'] ?? 1,
];
Db::getInstance()->execute($query, $values);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace Battles\Admin;
use Battles\Database\Db;
class User
{
private const INVISIBILITY_EFFECT = 1022;
public static function getInvisiblesList(): string
{
$list = '';
$row = Db::getInstance()->ofetchAll('select id, login from users left join users_effects ue on users.id = ue.owner_id where type = ' . self::INVISIBILITY_EFFECT);
foreach ($row as $item) {
$list .= '[id] = ' . $item->id . ', ' . $item->login . '<br>';
}
return $list;
}
}

View File

@ -62,14 +62,18 @@ class Chat
return $wrappedMessage; return $wrappedMessage;
} }
public function addMessage(string $msg) public function sendMessage(string $msg)
{ {
$this->db->execute('insert into chat (user_id, msg) values (?,?)', [User::getInstance()->getId(), $msg]); $this->db->execute('insert into chat (user_id, msg) values (?,?)', [User::getInstance()->getId(), $msg]);
} }
public static function addSYSMessage( string $msg, ?int $receiver_id = null) public static function sendSys(string $msg, ?int $receiver_id = null)
{ {
Db::getInstance()->execute('insert into chat (user_id, msg, receiver_id, type) values (?,?,?,?)', [User::getInstance()->getId(), $msg, $receiver_id, 'sys']); Db::getInstance()->execute('insert into chat (user_id, msg, receiver_id, type) values (-1,?,?,?)', [$msg, $receiver_id, 'sys']);
}
public static function sendTelegraf(string $msg, int $receiver_id)
{
Db::getInstance()->execute('insert into chat (user_id, msg, receiver_id, type) values (-1,?,?,?)', [$msg, $receiver_id, 'sms']);
} }
} }

View File

@ -12,9 +12,10 @@ use stdClass;
class DressedItems class DressedItems
{ {
private $USERID; private int $USERID;
private $dressedItem; private stdClass $dressedItem;
private static $db; private static Db $db;
private object $dressed;
/** /**
* DressedItems constructor. * DressedItems constructor.
@ -24,6 +25,7 @@ class DressedItems
{ {
self::$db = Db::getInstance(); self::$db = Db::getInstance();
$this->USERID = $user_id; $this->USERID = $user_id;
$this->dressed = self::$db->ofetchAll('select * from inventory where dressed_slot > 0 and owner_id = ?', $this->USERID);
} }
public static function getDressedItemBySlot($itemSlot, $ownerId) public static function getDressedItemBySlot($itemSlot, $ownerId)
@ -33,9 +35,8 @@ class DressedItems
public function getItemsInSlots(): stdClass public function getItemsInSlots(): stdClass
{ {
$items = self::$db->ofetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID);
$this->dressedItem = new stdClass(); $this->dressedItem = new stdClass();
foreach ($items as $item) { foreach ($this->dressed as $item) {
$i = $item->dressed_slot; $i = $item->dressed_slot;
$this->dressedItem->$i = $item; $this->dressedItem->$i = $item;
} }
@ -54,8 +55,35 @@ class DressedItems
self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]); self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]);
} }
} }
public static function undressAllItems($user_id) public static function undressAllItems($user_id)
{ {
return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id); return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id);
} }
public function checkRequirements()
{
$stats = (new UserStats($this->USERID))->getFullStats();
$q = 'select count(*) from inventory where
dressed_slot > 0 and
need_strength > ? and
need_dexterity > ? and
need_intuition > ? and
need_endurance > ? and
need_intelligence > ? and
need_wisdom > ? and
owner_id = ?';
$args = [
$stats->strength,
$stats->dexterity,
$stats->intuition,
$stats->endurance,
$stats->intelligence,
$stats->wisdom,
$this->USERID
];
if (self::$db->fetchColumn($q, $args) > 0) {
self::undressAllItems($this->USERID);
}
}
} }

View File

@ -48,7 +48,12 @@ class CureInjury extends Magic
{ {
$this->target = $this->target == $_SESSION['uid'] ? User::getInstance() : User::getInstance($this->target); $this->target = $this->target == $_SESSION['uid'] ? User::getInstance() : User::getInstance($this->target);
$this->login = $this->target->getLogin(); $this->login = $this->target->getLogin();
return ($this->isVisible(User::getInstance(), $this->target) && $this->isNotDead(User::getInstance()) && $this->enoughMana(User::getInstance()) && $this->isNotInBattle(User::getInstance())); return (
$this->isVisible(User::getInstance(), $this->target) &&
$this->isNotDead(User::getInstance()) &&
$this->enoughMana(User::getInstance()) &&
$this->isNotInBattle(User::getInstance())
);
} }
public static function cast($target, $type): self public static function cast($target, $type): self

View File

@ -1,11 +1,26 @@
<?php <?php
# Date: 16.09.2020 (08:45) # Date: 16.09.2020 (08:45)
namespace Battles\Magic; namespace Battles\Magic;
use Battles\Database\Db;
class Magic class Magic
{ {
protected $status; protected string $status;
private Db $db;
private object $magic;
protected function isVisible($caster, $target):bool public function __construct(Db $db, int $id)
{
$this->magic = $db->ofetch('select * from magic where id = ?', $id);
}
public function getMagic(): object
{
return $this->magic;
}
protected function isVisible($caster, $target): bool
{ {
if ($caster->battle != $target->battle || $caster->room != $target->room) { if ($caster->battle != $target->battle || $caster->room != $target->room) {
$this->status = 'Вы не видите цель!'; $this->status = 'Вы не видите цель!';
@ -15,7 +30,7 @@ class Magic
} }
} }
protected function isNotDead($caster):bool protected function isNotDead($caster): bool
{ {
if ($caster->health < 1) { if ($caster->health < 1) {
$this->status = 'Вы мертвы!'; $this->status = 'Вы мертвы!';
@ -25,7 +40,7 @@ class Magic
} }
} }
protected function enoughMana($caster):bool protected function enoughMana($caster): bool
{ {
if ($caster->mana < 1) { if ($caster->mana < 1) {
$this->status = 'Недостаточно пыли!'; $this->status = 'Недостаточно пыли!';
@ -35,7 +50,7 @@ class Magic
} }
} }
protected function isNotInBattle($caster):bool protected function isNotInBattle($caster): bool
{ {
if ($caster->battle) { if ($caster->battle) {
$this->status = 'Невозможно применить в поединке!'; $this->status = 'Невозможно применить в поединке!';
@ -52,12 +67,12 @@ class Magic
* *
* @return bool * @return bool
*/ */
protected function isSuccess($caster, int $difficulty = 40):bool protected function isSuccess($caster, int $difficulty = 40): bool
{ {
# 40 - потолок стата. # 40 - потолок стата.
if ($difficulty > 40) { if ($difficulty > 40) {
$difficulty = 40; $difficulty = 40;
} }
return mt_rand(1,$difficulty) < $caster->intelligence; return mt_rand(1, $difficulty) < $caster->intelligence;
} }
} }

View File

@ -216,6 +216,11 @@ class User
return $this->experience; return $this->experience;
} }
public function addExperience(int $amount): void
{
$this->experience += max($amount, 0);
}
public function getBattle(): int public function getBattle(): int
{ {
return Arena::fight()->hasNoActiveFights(); return Arena::fight()->hasNoActiveFights();

View File

@ -213,7 +213,7 @@ class UserStats extends User
$this->level += 1; $this->level += 1;
$this->free_stat_points += 2; $this->free_stat_points += 2;
$this->saveStats(); $this->saveStats();
Chat::addSYSMessage('Внимание, вы получили ' . $this->level . 'уровень. Доступны очки распределения параметров.'); Chat::sendSys('Внимание, вы получили ' . $this->level . 'уровень. Доступны очки распределения параметров.');
return 'Персонаж перешёл на ' . $this->level . 'уровень.'; return 'Персонаж перешёл на ' . $this->level . 'уровень.';
} }

View File

@ -6,9 +6,6 @@
* Project name: Battles-Game * Project name: Battles-Game
*/ */
use Battles\Database\Db;
use Battles\User;
include_once 'classes/Database/db.php'; include_once 'classes/Database/db.php';
include_once 'classes/Database/Mysql.php'; include_once 'classes/Database/Mysql.php';
include_once 'classes/Database/Statement.php'; include_once 'classes/Database/Statement.php';

View File

@ -552,10 +552,10 @@ class fbattle
} }
if ($arr_battle['win'] == 1) { if ($arr_battle['win'] == 1) {
Chat::addSYSMessage('Внимание! Тьма одержала победу благодаря великим воинам: <b>' . $uss . '</b>'); Chat::sendSys('Внимание! Тьма одержала победу благодаря великим воинам: <b>' . $uss . '</b>');
$this->AddToLog('<span class=date>' . date("H:i") . '</span> ' . 'Бой закончен, победа за <B>Силами Тьмы</B><BR>'); $this->AddToLog('<span class=date>' . date("H:i") . '</span> ' . 'Бой закончен, победа за <B>Силами Тьмы</B><BR>');
} else { } else {
Chat::addSYSMessage('Внимание! Свет одержал победу благодаря великим воинам: <b>' . $uss . '</b>'); Chat::sendSys('Внимание! Свет одержал победу благодаря великим воинам: <b>' . $uss . '</b>');
$this->AddToLog('<span class=date>' . date("H:i") . '</span> ' . 'Бой закончен, победа за <B>Силами Света</B><BR>'); $this->AddToLog('<span class=date>' . date("H:i") . '</span> ' . 'Бой закончен, победа за <B>Силами Света</B><BR>');
} }
mysql_query('UPDATE `variables` SET `value` = "' . $arr_battle['win'] . '" WHERE `var` = "arena_win" LIMIT 1'); mysql_query('UPDATE `variables` SET `value` = "' . $arr_battle['win'] . '" WHERE `var` = "arena_win" LIMIT 1');
@ -586,7 +586,7 @@ class fbattle
} }
} else { } else {
if ($this->battle_data['aren_of'] == 1) { if ($this->battle_data['aren_of'] == 1) {
Chat::addSYSMessage('Внимание! Бой на Арене Ангелов завершился ничьей, на этой недели силы тьмы и света равны.'); Chat::sendSys('Внимание! Бой на Арене Ангелов завершился ничьей, на этой недели силы тьмы и света равны.');
mysql_query('UPDATE `variables` SET `value` = 3 WHERE `var` = "arena_win" LIMIT 1'); mysql_query('UPDATE `variables` SET `value` = 3 WHERE `var` = "arena_win" LIMIT 1');
mysql_query('UPDATE `battle` SET `aren_of` = 0 WHERE `id` = "' . $arr_battle['id'] . '" AND `aren_of` = 1 LIMIT 1'); mysql_query('UPDATE `battle` SET `aren_of` = 0 WHERE `id` = "' . $arr_battle['id'] . '" AND `aren_of` = 1 LIMIT 1');
} }

View File

@ -1,4 +1,9 @@
<?php <?php
use Battles\DressedItems;
use Battles\Template;
use Battles\User;
if (isset($_POST['end'])) { if (isset($_POST['end'])) {
header("Location: main.php"); header("Location: main.php");
exit; exit;
@ -15,7 +20,7 @@ if (isset($user['id'])) {
include('./classes/battle_new.class.php'); include('./classes/battle_new.class.php');
$fbattle = new fbattle($user['battle']); $fbattle = new fbattle($user['battle']);
\Battles\Template::header('fbattle'); Template::header('fbattle');
?> ?>
<script type="text/javascript" src="js/sl2.js"></script> <script type="text/javascript" src="js/sl2.js"></script>
<script type="text/javascript" src="js/ch.js"></script> <script type="text/javascript" src="js/ch.js"></script>
@ -133,7 +138,7 @@ $fbattle = new fbattle($user['battle']);
<tr> <tr>
<td valign=top width=250 nowrap> <td valign=top width=250 nowrap>
<?php <?php
$myinfo = new \Battles\User($_SESSION['uid']); $myinfo = new User($_SESSION['uid']);
$myinfo->showUserDoll(1); $myinfo->showUserDoll(1);
?> ?>
</td> </td>
@ -290,7 +295,7 @@ $fbattle = new fbattle($user['battle']);
if (($user['hp'] > 0) && $fbattle->battle) { if (($user['hp'] > 0) && $fbattle->battle) {
echo '<center><FONT COLOR=red><b>Ожидаем хода противника...</b></FONT><BR><INPUT TYPE=submit value="Обновить" name=' . (($user['battle'] > 0) ? "battle" : "end") . '><BR></CENTER>'; echo '<center><FONT COLOR=red><b>Ожидаем хода противника...</b></FONT><BR><INPUT TYPE=submit value="Обновить" name=' . (($user['battle'] > 0) ? "battle" : "end") . '><BR></CENTER>';
} elseif ($user['hp'] <= 0 && $fbattle->battle) { } elseif ($user['hp'] <= 0 && $fbattle->battle) {
ref_drop(); (new DressedItems(User::getInstance()->getId()))->checkRequirements();
echo '<center><FONT COLOR=red><b>Ожидаем, пока бой закончат другие игроки...</b></FONT><BR><INPUT TYPE=submit value="Обновить" name=' . (($user['battle'] > 0) ? "battle" : "end") . '><BR></CENTER>'; echo '<center><FONT COLOR=red><b>Ожидаем, пока бой закончат другие игроки...</b></FONT><BR><INPUT TYPE=submit value="Обновить" name=' . (($user['battle'] > 0) ? "battle" : "end") . '><BR></CENTER>';
} }
break; break;
@ -468,7 +473,7 @@ $fbattle = new fbattle($user['battle']);
<?php <?php
if ($fbattle->return == 1) { if ($fbattle->return == 1) {
$enemyInfo = new \Battles\User($fbattle->enemy); $enemyInfo = new User($fbattle->enemy);
$enemyInfo->showUserDoll(1); $enemyInfo->showUserDoll(1);
} else { } else {
if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) { if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) {

View File

@ -5,6 +5,7 @@
* Project name: Battles-Game * Project name: Battles-Game
*/ */
use Battles\Chat;
use Battles\Database\Db; use Battles\Database\Db;
use Battles\DressedItems; use Battles\DressedItems;
use Battles\InventoryItem; use Battles\InventoryItem;
@ -78,26 +79,26 @@ Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBa
// exit; // exit;
//} //}
if (!empty($_GET['goto']) && !empty($_GET['tStamp']) && !empty($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) { if (
!empty($_GET['goto']) &&
!empty($_GET['tStamp']) &&
!empty($_GET['vcode']) &&
$_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))
) {
$query = 'update users u, online o set u.room = ?, o.room = ? where user_id = id and user_id = ?'; $query = 'update users u, online o set u.room = ?, o.room = ? where user_id = id and user_id = ?';
Db::getInstance()->execute($query, [$_GET['goto'], $_GET['goto'], User::getInstance()->getId()]); Db::getInstance()->execute($query, [$_GET['goto'], $_GET['goto'], User::getInstance()->getId()]);
User::getInstance()->setRoom(intval($_GET['goto'])); User::getInstance()->setRoom(intval($_GET['goto']));
} }
function createbot($bot, $login = "") function createbot($bot, $login = null)
{ {
$rec = db::c()->query('SELECT `id`, `login`, `maxhp` FROM `users` WHERE `id` = "?s" LIMIT 1', $bot)->fetch_assoc(); if (!User::getInstance($bot)->getId()) {
if (isset($rec['id'])) {
if ($login) {
$rec['login'] = $login;
}
$botname = $rec['login'];
db::c()->query('INSERT INTO `bots` (`name`, `prototype`, `hp`) VALUES ("?s", "?s", "?s")', $botname, $bot, $rec['maxhp']);
$nid = db::c()->getLastInsertId();
return ["id" => $nid, "login" => $botname];
} else {
return false; return false;
} }
$botname = $login ?: User::getInstance($bot)->getLogin();
Db::getInstance()->execute('insert into bots (name, prototype, hp) values (?, ?, ?)',
[$botname, $bot, (new UserStats($bot))->getMaxHealth()]);
return ["id" => Db::getInstance()->lastInsertId(), "login" => $botname];
} }
$var_map = [ $var_map = [
@ -123,7 +124,7 @@ function savecavedata($cavedata, $caveleader, $floor)
function GiveExp($id, $exp) function GiveExp($id, $exp)
{ {
db::c()->query('UPDATE users SET exp = exp + ?i WHERE id = ?i', $exp, $id); User::getInstance($id)->addExperience($exp);
} }
/** /**
@ -199,22 +200,18 @@ EMPTY_SLOT;
} }
// ссылка на магию // ссылка на магию
function showhrefmagic($dress) function showhrefmagic(array $dress): string
{ {
$user = db::c()->query('SELECT `battle` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); $magic = new Battles\Magic\Magic(Db::getInstance(), $dress['includemagic']);
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['includemagic'])->fetch_assoc();
$r = ''; $r = '';
$script = 'main'; $script = User::getInstance()->getBattle() ? 'fbattle' : 'main';
if ($user['battle']) {
$script = 'fbattle';
}
$r .= "<a onclick=\""; $r .= "<a onclick=\"";
if ($magic['targeted'] == 1) { if ($magic->getMagic()->targeted == 1) {
$r .= "okno('Введите название предмета', '{$script}.php?use={$dress['id']}', 'target')"; $r .= "okno('Введите название предмета', '{$script}.php?use={$dress['id']}', 'target')";
} elseif ($magic['targeted'] == 2) { } elseif ($magic->getMagic()->targeted == 2) {
$r .= "findlogin('" . $magic['name'] . "', '{$script}.php?use={$dress['id']}', 'target')"; $r .= "findlogin('" . $magic->getMagic()->name . "', '{$script}.php?use={$dress['id']}', 'target')";
} else { } else {
$r .= "if (confirm('Использовать сейчас?')) window.location='" . $script . ".php?use=" . $dress['id'] . "';"; $r .= "if (confirm('Использовать сейчас?')) window.location='" . $script . ".php?use=" . $dress['id'] . "';";
} }
@ -284,59 +281,6 @@ function addActions($time, $vars, $vls, $uid)
return $ins; return $ins;
} }
#15
function ref_drop()
{
//сможет держать
function derj($id)
{
$user = db::c()->query('SELECT `id`, `align` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
$ts = db::c()->query('SELECT `id`, `nalign` FROM `inventory` WHERE `id` = ?i', $id)->fetch_assoc();
$al = '(1 = 1)';
if ($ts['nalign'] == 1.1) {
$al = '(1 = 2)';
}
$dd = db::c()->query('SELECT `i`.`id` FROM `users` AS `u`, `inventory` AS `i`
WHERE
`i`.`needident` = 0 AND
`i`.`id` = ?i AND
`i`.`duration` < `i`.`maxdur` AND
`i`.`owner` = ?i AND
`u`.`sila` >= `i`.`nsila` AND
`u`.`lovk` >= `i`.`nlovk` AND
`u`.`inta` >= `i`.`ninta` AND
`u`.`vinos` >= `i`.`nvinos` AND
`u`.`intel` >= `i`.`nintel` AND
`u`.`mudra` >= `i`.`nmudra` AND
`u`.`level` >= `i`.`nlevel` AND
("?s" OR (?i = `i`.`nalign`) or (`i`.`nalign` = 0)) AND
`u`.`noj` >= `i`.`nnoj` AND
`u`.`topor` >= `i`.`ntopor` AND
`u`.`dubina` >= `i`.`ndubina` AND
`u`.`mec` >= `i`.`nmech` AND
`u`.`mfire` >= `i`.`nfire` AND
`u`.`mwater` >= `i`.`nwater` AND
`u`.`mair` >= `i`.`nair` AND
`u`.`mearth` >= `i`.`nearth` AND
`u`.`mlight` >= `i`.`nlight` AND
`u`.`mgray` >= `i`.`ngray` AND
`u`.`mdark` >= `i`.`ndark` AND
`i`.`setsale` = 0 AND
`u`.`id` = ?i', $id, $user['id'], $al, $user['align'], $user['id']);
return $dd->getNumRows() > 0;
}
$slot = ['sergi', 'kulon', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'perchi', 'shit', 'boots', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10'];
$user = db::c()->query('SELECT `sergi`,`kulon`,`weap`,`bron`,`r1`,`r2`,`r3`,`helm`,`perchi`,`shit`,`boots`,`m1`,`m2`,`m3`,`m4`,`m5`,`m6`,`m7`,`m8`,`m9`,`m10` FROM `users` WHERE id = ?i', $_SESSION['uid'])->fetch_assoc();
for ($i = 0; $i <= 20; $i++) {
if ($user[$slot[$i]] && !derj($user[$slot[$i]])) {
$item = new DressedItems($_SESSION['uid']);
$item->undressItem($i + 1);
$user[$slot[$i]] = null;
}
}
}
// использовать магию // использовать магию
function usemagic($id, $target) function usemagic($id, $target)
{ {
@ -426,7 +370,7 @@ function usemagic($id, $target)
} }
/* ВАЖНО! (#44) /* ВАЖНО! (#44)
* addch() и addchp() заменяются на Chat::class->addSYSMessage($message, [optional]$receiver); * addch() и addchp() заменяются на Chat::class->sendSys($message, [optional]$receiver);
* Для addchp() используется второй опциональный ключ. * Для addchp() используется второй опциональный ключ.
* Это 150+ вхождений в куче файлов, где надо менять структуру вызова функции из-за их несовместимости. * Это 150+ вхождений в куче файлов, где надо менять структуру вызова функции из-за их несовместимости.
* Возможно, приоритетом стоит сделать унификацию свитков нападения, которых самих около 20 и которые * Возможно, приоритетом стоит сделать унификацию свитков нападения, которых самих около 20 и которые
@ -435,30 +379,13 @@ function usemagic($id, $target)
function addch($text, $room = 0) function addch($text, $room = 0)
{ {
if ($room == 0) { Chat::sendSys($text);
$room = User::getInstance()->getRoom();
}
if ($fp = @fopen("tmp/chat.txt", "a")) { //открытие
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fwrite($fp, ":[" . time() . "]:[!sys!!]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом
fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose($fp); //закрытие
}
} }
function addchp($text, $who, $room = 0) function addchp($text, $who, $room = 0)
{ {
if ($room == 0) { Chat::sendSys($text, $who);
$room = User::getInstance()->getRoom();
}
$fp = fopen("tmp/chat.txt", "a"); //открытие
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fwrite($fp, ":[" . time() . "]:[{$who}]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом
fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose($fp); //закрытие
} }
function err($t) function err($t)
@ -466,19 +393,6 @@ function err($t)
echo '<span class="error">' . $t . '</span>'; echo '<span class="error">' . $t . '</span>';
} }
/**
* @param int $userId
* @param string $text
*
*/
function telegraph(int $userId, string $text)
{
if (Db::getInstance()->ofetch('SELECT 1 FROM users WHERE id = ?', $userId)) {
Db::getInstance()->execute('INSERT INTO chat (user_id,receiver_id,msg,type) VALUES (-1,?,?,?)', [$userId, $text, 'sms']);
}
}
function SolveExp($at_id, $def_id, $damage): float function SolveExp($at_id, $def_id, $damage): float
{ {
$mods = [ $mods = [

View File

@ -281,7 +281,7 @@ if (($kol_pl + $ls) < 2 && ($tur_data['start_time'] + 60) <= time()) {
mysql_query('UPDATE `deztow_turnir` SET `winner` = \'' . $user['id'] . '\', `winnerlog` = \'' . Nick::id($user['id'])->full(1) . '\', `endtime` = \'' . time() . '\', `active` = FALSE, `log` = CONCAT(`log`,\'' . "<span class=date>" . date("d.m.y H:i") . "</span> Турнир завершен. Победитель : " . Nick::id($user['id'])->full(1) . " Приз : <b>" . $tur['coin'] . "</b> кр. <br />" . '\') WHERE `active` = TRUE LIMIT 1'); mysql_query('UPDATE `deztow_turnir` SET `winner` = \'' . $user['id'] . '\', `winnerlog` = \'' . Nick::id($user['id'])->full(1) . '\', `endtime` = \'' . time() . '\', `active` = FALSE, `log` = CONCAT(`log`,\'' . "<span class=date>" . date("d.m.y H:i") . "</span> Турнир завершен. Победитель : " . Nick::id($user['id'])->full(1) . " Приз : <b>" . $tur['coin'] . "</b> кр. <br />" . '\') WHERE `active` = TRUE LIMIT 1');
addchp('<font color=red>Внимание!</font> Поздравляем! Вы победитель турнира Башни смерти! Получаете <b>' . $tur['coin'] . '</b> кр.', '{[]}' . $user['login'] . '{[]}'); addchp('<font color=red>Внимание!</font> Поздравляем! Вы победитель турнира Башни смерти! Получаете <b>' . $tur['coin'] . '</b> кр.', '{[]}' . $user['login'] . '{[]}');
Chat::addSYSMessage('Внимание! Битва в Башне Смерти завершена. Победитель:' . $user['login'] . ' [' . $user['level'] . ']'); Chat::sendSys('Внимание! Битва в Башне Смерти завершена. Победитель:' . $user['login'] . ' [' . $user['level'] . ']');
if ($tur['art'] == 1) { if ($tur['art'] == 1) {
$bs_art = 0; $bs_art = 0;
} else { } else {

View File

@ -207,7 +207,7 @@ class Zayavka
return $this->errorMessage; return $this->errorMessage;
} else { } else {
if ($type == 3) { if ($type == 3) {
Chat::addSYSMessage("Внимание! Подана заявка на хаотический поединок ({$t1min} - {$t1max}), который начнется через {$start} минут."); Chat::sendSys("Внимание! Подана заявка на хаотический поединок ({$t1min} - {$t1max}), который начнется через {$start} минут.");
} }
$start = time() + $start * 60; $start = time() + $start * 60;
@ -662,19 +662,19 @@ Template::header('zayavka');
} }
if (!empty($_POST['back2'])) { if (!empty($_POST['back2'])) {
$z = $zay->getlist(2, null, $user->getZayavka()); $z = $zay->getlist(2, null, $user->getZayavka());
Chat::addSYSMessage('Внимание!' . Nick::id($user->getId())->short() . ' отозвал заявку.'); Chat::sendSys('Внимание!' . Nick::id($user->getId())->short() . ' отозвал заявку.');
echo $zay->delteam($user->getId(), $user->getZayavka(), 2); echo $zay->delteam($user->getId(), $user->getZayavka(), 2);
} }
if (!empty($_POST['cansel'])) { if (!empty($_POST['cansel'])) {
$z = $zay->getlist(2, null, $user->getZayavka()); $z = $zay->getlist(2, null, $user->getZayavka());
echo $zay->delteam($z[$user->getZayavka()]['team2'][0], $user->getZayavka(), 2); echo $zay->delteam($z[$user->getZayavka()]['team2'][0], $user->getZayavka(), 2);
Chat::addSYSMessage('Внимание!' . Nick::id($user->getId())->short() . ' отказался от поединка.'); Chat::sendSys('Внимание!' . Nick::id($user->getId())->short() . ' отказался от поединка.');
} }
if (!empty($_POST['confirm2']) && empty($user->getZayavka())) { if (!empty($_POST['confirm2']) && empty($user->getZayavka())) {
$z = $zay->getlist(2, null, $_REQUEST['gocombat']); $z = $zay->getlist(2, null, $_REQUEST['gocombat']);
$toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$_REQUEST['gocombat']]['team1'][0])->fetch_assoc(); $toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$_REQUEST['gocombat']]['team1'][0])->fetch_assoc();
if ($user->getClan() != $toper['klan'] || !$user->getClan()) { if ($user->getClan() != $toper['klan'] || !$user->getClan()) {
Chat::addSYSMessage('Внимание!' . Nick::id($user->getId())->short() . ' принял заявку, нужно принять вызов или отказать.'); Chat::sendSys('Внимание!' . Nick::id($user->getId())->short() . ' принял заявку, нужно принять вызов или отказать.');
} }
echo $zay->addteam(2, 2); echo $zay->addteam(2, 2);
echo "</b></font><BR>Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'>"; echo "</b></font><BR>Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'>";