patch-dressedcheck #57
@ -45,8 +45,7 @@ if (isset($_GET['remclan'])) {
|
||||
|
||||
# Телеграф.
|
||||
if (!empty($_POST['receiver']) && !empty($_POST['tgmsg'])) {
|
||||
$receiver = Db::getInstance()->ofetch('SELECT id FROM users WHERE login= ?', $_POST['receiver']);
|
||||
Chat::sendTelegraf($_POST['tgmsg'], $receiver->id);
|
||||
Chat::sendTelegraf($_POST['tgmsg'], User::getInstance($_POST['receiver'])->getId());
|
||||
echo "Успешно.";
|
||||
}
|
||||
|
||||
@ -78,26 +77,49 @@ Template::header('ᐰdminка');
|
||||
<button disabled><img src="../i/magic/check.gif" alt="check"> Проверка</button>
|
||||
|
||||
<form method='post'>
|
||||
<legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend>
|
||||
<input name='ldnick' placeholder='Логин'> <input name='ldtext' size='50' placeholder='Сообщение'>
|
||||
<input type='submit' value='Добавить'><br>
|
||||
<fieldset>
|
||||
<legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend>
|
||||
<label>
|
||||
<input name='ldnick' placeholder='Логин'>
|
||||
</label>
|
||||
<label>
|
||||
<input name='ldtext' size='50' placeholder='Сообщение'>
|
||||
</label>
|
||||
<input type='submit' value='Добавить'><br>
|
||||
</fieldset>
|
||||
</form>
|
||||
<form method='post'>
|
||||
<fieldset>
|
||||
<legend>Отправить системное сообщение в чат</legend>
|
||||
<input name='syschatmsg' size='74' placeholder='Введите сообщение'>
|
||||
<input type='submit' value='Отправить'>
|
||||
<label>
|
||||
<input name='syschatmsg' size='74' placeholder='Введите сообщение'>
|
||||
</label>
|
||||
<input type='submit' value='Отправить'>
|
||||
</fieldset>
|
||||
</form>
|
||||
<form method='post'>
|
||||
<fieldset>
|
||||
<legend>Телеграф</legend>
|
||||
<input name='receiver' placeholder='Логин'>
|
||||
<input name='tgmsg' size='50' placeholder='Сообщение'>
|
||||
<input type='submit' value='Отправить'>
|
||||
<label>
|
||||
<input name='receiver' placeholder='Логин'>
|
||||
</label>
|
||||
<label>
|
||||
<input name='tgmsg' size='50' placeholder='Сообщение'>
|
||||
</label>
|
||||
<input type='submit' value='Отправить'>
|
||||
</fieldset>
|
||||
</form>
|
||||
<form method='post'>
|
||||
<fieldset>
|
||||
<legend>Поменять статус</legend>
|
||||
<input name='login' placeholder='Логин'>
|
||||
<input name='status' placeholder='Статус'>
|
||||
<input type='submit' value='Изменить статус'>
|
||||
<label>
|
||||
<input name='login' placeholder='Логин'>
|
||||
</label>
|
||||
<label>
|
||||
<input name='status' placeholder='Статус'>
|
||||
</label>
|
||||
<input type='submit' value='Изменить статус'>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<span class="legend">Невидимки</span><br>
|
||||
|
@ -48,7 +48,12 @@ class CureInjury extends Magic
|
||||
{
|
||||
$this->target = $this->target == $_SESSION['uid'] ? User::getInstance() : User::getInstance($this->target);
|
||||
$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
|
||||
|
@ -1,11 +1,26 @@
|
||||
<?php
|
||||
# Date: 16.09.2020 (08:45)
|
||||
namespace Battles\Magic;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
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) {
|
||||
$this->status = 'Вы не видите цель!';
|
||||
@ -15,7 +30,7 @@ class Magic
|
||||
}
|
||||
}
|
||||
|
||||
protected function isNotDead($caster):bool
|
||||
protected function isNotDead($caster): bool
|
||||
{
|
||||
if ($caster->health < 1) {
|
||||
$this->status = 'Вы мертвы!';
|
||||
@ -25,7 +40,7 @@ class Magic
|
||||
}
|
||||
}
|
||||
|
||||
protected function enoughMana($caster):bool
|
||||
protected function enoughMana($caster): bool
|
||||
{
|
||||
if ($caster->mana < 1) {
|
||||
$this->status = 'Недостаточно пыли!';
|
||||
@ -35,7 +50,7 @@ class Magic
|
||||
}
|
||||
}
|
||||
|
||||
protected function isNotInBattle($caster):bool
|
||||
protected function isNotInBattle($caster): bool
|
||||
{
|
||||
if ($caster->battle) {
|
||||
$this->status = 'Невозможно применить в поединке!';
|
||||
@ -52,12 +67,12 @@ class Magic
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isSuccess($caster, int $difficulty = 40):bool
|
||||
protected function isSuccess($caster, int $difficulty = 40): bool
|
||||
{
|
||||
# 40 - потолок стата.
|
||||
if ($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;
|
||||
}
|
||||
|
||||
public function addExperience(int $amount): void
|
||||
{
|
||||
$this->experience += max($amount, 0);
|
||||
}
|
||||
|
||||
public function getBattle(): int
|
||||
{
|
||||
return $this->battle;
|
||||
|
@ -6,9 +6,6 @@
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\User;
|
||||
|
||||
include_once 'classes/Database/db.php';
|
||||
include_once 'classes/Database/Mysql.php';
|
||||
include_once 'classes/Database/Statement.php';
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
use Battles\Chat;
|
||||
use Battles\Database\Db;
|
||||
use Battles\DressedItems;
|
||||
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;
|
||||
//}
|
||||
|
||||
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 = ?';
|
||||
Db::getInstance()->execute($query, [$_GET['goto'], $_GET['goto'], User::getInstance()->getId()]);
|
||||
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 (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 {
|
||||
if (!User::getInstance($bot)->getId()) {
|
||||
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 = [
|
||||
@ -123,15 +124,15 @@ function savecavedata($cavedata, $caveleader, $floor)
|
||||
|
||||
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 $maximum - Максимальное значение.
|
||||
* @param $current - Текущее значение.
|
||||
* @param $maximum - Максимальное значение.
|
||||
* @param string $line_color - Цвет полоски прогрессбара.
|
||||
* @param string $bg_color - Фон прогрессбара.
|
||||
* @param string $bg_color - Фон прогрессбара.
|
||||
* @return 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 = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['includemagic'])->fetch_assoc();
|
||||
$magic = new Battles\Magic\Magic(Db::getInstance(), $dress['includemagic']);
|
||||
|
||||
$r = '';
|
||||
$script = 'main';
|
||||
if ($user['battle']) {
|
||||
$script = 'fbattle';
|
||||
}
|
||||
$script = User::getInstance()->getBattle() ? 'fbattle' : 'main';
|
||||
|
||||
$r .= "<a onclick=\"";
|
||||
if ($magic['targeted'] == 1) {
|
||||
if ($magic->getMagic()->targeted == 1) {
|
||||
$r .= "okno('Введите название предмета', '{$script}.php?use={$dress['id']}', 'target')";
|
||||
} elseif ($magic['targeted'] == 2) {
|
||||
$r .= "findlogin('" . $magic['name'] . "', '{$script}.php?use={$dress['id']}', 'target')";
|
||||
} elseif ($magic->getMagic()->targeted == 2) {
|
||||
$r .= "findlogin('" . $magic->getMagic()->name . "', '{$script}.php?use={$dress['id']}', 'target')";
|
||||
} else {
|
||||
$r .= "if (confirm('Использовать сейчас?')) window.location='" . $script . ".php?use=" . $dress['id'] . "';";
|
||||
}
|
||||
@ -435,30 +432,13 @@ function usemagic($id, $target)
|
||||
|
||||
function addch($text, $room = 0)
|
||||
{
|
||||
if ($room == 0) {
|
||||
$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); //закрытие
|
||||
}
|
||||
Chat::sendSys($text);
|
||||
}
|
||||
|
||||
|
||||
function addchp($text, $who, $room = 0)
|
||||
{
|
||||
if ($room == 0) {
|
||||
$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); //закрытие
|
||||
Chat::sendSys($text, $who);
|
||||
}
|
||||
|
||||
function err($t)
|
||||
|
Loading…
Reference in New Issue
Block a user