Merge pull request 'patch-dressedcheck' (#57) from patch-dressedcheck into master
Reviewed-on: #57
This commit is contained in:
commit
5fbccc6a43
@ -4,11 +4,11 @@
|
|||||||
* 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\Admin\Clan;
|
use Battles\Admin\Clan;
|
||||||
|
use Battles\Admin\User as AUser;
|
||||||
use Battles\Chat;
|
use Battles\Chat;
|
||||||
use Battles\Database\Db;
|
|
||||||
use Battles\Moderation;
|
use Battles\Moderation;
|
||||||
use Battles\Template;
|
use Battles\Template;
|
||||||
use Battles\User;
|
use Battles\User;
|
||||||
@ -45,16 +45,9 @@ if (isset($_GET['remclan'])) {
|
|||||||
|
|
||||||
# Телеграф.
|
# Телеграф.
|
||||||
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());
|
||||||
Chat::sendTelegraf($_POST['tgmsg'], $receiver->id);
|
|
||||||
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ка');
|
||||||
?>
|
?>
|
||||||
@ -84,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'>
|
||||||
<legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend>
|
<fieldset>
|
||||||
<input name='ldnick' placeholder='Логин'> <input name='ldtext' size='50' placeholder='Сообщение'>
|
<legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend>
|
||||||
<input type='submit' value='Добавить'><br>
|
<label>
|
||||||
|
<input name='ldnick' placeholder='Логин'>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input name='ldtext' size='50' placeholder='Сообщение'>
|
||||||
|
</label>
|
||||||
|
<input type='submit' value='Добавить'><br>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<form method='post'>
|
<form method='post'>
|
||||||
|
<fieldset>
|
||||||
<legend>Отправить системное сообщение в чат</legend>
|
<legend>Отправить системное сообщение в чат</legend>
|
||||||
<input name='syschatmsg' size='74' placeholder='Введите сообщение'>
|
<label>
|
||||||
<input type='submit' value='Отправить'>
|
<input name='syschatmsg' size='74' placeholder='Введите сообщение'>
|
||||||
|
</label>
|
||||||
|
<input type='submit' value='Отправить'>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<form method='post'>
|
<form method='post'>
|
||||||
|
<fieldset>
|
||||||
<legend>Телеграф</legend>
|
<legend>Телеграф</legend>
|
||||||
<input name='receiver' placeholder='Логин'>
|
<label>
|
||||||
<input name='tgmsg' size='50' placeholder='Сообщение'>
|
<input name='receiver' placeholder='Логин'>
|
||||||
<input type='submit' value='Отправить'>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input name='tgmsg' size='50' placeholder='Сообщение'>
|
||||||
|
</label>
|
||||||
|
<input type='submit' value='Отправить'>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<form method='post'>
|
<form method='post'>
|
||||||
|
<fieldset>
|
||||||
<legend>Поменять статус</legend>
|
<legend>Поменять статус</legend>
|
||||||
<input name='login' placeholder='Логин'>
|
<label>
|
||||||
<input name='status' placeholder='Статус'>
|
<input name='login' placeholder='Логин'>
|
||||||
<input type='submit' value='Изменить статус'>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input name='status' placeholder='Статус'>
|
||||||
|
</label>
|
||||||
|
<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>
|
20
classes/Battles/Admin/User.php
Normal file
20
classes/Battles/Admin/User.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -12,18 +12,20 @@ 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.
|
||||||
* @param int $user_id ID игрока.
|
* @param int $user_id ID игрока.
|
||||||
*/
|
*/
|
||||||
public function __construct(int $user_id)
|
public function __construct(int $user_id)
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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 $this->battle;
|
return $this->battle;
|
||||||
|
@ -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';
|
||||||
|
13
fbattle.php
13
fbattle.php
@ -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) {
|
||||||
|
127
functions.php
127
functions.php
@ -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;
|
||||||
@ -24,7 +25,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());
|
||||||
|
|
||||||
///*
|
///*
|
||||||
// * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
// * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
||||||
@ -78,26 +79,26 @@ Travel::roomRedirects(User::$current->getRoom(), User::$current->getBattle(), Us
|
|||||||
// 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,15 +124,15 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Генератор прогрессбара.
|
* Генератор прогрессбара.
|
||||||
* @param $current - Текущее значение.
|
* @param $current - Текущее значение.
|
||||||
* @param $maximum - Максимальное значение.
|
* @param $maximum - Максимальное значение.
|
||||||
* @param string $line_color - Цвет полоски прогрессбара.
|
* @param string $line_color - Цвет полоски прогрессбара.
|
||||||
* @param string $bg_color - Фон прогрессбара.
|
* @param string $bg_color - Фон прогрессбара.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function showProgressBar($current, $maximum, string $line_color = 'limegreen', string $bg_color = 'silver'): string
|
function showProgressBar($current, $maximum, string $line_color = 'limegreen', string $bg_color = 'silver'): string
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
@ -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)
|
||||||
@ -473,7 +400,7 @@ function SolveExp($at_id, $def_id, $damage): float
|
|||||||
'btl_1' => 1,
|
'btl_1' => 1,
|
||||||
'btl_2' => 0.5,
|
'btl_2' => 0.5,
|
||||||
'btl_3' => 0.05,
|
'btl_3' => 0.05,
|
||||||
];
|
];
|
||||||
$baseexp = [
|
$baseexp = [
|
||||||
"0" => "2",
|
"0" => "2",
|
||||||
"1" => "5",
|
"1" => "5",
|
||||||
|
Loading…
Reference in New Issue
Block a user