Compare commits
No commits in common. "b1f578f4b066f0ad694848750d313aa54cae27d6" and "5fbccc6a43c0f99fd94abb5e6e4dd219288c17b4" have entirely different histories.
b1f578f4b0
...
5fbccc6a43
12
akadem.php
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\GameLogs;
|
||||
use Battles\Template;
|
||||
use Battles\Travel;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'functions.php';
|
||||
@ -13,7 +13,7 @@ const MEDIC = 'лекарь';
|
||||
$status = 'Внимание! Моментальная оплата без подтверждения!';
|
||||
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
||||
|
||||
function setProfession($name, $type, $needMoney, $needLevel): string
|
||||
function setProfession($name, $type, $needMoney, $needLevel)
|
||||
{
|
||||
global $user;
|
||||
$profId = 0;
|
||||
@ -43,7 +43,8 @@ function setProfession($name, $type, $needMoney, $needLevel): string
|
||||
$profId = 22;
|
||||
}
|
||||
if (!empty($profId)) {
|
||||
User::getInstance()->money()->spend($needMoney);
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - $needMoney);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, User::getInstance()->getId());
|
||||
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
|
||||
GameLogs::addUserLog($_SESSION['uid'], $deloText);
|
||||
@ -66,7 +67,8 @@ if ($get == 'medic') {
|
||||
}
|
||||
|
||||
if ($get == 'exit') {
|
||||
Travel::toRoom(2702, User::getInstance()->getRoom());
|
||||
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', User::getInstance()->getId(), User::getInstance()->getId());
|
||||
header('Location: city.php');
|
||||
}
|
||||
Template::header('Академия');
|
||||
?>
|
||||
@ -78,7 +80,7 @@ Template::header('Академия');
|
||||
<div><?= $status ?></div>
|
||||
<div class="appblock appblock-main">
|
||||
<span class="legend">Информация</span>
|
||||
<span class="wrap">Кредиты<span class="num"><?= User::getInstance()->money()->get() ?></span></span>
|
||||
<span class="wrap">Кредиты<span class="num"><?= User::getInstance()->getMoney() ?></span></span>
|
||||
<span class="wrap">Уровень персонажа<span class="num"><?= User::getInstance()->getLevel() ?></span></span>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
|
78
bank.php
@ -1,23 +1,77 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\GameConfigs;
|
||||
use Battles\Rooms;
|
||||
use Battles\Template;
|
||||
use Exceptions\GameException;
|
||||
use Battles\User;
|
||||
|
||||
require_once "functions.php";
|
||||
const SUCCESS = "Успешная операция!";
|
||||
|
||||
$_POST['action'] ??= null;
|
||||
$bank = new Bank();
|
||||
$bank = new Bank(User::getInstance()->getId());
|
||||
$status = '';
|
||||
|
||||
$toid = $_POST['to_id'] ?? 0;
|
||||
$summa = $_POST['summa'] ?? 0;
|
||||
$submit = $_POST['action'] ?? '';
|
||||
try {
|
||||
// Зачисление кредитов на счёт.
|
||||
if ($_POST['action'] === 'depositMoney' && !empty($_POST['summa'])) {
|
||||
$bank->depositMoney($_POST['summa']);
|
||||
}
|
||||
if ($submit === 'depositMoney' && $summa) {
|
||||
$operation = $bank->depositMoney($summa);
|
||||
User::getInstance()->setMoney($operation['walletMoney']);
|
||||
$bank->setMoney($operation['bankMoney']);
|
||||
$status = SUCCESS;
|
||||
}
|
||||
// Снятие кредитов со счёта.
|
||||
if ($_POST['action'] === 'withdrawMoney' && !empty($_POST['summa'])) {
|
||||
$bank->withdrawMoney($_POST['summa']);
|
||||
}
|
||||
if ($submit === 'withdrawMoney' && $summa) {
|
||||
$operation = $bank->withdrawMoney($summa);
|
||||
User::getInstance()->setMoney($operation['walletMoney']);
|
||||
$bank->setMoney($operation['bankMoney']);
|
||||
$status = SUCCESS;
|
||||
}
|
||||
// Перевод кредитов на другой счёт.
|
||||
if ($_POST['action'] === 'sendMoney' && !empty($_POST['summa']) && !empty($_POST['to-id'])) {
|
||||
$bank->sendMoney($_POST['to-id'], $_POST['summa']);
|
||||
if ($submit === 'sendMoney' && $summa && $toid) {
|
||||
User::getInstance()->setMoney($bank->sendMoney($toid, $summa));
|
||||
$status = SUCCESS;
|
||||
}
|
||||
} catch (GameException $e) {
|
||||
echo 'Банковская ошибка!';
|
||||
} finally {
|
||||
unset($submit, $summa, $toid);
|
||||
}
|
||||
|
||||
require_once 'views/bank.php';
|
||||
Template::header('Банк');
|
||||
?>
|
||||
<link href="css/secondary.css" rel="stylesheet"/>
|
||||
<script src="js/main.js"></script>
|
||||
<?php Template::buildingTop(Rooms::$roomNames[29], 'strah') ?>
|
||||
<div><?= $status ?></div>
|
||||
<div class="appblock appblock-main">
|
||||
<span class="wrap">На счету: <span class="num"><?= $bank->getMoney() ?></span></span>
|
||||
<hr>
|
||||
<span class="wrap">На руках: <span class="num"><?= User::getInstance()->getMoney() ?></span></span>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
<span class="legend">Работа со счётом</span>
|
||||
<form method="post">
|
||||
<input size="10" name="summa" placeholder="Сумма">
|
||||
<input type="hidden" name="action" value="depositMoney">
|
||||
<input type="submit" value="Положить деньги">
|
||||
</form>
|
||||
<form method="post">
|
||||
<input size="10" name="summa" placeholder="Сумма">
|
||||
<input type="hidden" name="action" value="withdrawMoney">
|
||||
<input type="submit" value="Снять деньги">
|
||||
</form>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
<span class="legend">Перевод кредитов</span>
|
||||
<form method="post">
|
||||
<input size="10" name="summa" placeholder="Сумма">
|
||||
<input size="10" name="to-id" placeholder="Cчёт"><br>
|
||||
<input type="hidden" name="action" value="sendMoney">
|
||||
<input type="submit" value="Перевести кредиты">
|
||||
</form>
|
||||
<span class="wrap">Комиссия: <?= GameConfigs::BANK_COMISSION * 100 ?>% от переводимой суммы, но не менее 1 кр.</span>
|
||||
</div>
|
||||
|
7
buy.php
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Database\Db;
|
||||
use Battles\User;
|
||||
|
||||
@ -33,12 +34,14 @@ if (!$check_bonuses) {
|
||||
|
||||
function buy_bonus($name): bool
|
||||
{
|
||||
if (User::getInstance()->money()->getBank() <= PRICES[$name]) {
|
||||
global $prices;
|
||||
$bank = new Bank(User::getInstance()->getId());
|
||||
if ($bank->getMoney() <= PRICES[$name]) {
|
||||
return false;
|
||||
}
|
||||
$query = sprintf('update users_bonuses set %s = %s + 1 where user_id = ?', $name, $name);
|
||||
Db::getInstance()->execute($query, User::getInstance()->getId());
|
||||
User::getInstance()->money()->modifyBank(-PRICES[$name]);
|
||||
$bank->setMoney($bank->getMoney() - $prices[$name]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Database\Db;
|
||||
use Battles\User;
|
||||
|
||||
@ -37,13 +38,14 @@ if (!$check_bonuses) {
|
||||
|
||||
function buy_bonus($name): bool
|
||||
{
|
||||
if (User::getInstance()->money()->getBank() <= PRICES[$name]) {
|
||||
$bank = new Bank(User::getInstance()->getId());
|
||||
if ($bank->getMoney() <= PRICES[$name]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = sprintf('update clan_bonuses set %s = %s + 1 where short_name = ?', $name, $name);
|
||||
Db::getInstance()->execute($query, User::getInstance()->getClan());
|
||||
User::getInstance()->money()->modifyBank(-PRICES[$name]);
|
||||
$bank->setMoney($bank->getMoney() - PRICES[$name]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ if (!$ch_rooms[$in_haos['room']]) {
|
||||
addchp('За убийство босса Цитадели Хаоса вы получили ' . $dress['name'], '{[]}' . Nick::id($all_get[$l_id])->short() . '{[]}');
|
||||
}
|
||||
if ($priz_exp > 0) {
|
||||
\Battles\User::getInstance($all_get[$l_id])->addExperience($priz_exp);
|
||||
GiveExp($all_get[$l_id], $priz_exp);
|
||||
addchp('За убийство босса Цитадели Хаоса вы получили ' . $priz_exp . ' опыта', '{[]}' . Nick::id($all_get[$l_id])->short() . '{[]}');
|
||||
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
|
||||
VALUES ('','0','{$cur_user['id']}','\"" . $all_get[$l_id] . "\" получил в ЦХ \"" . $priz_exp . "\" опыта',1,'" . time() . "');");
|
||||
|
10
cave.php
@ -5,17 +5,18 @@ use Battles\GameLogs;
|
||||
use Battles\ShopItem;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
use Battles\UserEffect;
|
||||
|
||||
require_once 'functions.php';
|
||||
//require_once 'cave/cave_bots.php';
|
||||
$userslots = ['sergi', 'kulon', 'perchi', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'shit', 'boots', 'rybax', 'plaw', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10'];
|
||||
function cancarry($m, $uid): bool
|
||||
function cancarry($m, $uid)
|
||||
{
|
||||
if (!$uid) {
|
||||
$uid = User::getInstance()->getId();
|
||||
}
|
||||
return !UserEffect::isOverEncumbered($uid, $m);
|
||||
$weight = \Battles\Database\Db::getInstance()->execute('select sum(weight) from inventory where owner_id = ? and on_sale = 0', $uid)->fetchColumn();
|
||||
$maxWeight = \Battles\Database\Db::getInstance()->execute('select strength * 4 from users where id = ?', $uid)->fetchColumn();
|
||||
return $weight + $m > $maxWeight ? false : true;
|
||||
}
|
||||
|
||||
function placeinbackpack($qty, $userid = null)
|
||||
@ -338,7 +339,7 @@ while ($rec = mysql_fetch_assoc($r)) {
|
||||
}
|
||||
|
||||
if (User::getInstance()->getRoom() == 621) {
|
||||
$base = "/i/underdesigns/alchcave";
|
||||
$base = "/underdesigns/alchcave";
|
||||
}
|
||||
|
||||
$maxloses = 3;
|
||||
@ -1193,7 +1194,6 @@ Template::header('cave');
|
||||
if ($user['hp'] <= 0) {
|
||||
makedeath();
|
||||
}
|
||||
|
||||
$botNames = CaveBots::$botnames;
|
||||
$botIds = CaveBots::$bots;
|
||||
function drawmap($map1, $players, $x, $y, $direction)
|
||||
|
@ -1,16 +1,18 @@
|
||||
<?php
|
||||
// Здание регистратуры!
|
||||
use Battles\Database\Db;
|
||||
use Battles\Bank;
|
||||
use Battles\GameConfigs;
|
||||
use Battles\Rooms;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
use Battles\Database\Db;
|
||||
|
||||
require_once 'functions.php';
|
||||
$userClan = Db::getInstance()->ofetch('select * from clans where owner_id = ?', User::getInstance()->getId());
|
||||
$clanFullName = $_POST['clan_full_name'] ?? '';
|
||||
$clanShortName = $_POST['clan_short_name'] ?? '';
|
||||
$clanInfo = $_POST['clan_info'] ?? '';
|
||||
$userBank = new Bank(User::getInstance()->getId());
|
||||
if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
|
||||
|
||||
$eff = Db::getInstance()->execute('select count(*) from users_effects where type = 20 and owner_id = ?', User::getInstance()->getId())->fetchColumn();
|
||||
@ -25,7 +27,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
|
||||
if (User::getInstance()->getClan()) {
|
||||
$errorMessage[1] = 'Вы уже состоите в клане!. <BR>';
|
||||
}
|
||||
if (GameConfigs::CLAN['clan_register_cost'] >= User::getInstance()->money()->getBank()) {
|
||||
if (GameConfigs::CLAN['clan_register_cost'] >= $userBank->getMoney()) {
|
||||
$errorMessage[2] = 'Не хватает денег на регистрацию клана. <BR>';
|
||||
}
|
||||
if (!$eff) {
|
||||
@ -37,8 +39,8 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
|
||||
if (!$errorMessage || User::getInstance()->getAdmin()) {
|
||||
try {
|
||||
Db::getInstance()->execute('insert into clans (owner_id, full_name, short_name, info) values (?,?,?,?)', [User::getInstance()->getId(), $clanFullName, $clanShortName, $clanInfo]);
|
||||
|
||||
User::getInstance()->money()->modifyBank(-GameConfigs::CLAN['clan_register_cost'], 'clanRegister');
|
||||
$userBank->setMoney($userBank->getMoney() - GameConfigs::CLAN['clan_register_cost']);
|
||||
Battles\Bank::setBankMoney($userBank->getMoney(), User::getInstance()->getId(), 'clanRegister');
|
||||
// Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит.
|
||||
$userClan = new stdClass();
|
||||
$userClan->full_name = $clanFullName;
|
||||
@ -99,7 +101,7 @@ if ($userClan): ?>
|
||||
Для регистрации клана необходимо иметь:
|
||||
<ol>
|
||||
<li>Проверку на чистоту. У вас её нет.
|
||||
<li>10000 кредитов на банковском счёте. У вас на счету <?= User::getInstance()->money()->getBank() ?>.
|
||||
<li>10000 кредитов на банковском счёте. У вас на счету <?= $userBank->getMoney() ?>.
|
||||
</ol>
|
||||
Поле информации не обазательное. Но его содержимое может серьёзно повысить шансы на регистрацию клана.<BR>
|
||||
Заявку на регистрацию подает глава клана.
|
||||
|
@ -7,22 +7,21 @@
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Exceptions\GameException;
|
||||
use Battles\Database\Db;
|
||||
use Throwable;
|
||||
|
||||
class Bank
|
||||
{
|
||||
private int $user_id = 0;
|
||||
public int $user_id = 0;
|
||||
private int $money = 0;
|
||||
private string $error = '';
|
||||
private string $status = '';
|
||||
private int $comission = 0;
|
||||
private $user;
|
||||
|
||||
private const ERROR_NO_MONEY_IN_WALLET = "Ошибка! Нет денег в кошельке!";
|
||||
private const ERROR_NO_BANK_ACCOUNT = "Ошибка! Счёта не существует!";
|
||||
private const ERROR_NO_MONEY_IN_BANK_ACCOUNT = "Ошибка! Нет денег на счету!";
|
||||
private const ERROR_WRONG_AMOUNT = "Ошибка! Сумма должна быть положительной!";
|
||||
private const ERROR_WRONG_ID = 'Неверный ID!';
|
||||
private const LOG = [
|
||||
const ERROR_NO_MONEY_IN_WALLET = "Ошибка! Нет денег в кошельке!";
|
||||
const ERROR_NO_BANK_ACCOUNT = "Ошибка! Счёта не существует!";
|
||||
const ERROR_NO_MONEY_IN_BANK_ACCOUNT = "Ошибка! Нет денег на счету!";
|
||||
const ERROR_WRONG_AMOUNT = "Ошибка! Сумма должна быть положительной!";
|
||||
const LOG = [
|
||||
'sendMoney' => 'Банк: Перевод средств на другой счёт.',
|
||||
'receiveMoney' => 'Банк: Получение средств.',
|
||||
'depositMoney' => 'Пополнение счёта.',
|
||||
@ -31,12 +30,10 @@ class Bank
|
||||
'sellShop' => 'Продажа товара в магазине.'
|
||||
];
|
||||
|
||||
public function __construct(int $user_id = null)
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
if (empty($user_id)) {
|
||||
$user_id = User::getInstance()->getId();
|
||||
}
|
||||
$bank_row = Db::getInstance()->fetch('SELECT user_id, money FROM bank WHERE user_id = ?', $user_id);
|
||||
$this->user = Db::getInstance()->fetch('SELECT money FROM users WHERE id = ?', $user_id);
|
||||
foreach ($this as $key => $value) {
|
||||
if (isset($bank_row[$key])) {
|
||||
$this->$key = $bank_row[$key];
|
||||
@ -51,69 +48,75 @@ class Bank
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function commission(int $amount): int
|
||||
private function bankCommission(int $amount): int
|
||||
{
|
||||
$bankCommission = round($amount * GameConfigs::BANK_COMISSION);
|
||||
$this->comission = max(1, (int)$bankCommission);
|
||||
return $this->comission;
|
||||
if ($bankCommission < 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return (int)$bankCommission;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Пишем банковское событие в лог в БД
|
||||
*
|
||||
* @param int $receiverId ID получателя.
|
||||
* @param int $amount сумма.
|
||||
* @param int $receiverId ID получателя.
|
||||
* @param int $amount сумма.
|
||||
* @param string $operationType тип банковской операции.
|
||||
* @param ?int $senderId ID отправителя (ID игрока, если не указано иное).
|
||||
* @param int $senderId ID отправителя (ID игрока, если не указано иное).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addLog(int $receiverId, int $amount, string $operationType, ?int $senderId = null): void
|
||||
private function bankLogs(int $receiverId, int $amount, string $operationType, int $senderId = null): void
|
||||
{
|
||||
if (is_null($senderId)) {
|
||||
$senderId = $this->user_id;
|
||||
}
|
||||
if ($operationType === 'depositMoney' || $operationType === 'withdrawMoney') {
|
||||
$text = self::LOG[$operationType];
|
||||
if ($operationType == "sendMoney") {
|
||||
$text .= " Комиссия: " . $this->bankCommission($amount);
|
||||
} elseif ($operationType == "depositMoney") {
|
||||
$receiverId = $this->user_id;
|
||||
} elseif ($operationType == "withdrawMoney") {
|
||||
$receiverId = $this->user_id;
|
||||
$text .= " Комиссия: " . $this->bankCommission($amount);
|
||||
}
|
||||
$commText = $this->comission ? ' Комиссия: ' . $this->comission : '';
|
||||
$text = self::LOG[$operationType] . $commText;
|
||||
$this->status = $text;
|
||||
GameLogs::addBankLog($senderId, $receiverId, $amount, $operationType, $text);
|
||||
GameLogs::addBankLog($senderId,$receiverId,$amount,$operationType,$text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Перевод денег между банковскими счетами игроков с банковской комиссией.
|
||||
*
|
||||
* @param mixed $receiver ID получателя.
|
||||
* @param mixed $amount Cумма.
|
||||
* @param int $receiver ID получателя.
|
||||
* @param int $amount сумма.
|
||||
*
|
||||
* @return int
|
||||
* @throws GameException
|
||||
*/
|
||||
public function sendMoney($receiver, $amount)
|
||||
public function sendMoney(int $receiver, int $amount): int
|
||||
{
|
||||
if (!is_numeric($receiver)) {
|
||||
$this->error = self::ERROR_WRONG_ID;
|
||||
return;
|
||||
$receiverWallet = Db::getInstance()->ofetch('SELECT money FROM bank WHERE user_id = ?', $receiver);
|
||||
if ($amount <= 0) {
|
||||
throw new GameException(self::ERROR_WRONG_AMOUNT);
|
||||
}
|
||||
$rec = new self($receiver);
|
||||
if (!is_numeric($amount) || $amount <= 0) {
|
||||
$this->error = self::ERROR_WRONG_AMOUNT;
|
||||
if (!$receiverWallet) {
|
||||
throw new GameException(self::ERROR_NO_BANK_ACCOUNT);
|
||||
}
|
||||
if (!$rec->user_id) {
|
||||
$this->error = self::ERROR_NO_BANK_ACCOUNT;
|
||||
}
|
||||
$amountWithComission = $amount + $this->commission($amount);
|
||||
$amountWithComission = $amount + $this->bankCommission($amount);
|
||||
if ($amountWithComission > $this->money) {
|
||||
$this->error = self::ERROR_NO_MONEY_IN_BANK_ACCOUNT;
|
||||
}
|
||||
if ($this->error) {
|
||||
return;
|
||||
throw new GameException(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
|
||||
}
|
||||
// Снимаем сумму с комиссией у отправителя
|
||||
$this->modify(-$amountWithComission);
|
||||
$this->addLog($rec->user_id, $this->money, 'sendMoney', $this->user_id);
|
||||
$this->money -= $amountWithComission;
|
||||
self::setBankMoney($this->money, $this->user_id);
|
||||
$this->bankLogs($receiver, $this->money, "sendMoney");
|
||||
// Отдаём сумму на счёт получателю
|
||||
$rec->modify($amount);
|
||||
$rec->addLog($rec->user_id, $rec->money, 'receiveMoney', $this->user_id);
|
||||
$receiverWallet->money += $amount;
|
||||
self::setBankMoney($receiverWallet->money, $receiver);
|
||||
$this->bankLogs($receiver, $receiverWallet->money, "receiveMoney");
|
||||
// Возвращаем изменившиеся значения
|
||||
return $this->money;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,22 +124,30 @@ class Bank
|
||||
*
|
||||
* @param int $amount сумма.
|
||||
*
|
||||
* @return array
|
||||
* @throws GameException
|
||||
*/
|
||||
public function depositMoney(int $amount)
|
||||
public function depositMoney(int $amount): array
|
||||
{
|
||||
if ($amount <= 0) {
|
||||
$this->error = self::ERROR_WRONG_AMOUNT;
|
||||
throw new GameException(self::ERROR_WRONG_AMOUNT);
|
||||
}
|
||||
$walletMoney = Db::getInstance()->fetchColumn('SELECT money FROM users WHERE id = ?', $this->user_id);
|
||||
if ($walletMoney < $amount) {
|
||||
throw new GameException(self::ERROR_NO_MONEY_IN_WALLET);
|
||||
}
|
||||
// Забираем деньги из кошелька получателя
|
||||
if (!User::getInstance($this->user_id)->money()->spend($amount)) {
|
||||
$this->error = self::ERROR_NO_MONEY_IN_WALLET;
|
||||
}
|
||||
if ($this->error) {
|
||||
return;
|
||||
}
|
||||
$this->user->money -= $amount;
|
||||
self::setWalletMoney($this->user->money, $this->user_id);
|
||||
// Отдаём сумму на счёт получателю
|
||||
$this->modify($amount);
|
||||
$this->addLog(0, $this->money, 'depositMoney');
|
||||
$this->money += $amount;
|
||||
self::setBankMoney($this->money, $this->user_id);
|
||||
$this->bankLogs(0, $this->money, "depositMoney");
|
||||
// Возвращаем изменившиеся значения
|
||||
return [
|
||||
'walletMoney' => $this->user->money,
|
||||
'bankMoney' => $this->money
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,29 +155,66 @@ class Bank
|
||||
*
|
||||
* @param int $amount сумма.
|
||||
*
|
||||
* @return array
|
||||
* @throws GameException
|
||||
*/
|
||||
public function withdrawMoney(int $amount)
|
||||
public function withdrawMoney(int $amount): array
|
||||
{
|
||||
if ($amount <= 0) {
|
||||
$this->error = self::ERROR_WRONG_AMOUNT;
|
||||
throw new GameException(self::ERROR_WRONG_AMOUNT);
|
||||
}
|
||||
$amountWithComission = $amount + $this->commission($amount);
|
||||
$amountWithComission = $amount + $this->bankCommission($amount);
|
||||
if ($this->money < $amountWithComission) {
|
||||
$this->error = self::ERROR_NO_MONEY_IN_BANK_ACCOUNT;
|
||||
}
|
||||
if ($this->error) {
|
||||
return;
|
||||
throw new GameException(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
|
||||
}
|
||||
// Снимаем сумму с комиссией у отправителя
|
||||
$this->modify(-$amountWithComission);
|
||||
$this->addLog(0, $this->money, 'withdrawMoney');
|
||||
$this->money -= $amountWithComission;
|
||||
self::setBankMoney($this->money, $this->user_id);
|
||||
$this->bankLogs(0, $this->money, "withdrawMoney");
|
||||
// Отдаём сумму в кошелёк получателя
|
||||
User::getInstance($this->user_id)->money()->earn($amount);
|
||||
$this->user['money'] += $amount;
|
||||
self::setWalletMoney($this->user['money'], $this->user_id);
|
||||
// Возвращаем изменившиеся значения
|
||||
return [
|
||||
'walletMoney' => $this->user['money'],
|
||||
'bankMoney' => $this->money
|
||||
];
|
||||
}
|
||||
|
||||
private function save()
|
||||
/**
|
||||
* Установить количество денег на банковском счету.
|
||||
*
|
||||
* @param int $amount сумма.
|
||||
* @param int $user_id ID пользователя.
|
||||
* @param string $operationType Тип операции. По умолчанию пусто. Если ввести, система запишет событие в банковский лог.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setBankMoney(int $amount, int $user_id, string $operationType = ''): void
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE bank SET money = ? WHERE user_id = ?', [$this->money, $this->user_id]);
|
||||
try {
|
||||
Db::getInstance()->execute('UPDATE bank SET money = ? WHERE user_id = ?', [$amount, $user_id]);
|
||||
if ($operationType) {
|
||||
GameLogs::addBankLog(0, 0, $amount, $operationType, self::LOG[$operationType]);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
echo "Не отработал запрос в БД в файле {$e->getFile()}({$e->getLine()})";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить количество денег на руках.
|
||||
*
|
||||
* @param int $amount сумма.
|
||||
* @param int $user_id ID пользователя.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setWalletMoney(int $amount, int $user_id): void
|
||||
{
|
||||
User::getInstance($user_id)->setMoney($amount);
|
||||
User::getInstance($user_id)->saveMoney();
|
||||
}
|
||||
|
||||
public function getMoney(): int
|
||||
@ -174,30 +222,8 @@ class Bank
|
||||
return $this->money;
|
||||
}
|
||||
|
||||
public function modify(int $amount, string $logType = '')
|
||||
public function setMoney($amount)
|
||||
{
|
||||
if ($amount > 0) {
|
||||
// add_money
|
||||
$this->money += $amount;
|
||||
$this->save();
|
||||
} elseif ($amount < 0) {
|
||||
// remove_money
|
||||
if ($this->money < $amount) {
|
||||
return;
|
||||
}
|
||||
$this->money -= $amount;
|
||||
$this->save();
|
||||
}
|
||||
if ($logType && $amount !== 0) {
|
||||
$this->addLog(0, $this->money, $logType);
|
||||
}
|
||||
$this->money = $amount;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
if (!$this->error) {
|
||||
return $this->status;
|
||||
}
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ class Check
|
||||
* Check constructor.
|
||||
*
|
||||
* @param User $user
|
||||
* @param Db $db
|
||||
*/
|
||||
public function __construct(User $user, Db $db)
|
||||
{
|
||||
@ -22,13 +21,8 @@ class Check
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public static function expiredEffects()
|
||||
public function Effects()
|
||||
{
|
||||
return Db::getInstance()->execute('delete from users_effects where remaining_time <= ?', strtotime('now'));
|
||||
}
|
||||
|
||||
public static function userExists($id): bool
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('select count(*) from users where id = ?', $id) > 0;
|
||||
return $this->db->execute('delete from users_effects where remaining_time <= ?', strtotime('now'));
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\Models\User\Effects;
|
||||
|
||||
class Clan
|
||||
{
|
||||
@ -35,13 +34,14 @@ class Clan
|
||||
if (User::getInstance($login)->getLevel() < 1) {
|
||||
$error .= '<br>Персонаж 0 уровня не может быть принят!';
|
||||
}
|
||||
if (!User::getInstance()->money()->spend(GameConfigs::CLAN['add_member_cost'])) {
|
||||
if (User::getInstance()->getMoney() < GameConfigs::CLAN['add_member_cost']) {
|
||||
$error .= '<br>Недостаточно денег!';
|
||||
}
|
||||
if ($error) {
|
||||
return $error;
|
||||
}
|
||||
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - GameConfigs::CLAN['add_member_cost']);
|
||||
User::getInstance()->saveMoney();
|
||||
User::getInstance($login)->setClan(User::getInstance()->getClan());
|
||||
return "Персонаж «{$login}» успешно принят в клан.";
|
||||
}
|
||||
@ -49,18 +49,20 @@ class Clan
|
||||
public function removeMember(string $login): string
|
||||
{
|
||||
$error = null;
|
||||
if (User::getInstance()->getMoney() < GameConfigs::CLAN['remove_member_cost']) {
|
||||
$error .= '<br>Недостаточно денег!';
|
||||
}
|
||||
if (User::getInstance($login)->getId() === User::getInstance()->getId()) {
|
||||
$error .= '<br>Себя выгонять нельзя!';
|
||||
}
|
||||
if (User::getInstance($login)->getClan() !== User::getInstance()->getClan()) {
|
||||
$error .= '<br>Персонаж не состоит в этом клане!';
|
||||
}
|
||||
if (!User::getInstance()->money()->spend(GameConfigs::CLAN['remove_member_cost'])) {
|
||||
$error .= '<br>Недостаточно денег!';
|
||||
}
|
||||
if ($error) {
|
||||
return $error;
|
||||
}
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - GameConfigs::CLAN['remove_member_cost']);
|
||||
User::getInstance()->saveMoney();
|
||||
User::getInstance($login)->setClan(null);
|
||||
return "Персонаж «{$login}» покинул клан.";
|
||||
}
|
||||
@ -98,7 +100,7 @@ class Clan
|
||||
|
||||
private function getProverka($user_id)
|
||||
{
|
||||
return Effects::count($user_id, 20);
|
||||
return Db::getInstance()->fetchColumn('select count(*) from users_effects where type = 20 and owner_id = ?', $user_id);
|
||||
}
|
||||
|
||||
public function getClanOwnerId(): ?int
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\Models\Inventory;
|
||||
use stdClass;
|
||||
|
||||
class DressedItems
|
||||
@ -53,7 +52,7 @@ class DressedItems
|
||||
self::getItemsInSlots();
|
||||
// Проверяем, что используется один из 12 слотов и наличие предмета в слоте.
|
||||
if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem->$slot_id) {
|
||||
Inventory::undressOne($slot_id, $this->USERID);
|
||||
self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,177 +0,0 @@
|
||||
<?php
|
||||
# Date: 19.02.2022 (2:33)
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Hostel
|
||||
{
|
||||
private array $status = [];
|
||||
private int $uid;
|
||||
private int $hid;
|
||||
private int $type;
|
||||
private int $time;
|
||||
|
||||
public const PRICEPERTYPE = [
|
||||
1 => [8, 16, 24, 32],
|
||||
2 => [15, 30, 45, 60],
|
||||
3 => [25, 50, 75, 100],
|
||||
4 => [40, 80, 120, 160]
|
||||
];
|
||||
public const BASENAME = [
|
||||
1 => 'Сумка',
|
||||
2 => 'Сундук',
|
||||
3 => 'Комната',
|
||||
4 => 'Амбар',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->uid = User::getInstance()->getId();
|
||||
$data = Db::getInstance()->ofetch('select id, type, time from hostel where uid = ?', $this->uid);
|
||||
$this->hid = $data->id ?? null;
|
||||
$this->type = $data->type ?? null;
|
||||
$this->time = $data->time ?? null;
|
||||
}
|
||||
|
||||
private function add7DayRent($type)
|
||||
{
|
||||
Db::getInstance()->execute('insert into hostel (uid, type, time) values (?,?,?)', [$this->uid, $type, time() + 60 * 60 * 24 * 7]);
|
||||
}
|
||||
|
||||
private function addRentTime($hostel_id, $time)
|
||||
{
|
||||
Db::getInstance()->execute('update hostel set time = ? where id = ? and uid = ?', [$time, $hostel_id, $this->uid]);
|
||||
}
|
||||
|
||||
private function removeItems()
|
||||
{
|
||||
Db::getInstance()->execute('update inventory set in_hostel = 0 where owner_id = ? and in_hostel = 1', $this->uid);
|
||||
}
|
||||
|
||||
private function removeRent()
|
||||
{
|
||||
Db::getInstance()->execute('delete from hostel where id = ? and uid = ?', [$this->hid, $this->uid]);
|
||||
}
|
||||
|
||||
private function pay($amount): bool
|
||||
{
|
||||
if (!User::getInstance()->money()->spend($amount)) {
|
||||
$this->setError('Недостаточно денег!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function hasNoRents(): bool
|
||||
{
|
||||
if ($this->hid) {
|
||||
$this->setError('Не более 1 арендованного места!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function typeIsAllowed($type): bool
|
||||
{
|
||||
if (!in_array($type, [1, 2, 3, 4])) {
|
||||
$this->setError('Неверный тип аренды!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setError(string $message)
|
||||
{
|
||||
$this->status = ['type' => 'error', 'message' => $message];
|
||||
}
|
||||
|
||||
private function setSuccess(string $message)
|
||||
{
|
||||
$this->status = ['type' => 'success', 'message' => $message];
|
||||
}
|
||||
|
||||
public function newRent($type): bool
|
||||
{
|
||||
if (
|
||||
!$this->typeIsAllowed($type) ||
|
||||
!$this->hasNoRents() ||
|
||||
!$this->pay(self::PRICEPERTYPE[$type][0])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
$this->add7DayRent($type);
|
||||
$this->setSuccess('Поздравляем с успешной арендой!');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function remove(): bool
|
||||
{
|
||||
if ($this->time < time()) {
|
||||
$this->setError('Нельзя отказаться от услуг если имеется задолежнность!');
|
||||
return false;
|
||||
}
|
||||
$this->removeRent();
|
||||
$this->removeItems();
|
||||
$this->setSuccess('Вы успешно отказались от аренды!');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function changeType(int $type)
|
||||
{
|
||||
$this->remove();
|
||||
$this->newRent($type);
|
||||
}
|
||||
|
||||
public function changeTime(int $ordered_time): bool
|
||||
{
|
||||
$daysByOrder = [
|
||||
1 => 7,
|
||||
2 => 14,
|
||||
3 => 21,
|
||||
4 => 28,
|
||||
];
|
||||
if (
|
||||
!$this->typeIsAllowed($ordered_time) ||
|
||||
!$this->pay(self::PRICEPERTYPE[$this->type][$ordered_time - 1])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
$this->time += 60 * 60 * 24 * $daysByOrder[$ordered_time];
|
||||
$this->addRentTime($this->hid, $this->time);
|
||||
$this->setSuccess('Всё прошло успешно!');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getHid(): ?int
|
||||
{
|
||||
return $this->hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getType(): ?int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getTime(): ?int
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getStatus(): array
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Models\Inventory;
|
||||
use Battles\Database\Db;
|
||||
|
||||
class InventoryItem extends Item
|
||||
{
|
||||
private ?string $present;
|
||||
private int $owner_id;
|
||||
private $present;
|
||||
private $owner_id;
|
||||
private const TOO_MANY_ITEMS_IN_SLOTS = 'Критическая ошибка: Переполнение слота!';
|
||||
private const UNKNOWN_ITEM_TYPE = 'Неизвестный тип предмета!';
|
||||
private const REQUIREMENTS_NOT_MET = 'Персонаж не соответствует требованиям!';
|
||||
@ -47,21 +46,22 @@ IMG;
|
||||
}
|
||||
}
|
||||
|
||||
public function printControls()
|
||||
{
|
||||
public function printControls(){
|
||||
// Для кнопок управления под картинкой.
|
||||
}
|
||||
|
||||
private function dressStatsChecks(): bool
|
||||
private function dressStatsChecks(): ?string
|
||||
{
|
||||
$checkStats = new UserStats($this->owner_id);
|
||||
$stat = $checkStats->getFullStats();
|
||||
return $this->need_strength > $stat->strength
|
||||
|| $this->need_dexterity > $stat->dexterity
|
||||
|| $this->need_intuition > $stat->intuition
|
||||
|| $this->need_endurance > $stat->endurance
|
||||
|| $this->need_intelligence > $stat->intelligence
|
||||
|| $this->need_wisdom > $stat->wisdom;
|
||||
return
|
||||
$this->need_strength > $stat->strength
|
||||
|| $this->need_dexterity > $stat->dexterity
|
||||
|| $this->need_intuition > $stat->intuition
|
||||
|| $this->need_endurance > $stat->endurance
|
||||
|| $this->need_intelligence > $stat->intelligence
|
||||
|| $this->need_wisdom > $stat->wisdom
|
||||
? true : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,8 +77,8 @@ IMG;
|
||||
// считаем сколько ОДЕТЫХ предметов в слоте в который мы хотим одеть предмет. 1=просто вещь 1-3=шашни с кольцами
|
||||
// Count добавленный в первый запрос возвращает одну строку в любом случае.
|
||||
// fetch возвращает одну строку в любом случае.
|
||||
$weared = Inventory::getDressed($this->item_type, $this->owner_id);
|
||||
$wearedCount = Inventory::countDressed($this->item_type, $this->owner_id);
|
||||
$weared = Db::getInstance()->ofetchAll('SELECT dressed_slot FROM inventory WHERE dressed_slot != 0 AND item_type = ? AND owner_id = ?', [$this->item_type, $this->owner_id]);
|
||||
$wearedCount = Db::getInstance()->ofetch('select count(dressed_slot) as c from inventory where dressed_slot !=0 and item_type = ? and owner_id = ?', [$this->item_type, $this->owner_id]);
|
||||
// Если в слоте есть предмет(ы), забиваем их массив одетых в слот предметов.
|
||||
if ($wearedCount) {
|
||||
foreach ($weared as $item) {
|
||||
@ -93,11 +93,11 @@ IMG;
|
||||
//работаем с нормальными слотами
|
||||
if ($wearedCount->c == 1) {
|
||||
//если слот занят, снимаем старый предмет и одеваем новый предмет
|
||||
Inventory::undressOne($itemInSlot[0], $this->owner_id);
|
||||
Inventory::dressOne($this->item_id, $this->owner_id);
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$itemInSlot[0], $this->owner_id]);
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]);
|
||||
} elseif (!$wearedCount->c) {
|
||||
//если слот пуст, одеваем новый предмет
|
||||
Inventory::dressOne($this->item_id, $this->owner_id);
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]);
|
||||
} else {
|
||||
/* проверка на переполнение слотов */
|
||||
$error = self::TOO_MANY_ITEMS_IN_SLOTS;
|
||||
@ -111,10 +111,11 @@ IMG;
|
||||
// Сортируем массив свободных слотов по возрастанию.
|
||||
sort($emptyRingSlots);
|
||||
// Одеваем предмет в первый свободный слот.
|
||||
Inventory::dressOneToSlot($this->item_id, $emptyRingSlots[0]);
|
||||
Db::getInstance()->execute('update inventory set dressed_slot = ? where item_id = ?', [$emptyRingSlots[0], $this->item_id]);
|
||||
} elseif ($wearedCount->c == 3) {
|
||||
// Cнимаем предмет из последнего слота 11 и одеваем новый предмет
|
||||
Inventory::changeRings($this->item_id);
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11');
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?', $this->item_id);
|
||||
} else {
|
||||
/* проверка на переполнение слотов */
|
||||
$error = self::TOO_MANY_ITEMS_IN_SLOTS;
|
||||
@ -127,31 +128,9 @@ IMG;
|
||||
return $error ?? true;
|
||||
}
|
||||
|
||||
// Выбрасываем вещь.
|
||||
public function drop(): string
|
||||
public static function destroyItem($itemId)
|
||||
{
|
||||
if (empty($this->item_id)) {
|
||||
return 'Ошибка: предмет не найден!';
|
||||
}
|
||||
if (Inventory::isWeared($this->item_id)) {
|
||||
return 'Ошибка: нельзя выбросить одетый предмет!';
|
||||
}
|
||||
Inventory::destroyItem($this->item_id, $this->owner_id);
|
||||
GameLogs::addUserLog(User::getInstance()->getId(), User::getInstance()->getLogin() . ' выбросил предмет ' . $this->name . ' id:(cap' . $this->item_id . ')');
|
||||
return 'Предмет ' . $this->name . ' выброшен.';
|
||||
}
|
||||
|
||||
/** Снятие всех предметов, которые не подходят по статам. */
|
||||
public static function autoDrop()
|
||||
{
|
||||
$DI = new DressedItems(User::getInstance()->getId());
|
||||
foreach ($DI->getItemsInSlots() as $dressedItem)
|
||||
{
|
||||
$ITM = new self($dressedItem);
|
||||
if (!$ITM->dressStatsChecks()) {
|
||||
$DI->undressItem($dressedItem->dressed_slot);
|
||||
}
|
||||
}
|
||||
Db::getInstance()->execute('delete from inventory where dressed_slot = 0 and owner_id = ? and item_id = ?', [$_SESSION['uid'], $itemId]);
|
||||
}
|
||||
|
||||
/** Надеюсь, временная заглушка, которая объединяет get_meshok() и другую выдачу одной строкой.
|
||||
@ -159,9 +138,9 @@ IMG;
|
||||
*/
|
||||
public static function getWeightData(): string
|
||||
{
|
||||
$all = Inventory::getWeight(User::getInstance()->getId());
|
||||
$max = User::getInstance()->stats()->getMaxWeight();
|
||||
$css = $all > $max ? ' style="color:maroon;"' : '';
|
||||
return "<span$css>$all / $max</span>";
|
||||
$query = 'select sum(weight) as `all`, strength * 4 as max from inventory left join users u on owner_id = id where owner_id = ?';
|
||||
$weight = Db::getInstance()->ofetch($query, User::getInstance()->getId());
|
||||
$css = $weight->all > $weight->max ? ' style="color:maroon;"' : '';
|
||||
return "<span$css>$weight->all / $weight->max</span>";
|
||||
}
|
||||
}
|
@ -3,13 +3,13 @@
|
||||
// Магия лечения травм
|
||||
namespace Battles\Magic;
|
||||
|
||||
use Battles\Database\Db, Battles\User, Battles\UserEffect;
|
||||
use Battles\UserEffects, Battles\Database\Db, Battles\User;
|
||||
|
||||
class CureInjury extends Magic
|
||||
{
|
||||
private $target;
|
||||
private $login;
|
||||
//use UserEffects;
|
||||
use UserEffects;
|
||||
|
||||
/**
|
||||
* Магия лечения травм. Если у персонажа несколько травм, лечится самая тяжёлая.
|
||||
@ -25,14 +25,16 @@ class CureInjury extends Magic
|
||||
}
|
||||
$ok = null;
|
||||
$injury = $db->ofetch('SELECT effect_id, type, name FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ? ORDER BY type DESC LIMIT 1', $target);
|
||||
if (in_array($injury->type, [11, 12, 13, 14]) && $injuryType >= $injury->type && UserEffect::remove($target, $injury->effect_id)) {
|
||||
if (empty($injury->name) || $injury->name === 'Неизвестный эффект') {
|
||||
$injuryName = UserEffect::$effectName[$injury->type];
|
||||
if (in_array($injury->type, [11, 12, 13, 14]) && $injuryType >= $injury->type) {
|
||||
$db->execute('DELETE FROM users_effects WHERE effect_id = ?', $injury->effect_id);
|
||||
if (empty($injury->name) || $injury->name == 'Неизвестный эффект') {
|
||||
$injuryName = self::$effectName[$injury->type];
|
||||
} else {
|
||||
$injuryName = $injury->name;
|
||||
}
|
||||
$ok = "Вы вылечили повреждение ${injuryName} персонажу $this->login.";
|
||||
} elseif ($injury->effect_id && $injuryType === 15 && UserEffect::massRemove($target, [11,12,13,14])) {
|
||||
} elseif ($injury->effect_id && $injuryType == 15) {
|
||||
$db->execute('DELETE FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?', $target);
|
||||
$ok = "Вы вылечили все повреждения персонажу $this->login.";
|
||||
}
|
||||
return $ok;
|
||||
|
39
classes/Battles/Models/EffectsModel.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 05.07.2020
|
||||
* Time: 23:32
|
||||
*/
|
||||
|
||||
namespace Battles\Models;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class EffectsModel
|
||||
{
|
||||
protected $DB;
|
||||
const EFFECT_HIDEUSERINFO = 5; // Обезлик
|
||||
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
$this->DB = Db::getInstance()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка обезличен ли персонаж.
|
||||
* @return int date() до конца эффекта или 0.
|
||||
*/
|
||||
public function getHideUserInfoStatus(): int
|
||||
{
|
||||
if ($this->DB) {
|
||||
$i = 0;
|
||||
while ($i < count($this->DB)) {
|
||||
if ($this->DB[$i]->type == self::EFFECT_HIDEUSERINFO) {
|
||||
return $this->DB[$i]->remaining_time;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
<?php
|
||||
# Date: 23.02.2022 (2:47)
|
||||
namespace Battles\Models;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Inventory
|
||||
{
|
||||
public static function getWeight(int $user_id): int
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('
|
||||
select
|
||||
sum(weight)
|
||||
from
|
||||
inventory
|
||||
where
|
||||
owner_id = ?
|
||||
and on_sale = 0
|
||||
', $user_id);
|
||||
}
|
||||
|
||||
public static function getBonuses(int $user_id)
|
||||
{
|
||||
return Db::getInstance()->ofetch("
|
||||
select
|
||||
sum(add_strength) as item_strength,
|
||||
sum(add_dexterity) as item_dexterity,
|
||||
sum(add_intuition) as item_intuition,
|
||||
sum(add_endurance) as item_endurance,
|
||||
sum(add_intelligence) as item_intelligence,
|
||||
sum(add_wisdom) as item_wisdom,
|
||||
sum(add_accuracy) as item_accuracy,
|
||||
sum(add_evasion) as item_evasion,
|
||||
sum(add_criticals) as item_criticals,
|
||||
sum(add_min_physical_damage) as item_min_physical_damage,
|
||||
sum(add_max_physical_damage) as item_max_physical_damage
|
||||
from
|
||||
inventory
|
||||
where
|
||||
dressed_slot != 0 and
|
||||
owner_id = ?
|
||||
", $user_id);
|
||||
}
|
||||
|
||||
public static function getDressed(int $item_type, int $user_id): object
|
||||
{
|
||||
return Db::getInstance()->ofetchAll('
|
||||
SELECT
|
||||
dressed_slot
|
||||
FROM
|
||||
inventory
|
||||
WHERE
|
||||
dressed_slot != 0
|
||||
AND item_type = ?
|
||||
AND owner_id = ?
|
||||
', [$item_type, $user_id]);
|
||||
}
|
||||
|
||||
public static function countDressed(int $item_type, int $user_id): object
|
||||
{
|
||||
return Db::getInstance()->ofetchAll('
|
||||
SELECT
|
||||
count(dressed_slot)
|
||||
FROM
|
||||
inventory
|
||||
WHERE
|
||||
dressed_slot != 0
|
||||
AND item_type = ?
|
||||
AND owner_id = ?
|
||||
', [$item_type, $user_id]);
|
||||
}
|
||||
|
||||
public static function undressOne(int $slot, int $user_id)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
UPDATE
|
||||
inventory
|
||||
SET
|
||||
dressed_slot = 0
|
||||
WHERE
|
||||
dressed_slot = ?
|
||||
AND owner_id = ?
|
||||
', [$slot, $user_id]);
|
||||
}
|
||||
|
||||
public static function dressOne(int $item_id, int $user_id)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
UPDATE
|
||||
inventory
|
||||
SET
|
||||
dressed_slot = item_type
|
||||
WHERE
|
||||
item_id = ?
|
||||
AND owner_id = ?
|
||||
', [$item_id, $user_id]);
|
||||
}
|
||||
|
||||
public static function dressOneToSlot(int $item_id, int $slot)
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = ? WHERE item_id = ?', [$slot, $item_id]);
|
||||
}
|
||||
|
||||
public static function destroyItem(int $item_id, int $user_id)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
delete
|
||||
from
|
||||
inventory
|
||||
where
|
||||
dressed_slot = 0
|
||||
and owner_id = ?
|
||||
and item_id = ?
|
||||
', [$user_id, $item_id]);
|
||||
}
|
||||
|
||||
public static function changeRings(int $item_id)
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11');
|
||||
Db::getInstance()->execute('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?', $item_id);
|
||||
}
|
||||
|
||||
public static function isWeared(int $item_id): bool
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
inventory
|
||||
where
|
||||
item_id = ?
|
||||
and dressed_slot > 0
|
||||
', $item_id) > 0;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 04.07.2020
|
||||
* Time: 13:17
|
||||
*/
|
||||
namespace Battles\Models;
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\User;
|
||||
|
||||
|
||||
class Presents
|
||||
{
|
||||
public function getAll($user_id = null)
|
||||
{
|
||||
if (is_null($user_id)) {
|
||||
$user_id = User::getInstance()->getId();
|
||||
}
|
||||
return Db::getInstance()->execute('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?', $user_id);
|
||||
}
|
||||
}
|
26
classes/Battles/Models/PresentsModel.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 04.07.2020
|
||||
* Time: 13:17
|
||||
*/
|
||||
namespace Battles\Models;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class PresentsModel
|
||||
{
|
||||
protected $DB;
|
||||
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
if (!$this->DB) {
|
||||
$this->DB = Db::getInstance()->execute('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?', $user_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllPresents()
|
||||
{
|
||||
return $this->DB;
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
# Date: 23.02.2022 (3:02)
|
||||
namespace Battles\Models\User;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Effects
|
||||
{
|
||||
public static function getStatMods(int $user_id)
|
||||
{
|
||||
return Db::getInstance()->ofetch("
|
||||
select
|
||||
sum(mod_strength) as effect_strength,
|
||||
sum(mod_dexterity) as effect_dexterity,
|
||||
sum(mod_intuition) as effect_intuition,
|
||||
sum(mod_endurance) as effect_endurance,
|
||||
sum(mod_intelligence) as effect_intelligence,
|
||||
sum(mod_wisdom) as effect_wisdom
|
||||
from
|
||||
users_effects
|
||||
where
|
||||
owner_id = ?
|
||||
", $user_id);
|
||||
}
|
||||
|
||||
public static function getAll(int $user_id): object
|
||||
{
|
||||
return Db::getInstance()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $user_id);
|
||||
}
|
||||
|
||||
public static function count(int $user_id, int $type)
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('select count(*) from users_effects where type = ? and owner_id = ?', [$type, $user_id]);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
# Date: 23.02.2022 (2:32)
|
||||
namespace Battles\Models\User;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Stats
|
||||
{
|
||||
/**
|
||||
* @param int|string $user
|
||||
*/
|
||||
public static function getAll($user)
|
||||
{
|
||||
$col = ctype_digit(strval($user)) ? 'id' : 'login';
|
||||
return Db::getInstance()->ofetch('select id, strength, dexterity, intuition, endurance, intelligence, wisdom, health, mana, free_stat_points, level from users where ' . $col . ' = ?', $user);
|
||||
}
|
||||
|
||||
public static function addOne(string $stat, int $user_id)
|
||||
{
|
||||
|
||||
Db::getInstance()->execute("
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
$stat = $stat + 1,
|
||||
free_stat_points = free_stat_points - 1
|
||||
WHERE
|
||||
id = ?
|
||||
", $user_id);
|
||||
}
|
||||
|
||||
public static function save(array $vars)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
update
|
||||
users
|
||||
set
|
||||
strength = ?,
|
||||
dexterity = ?,
|
||||
intuition = ?,
|
||||
endurance = ?,
|
||||
intelligence = ?,
|
||||
wisdom = ?,
|
||||
health = ?,
|
||||
mana = ?,
|
||||
free_stat_points = ?,
|
||||
level = ?
|
||||
where
|
||||
id = ?
|
||||
', $vars);
|
||||
}
|
||||
}
|
@ -17,50 +17,50 @@ class Moderation
|
||||
|
||||
public static function muteChat(int $target, int $time)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[2]);
|
||||
UserEffect::add($target, 2, UserEffect::$effectName[2], $time);
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[2]);
|
||||
User::addUserEffect($target, 2, UserEffects::$effectName[2], $time);
|
||||
}
|
||||
|
||||
public static function unmuteChat(int $target)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[2] . self::STATUS_OFF);
|
||||
UserEffect::remove($target, 2);
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[2] . self::STATUS_OFF);
|
||||
User::removeUserEffect($target, 2);
|
||||
}
|
||||
|
||||
public static function muteForum(int $target, int $time)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[3]);
|
||||
UserEffect::add($target, 3, UserEffect::$effectName[3], $time);
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[3]);
|
||||
User::addUserEffect($target, 3, UserEffects::$effectName[3], $time);
|
||||
}
|
||||
|
||||
public static function unmuteForum(int $target)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[3] . self::STATUS_OFF);
|
||||
UserEffect::remove($target, 3);
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[3] . self::STATUS_OFF);
|
||||
User::removeUserEffect($target, 3);
|
||||
}
|
||||
|
||||
public static function hideUserInfo(int $target, int $time)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[5]);
|
||||
UserEffect::add($target, 5, UserEffect::$effectName[5], $time);
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[5]);
|
||||
User::addUserEffect($target, 5, UserEffects::$effectName[5], $time);
|
||||
}
|
||||
|
||||
public static function unHideUserInfo(int $target)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[5] . self::STATUS_OFF);
|
||||
UserEffect::remove($target, 5);
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[5] . self::STATUS_OFF);
|
||||
User::removeUserEffect($target, 5);
|
||||
}
|
||||
|
||||
public static function blockUser(int $target)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, "Блокировка");
|
||||
Db::getInstance()->execute('UPDATE users SET block = 1 WHERE id = ?', $target);
|
||||
Db::getInstance()->execute('UPDATE battles.users SET block = 1 WHERE id = ?', $target);
|
||||
}
|
||||
|
||||
public static function unblockUser(int $target)
|
||||
public static function unBlockUser(int $target)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, "Блокировка" . self::STATUS_OFF);
|
||||
Db::getInstance()->execute('UPDATE users SET block = 0 WHERE block = 1 AND id = ?', $target);
|
||||
Db::getInstance()->execute('UPDATE battles.users SET block = 0 WHERE block = 1 AND id = ?', $target);
|
||||
}
|
||||
|
||||
public static function addToUserLog(int $target, string $message, int $senderId)
|
||||
@ -80,7 +80,7 @@ class Moderation
|
||||
|
||||
public static function addUserCheck(int $target)
|
||||
{
|
||||
self::addEffectStatusToUserLog($target, UserEffect::$effectName[20]);
|
||||
UserEffect::add($target, 20, UserEffect::$effectName[20], strtotime('3days'));
|
||||
self::addEffectStatusToUserLog($target, UserEffects::$effectName[20]);
|
||||
User::addUserEffect($target, 20, UserEffects::$effectName[20], strtotime('3days'));
|
||||
}
|
||||
}
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
/**
|
||||
* Разные способы отображения строки с логином персонажа.
|
||||
*/
|
||||
const INVIS = '<i>невидимка</i>';
|
||||
class Nick
|
||||
class Nick extends UserStats
|
||||
{
|
||||
private User $user;
|
||||
|
||||
private function __construct(int $userid)
|
||||
private function isInvisible()
|
||||
{
|
||||
$this->user = User::getInstance($userid);
|
||||
return Db::getInstance()->execute('SELECT count(*) FROM users_effects WHERE type = 1022 AND owner_id = ?', $this->id)->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,41 +21,25 @@ class Nick
|
||||
*/
|
||||
private function getAlignImage(): ?string
|
||||
{
|
||||
return $this->getImage($this->user->getAlign(), '/i/align_');
|
||||
return $this->align ? "<img src='i/align_$this->align.gif' alt='Склонность'>" : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Отображение иконки клана.
|
||||
* @return string
|
||||
*/
|
||||
private function getClanImage(): string
|
||||
private function getClanImage(): ?string
|
||||
{
|
||||
return $this->getImage($this->user->getClan(), '/i/clan/');
|
||||
}
|
||||
|
||||
private function getImage($name, $path): string
|
||||
{
|
||||
if (empty($name)) {
|
||||
return '';
|
||||
}
|
||||
$file = $path . $name . '.png';
|
||||
$alt = '';
|
||||
if (strpos($path, 'align')) {
|
||||
$alt = '{a:' . $name . '}';
|
||||
} elseif (strpos($path, 'clan')) {
|
||||
$alt = '{c:' . $name . '}';
|
||||
}
|
||||
return file_exists($file) ? "<img src='$file' alt='$alt'>" : $alt;
|
||||
return $this->clan ? "<img src='i/clan/$this->clan.png' alt='Клан'>" : null;
|
||||
}
|
||||
|
||||
private function getInfolinkImage(): string
|
||||
{
|
||||
return "<a href='inf.php?" . $this->user->getLogin() . "' target='_blank'><img src='i/inf.gif' alt='Ссылка на профиль'></a>";
|
||||
return "<a href='inf.php?$this->login' target='_blank'><img src='i/inf.gif' alt='Ссылка на профиль'></a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Вызов класса из самого себя. Читать про обратное связывание и пытаться что-то понять.
|
||||
*
|
||||
* @param $playerId
|
||||
*
|
||||
* @return Nick
|
||||
@ -74,10 +58,7 @@ class Nick
|
||||
*/
|
||||
public function full(int $showInvisibility = 0): string
|
||||
{
|
||||
if ($showInvisibility === 0 && UserEffect::isInvisible($this->user->getId())) {
|
||||
return INVIS;
|
||||
}
|
||||
return $this->getAlignImage() . ' ' . $this->getClanImage() . ' ' . $this->user->getLogin() . " [" . $this->user->getLevel() . "] " . $this->getInfolinkImage();
|
||||
return !$showInvisibility && $this->isInvisible() ? INVIS : $this->getAlignImage() . $this->getClanImage() . " <b>$this->login</b> [$this->level] " . $this->getInfolinkImage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +68,7 @@ class Nick
|
||||
*/
|
||||
public function short(): string
|
||||
{
|
||||
return $this->user->getLogin();
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,6 +77,6 @@ class Nick
|
||||
*/
|
||||
public function battle(): string
|
||||
{
|
||||
return $this->full() . "<img src='i/herz.gif' alt='HP'> [" . $this->user->stats()->getHealth() . "/" . $this->user->stats()->getMaxHealth() . "]";
|
||||
return $this->full() . "<img src='i/herz.gif' alt='HP'> [$this->health/$this->maxHealth]";
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
//namespace /;
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
@ -8,13 +8,7 @@ class Register
|
||||
{
|
||||
public static function addUser(string $login, string $password, string $email, string $birthday): int
|
||||
{
|
||||
$password = password_hash($password, PASSWORD_DEFAULT);
|
||||
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
if (
|
||||
!$email ||
|
||||
Db::getInstance()->execute('select count(*) from users where login = ? or email = ?', [$login, $email])->fetchColumn()
|
||||
) {
|
||||
if (Db::getInstance()->execute('select count(*) from users where login = ? or email = ?', [$login, $email])->fetchColumn()) {
|
||||
return 0;
|
||||
}
|
||||
Db::getInstance()->execute('insert into users (login,pass,email,borndate,ip,session_id,shadow) values (?,?,?,?,?,?,?)',
|
@ -3,10 +3,13 @@
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\Models\PresentsModel;
|
||||
use Exceptions\GameException;
|
||||
|
||||
class ShopItem extends Item
|
||||
{
|
||||
private const NO_ITEMS_IN_STOCK = "Товара нет в наличии!";
|
||||
private const NO_MONEY = "У вас нет денег!";
|
||||
private const NO_BARTER_ITEMS = 'У вас нет требуемых предметов!';
|
||||
private const BUTTON = [
|
||||
'setmarket' => 'Сдать в магазин',
|
||||
@ -132,23 +135,23 @@ SQL;
|
||||
return "<img src='/i/sh/$this->image' class='item-wrap-normal' alt=''>";
|
||||
}
|
||||
|
||||
public static function buyItem($id)
|
||||
public static function buyItem($id, User $buyer)
|
||||
{
|
||||
$check = Db::getInstance()->ofetch("select * from trade_offers where offer_id = ?", $id);
|
||||
$item = new Item(Db::getInstance()->fetch('select * from items where id = ?', $check->shop_item_id));
|
||||
$price = $item->calculateItemCost();
|
||||
|
||||
if (
|
||||
!self::checkAndRemoveBarteredItems($check->barter_items_list_json, User::getInstance()->getId()) ||
|
||||
!self::checkAndPayTheBills($price) ||
|
||||
!self::checkAndRemoveBarteredItems($check->barter_items_list_json, $buyer->getId()) ||
|
||||
!self::checkAndPayTheBills($price, $buyer) ||
|
||||
!self::checkAndChangeRemainingItems($check->shop_item_quantity, $check->shop_item_id)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Db::getInstance()->execute(self::BUY_QUERY, [User::getInstance()->getId(), $check->shop_item_id]);
|
||||
$deloText = User::getInstance()->getLogin() . " купил товар «" . $item->name . "» id:(" . $check->shop_item_id . ") в магазине за " . $price . ".";
|
||||
GameLogs::addUserLog(User::getInstance()->getId(), $deloText);
|
||||
Db::getInstance()->execute(self::BUY_QUERY, [$buyer->getId(), $check->shop_item_id]);
|
||||
$deloText = $buyer->getLogin() . " купил товар «" . $item->name . "» id:(" . $check->shop_item_id . ") в магазине за " . $price . ".";
|
||||
GameLogs::addUserLog($buyer->getId(), $deloText);
|
||||
self::$status = "Предмет " . $item->name . " куплен за " . $price . ".";
|
||||
}
|
||||
|
||||
@ -176,13 +179,21 @@ SQL;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function checkAndPayTheBills(int $price): bool
|
||||
private static function checkAndPayTheBills(int $price, User $user): bool
|
||||
{
|
||||
if (User::getInstance()->money()->spend($price)) {
|
||||
if (User::getInstance()->getMoney() > $price) {
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - $price);
|
||||
User::getInstance()->saveMoney();
|
||||
return true;
|
||||
}
|
||||
(new Bank())->withdrawMoney($price);
|
||||
return true;
|
||||
try {
|
||||
$bank = new Bank(User::getInstance()->getId());
|
||||
$bank->withdrawMoney($price);
|
||||
return true;
|
||||
} catch (GameException $e) {
|
||||
self::$status = 'Банковская ошибка! ' . self::NO_MONEY;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkAndChangeRemainingItems(int $current_quantity, $item_id): bool
|
||||
@ -198,7 +209,7 @@ SQL;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function sellItem($id, $bankTrade = 0)
|
||||
public static function sellItem($id, User $seller, $bankTrade = 0)
|
||||
{
|
||||
$item = Db::getInstance()->ofetch('select * from inventory where item_id = ?', $id);
|
||||
$sellingItemName = $item->name;
|
||||
@ -206,12 +217,14 @@ SQL;
|
||||
$sellingPrice = $item->price > 1 ? mt_rand(0, $item->price / 2) : mt_rand(0, 1);
|
||||
Db::getInstance()->execute('delete from inventory where item_id = ?', $id);
|
||||
if ($bankTrade) {
|
||||
User::getInstance()->money()->modifyBank($sellingPrice, 'sellShop');
|
||||
$bank = new Bank($seller->getId());
|
||||
$bank->setMoney($bank->getMoney() + $sellingPrice);
|
||||
Bank::setBankMoney($bank->getMoney(), $seller->getId(), 'sellShop');
|
||||
} else {
|
||||
User::getInstance()->money()->earn($sellingPrice);
|
||||
Db::getInstance()->execute('update users set money = money - ? where id = ?', [$sellingPrice, $_SESSION['uid']]);
|
||||
}
|
||||
$deloText = User::getInstance()->getLogin() . " продал товар «{$sellingItemName}» id:($id) в магазине за $sellingPrice кр.";
|
||||
GameLogs::addUserLog(User::getInstance()->getId(), $deloText);
|
||||
$deloText = "{$seller->getLogin()} продал товар «{$sellingItemName}» id:($id) в магазине за $sellingPrice кр.";
|
||||
GameLogs::addUserLog($seller->getId(), $deloText);
|
||||
if ($sellingPrice == 0) {
|
||||
self::$status = "После длительных и изнурительных торгов вы плюнули на всё и просто подарили ваш «{$sellingItemName}» торговцу.";
|
||||
} else {
|
||||
@ -261,9 +274,8 @@ FORM;
|
||||
|
||||
/** Выдача магазинных предметов по запросу.
|
||||
* Ввелась чтобы перебить takeshopitem() в functions с идентичным функционалом.
|
||||
*
|
||||
* @param int $item_id ИД предмета.
|
||||
* @param int $to ИД пперсонажа-получателя.
|
||||
* @param int $to ИД пперсонажа-получателя.
|
||||
*/
|
||||
public static function giveNewItem(int $item_id, int $to): array
|
||||
{
|
||||
|
@ -8,9 +8,9 @@ class Travel
|
||||
{
|
||||
/**
|
||||
* Соответствие ID комнаты игровому файлу.
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
public static array $roomFileName = [
|
||||
public static $roomFileName = [
|
||||
1 => 'main.php',
|
||||
20 => 'city.php',
|
||||
21 => 'city.php',
|
||||
@ -91,16 +91,18 @@ class Travel
|
||||
private static array $roomsCheck = [22, 23, 27, 29, 30, 31, 37, 38, 39, 40, 41, 45, 53, 61, 401, 402, 600, 601, 602, 621, 650, 1051, 1052];
|
||||
|
||||
/**
|
||||
* Перемещение по комнатам. Header:Location уже включён.
|
||||
* Перемещение по комнатам.
|
||||
*
|
||||
* @param int $roomId ID куда идём.
|
||||
* @param int $roomIdCurrent ID откуда идём.
|
||||
*/
|
||||
public static function toRoom(int $roomId, int $roomIdCurrent): void
|
||||
{
|
||||
UserStats::getInstance()->
|
||||
$itemsWeightOverflow = Db::getInstance()->fetchColumn('SELECT SUM(weight) - (select strength * 4 from users where id = ?) AS weight_overflow FROM inventory WHERE owner_id = ? AND on_sale = 0', [$_SESSION['uid'], $_SESSION['uid']]);
|
||||
$eff = Db::getInstance()->fetchColumn('SELECT type FROM users_effects WHERE owner_id = ? AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid']);
|
||||
$errors = [];
|
||||
if (UserEffect::isOverEncumbered($_SESSION['uid'])) {
|
||||
if ($itemsWeightOverflow > 0) {
|
||||
$errors[0] = 'У вас переполнен рюкзак, вы не можете передвигаться...';
|
||||
}
|
||||
if ($eff == 10) {
|
||||
@ -153,8 +155,8 @@ class Travel
|
||||
$room[21] = [20, 29, 30, 31, 34, 650, 2111];
|
||||
$room[29] = $room[30] = $room[31] = $room[34] = [21];
|
||||
|
||||
$room[26] = [20, 401, 660, 661, 777, 2601];
|
||||
$room[401] = $room[660] = $room[661] = $room[777] = [26];
|
||||
$room[26] = [20, 401, 660, 777, 2601];
|
||||
$room[401] = $room[660] = $room[777] = [26];
|
||||
|
||||
$room[2601] = [26, 37, 404, 1051, 2655];
|
||||
|
||||
@ -185,7 +187,7 @@ class Travel
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function roomRedirects(int $inRoom, int $inBattle, int $inTower = 0)
|
||||
public static function roomRedirects(int $inRoom, int $inBattle, int $inTower)
|
||||
{
|
||||
if ($inBattle && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], self::$fbattleCheckFiles)) {
|
||||
header('location: fbattle.php');
|
||||
|
@ -6,44 +6,50 @@ use Battles\Database\Db;
|
||||
|
||||
class User
|
||||
{
|
||||
use Users;
|
||||
private static ?self $_instance = null;
|
||||
private ?UserProfile $profile = null;
|
||||
private ?UserEffect $effect = null;
|
||||
private ?UserStats $stats = null;
|
||||
private ?UserInfo $userInfo = null;
|
||||
private ?UserMoney $userMoney = null;
|
||||
|
||||
protected int $id = 0;
|
||||
protected string $login = '';
|
||||
protected ?string $pass = null;
|
||||
protected ?string $email = null;
|
||||
protected ?string $realname = null;
|
||||
protected ?string $borndate = null;
|
||||
protected ?string $info = null;
|
||||
protected int $level = 0;
|
||||
protected ?int $align = null;
|
||||
protected ?string $clan = null;
|
||||
protected ?int $money = null;
|
||||
protected ?string $ip = null;
|
||||
|
||||
protected ?int $admin = null;
|
||||
protected int $room = 0;
|
||||
protected int $block = 0;
|
||||
protected string $shadow = '';
|
||||
|
||||
// Пока несуществующие, для совместимости.
|
||||
protected int $experience = 0;
|
||||
protected int $battle = 0;
|
||||
protected int $in_tower = 0; // Скорее башню похороним чем запустим...
|
||||
protected int $zayavka = 0;
|
||||
|
||||
public const INFO_CHAR_LIMIT = 1500;
|
||||
|
||||
protected function __construct($user = null)
|
||||
{
|
||||
if (is_null($user)) {
|
||||
$user = $_SESSION['uid'];
|
||||
}
|
||||
// Отсекаем 2.0000~
|
||||
$col = ctype_digit(strval($user)) ? 'id' : 'login';
|
||||
$query = "select * from users where $col = ?";
|
||||
$query = 'select * from users where login = ?';
|
||||
if (is_numeric($user)) {
|
||||
$query = 'select * from users where id = ?';
|
||||
$user = (int)$user;
|
||||
}
|
||||
$user_query = Db::getInstance()->fetch($query, $user);
|
||||
foreach ($this as $key => $value) {
|
||||
if (isset($user_query[$key])) {
|
||||
$this->$key = $user_query[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$this->profileData = (object)[
|
||||
$this->id,
|
||||
$this->pass,
|
||||
$this->email,
|
||||
$this->realname,
|
||||
$this->borndate,
|
||||
$this->info,
|
||||
$this->ip,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getInstance($user = null): self
|
||||
@ -54,53 +60,27 @@ class User
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
public function profile(): UserProfile
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $type
|
||||
* @param string $name
|
||||
* @param int $time
|
||||
* @param string|null $json_modifiers_list (str, dex, int, end, intel, wis).
|
||||
*/
|
||||
public static function addUserEffect(int $userId, int $type, string $name, int $time, string $json_modifiers_list = null)
|
||||
{
|
||||
if (is_null($this->profile)) {
|
||||
$this->profile = new UserProfile(
|
||||
$this->id,
|
||||
$this->pass,
|
||||
$this->email,
|
||||
$this->realname,
|
||||
$this->borndate,
|
||||
$this->info,
|
||||
$this->ip,
|
||||
);
|
||||
}
|
||||
return $this->profile;
|
||||
$mods = json_decode($json_modifiers_list);
|
||||
Db::getInstance()->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intelligence, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]);
|
||||
}
|
||||
|
||||
public function effect(): UserEffect
|
||||
public static function removeUserEffect(int $userId, int $type): bool
|
||||
{
|
||||
if (is_null($this->effect)) {
|
||||
$this->effect = new UserEffect();
|
||||
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 $this->effect;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function stats(): UserStats
|
||||
{
|
||||
if (is_null($this->stats)) {
|
||||
$this->stats = new UserStats($this->id);
|
||||
}
|
||||
return $this->stats;
|
||||
}
|
||||
public function userInfo(): UserInfo
|
||||
{
|
||||
if (is_null($this->userInfo)) {
|
||||
$this->userInfo = new UserInfo($this->id);
|
||||
}
|
||||
return $this->userInfo;
|
||||
}
|
||||
public function money(): UserMoney
|
||||
{
|
||||
if (is_null($this->userMoney)) {
|
||||
$this->userMoney = new UserMoney($this->id, $this->money);
|
||||
}
|
||||
return $this->userMoney;
|
||||
}
|
||||
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
@ -111,6 +91,44 @@ class User
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function getPass(): string
|
||||
{
|
||||
return $this->pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $pass
|
||||
*/
|
||||
public function setPass($pass): void
|
||||
{
|
||||
$this->pass = $pass;
|
||||
}
|
||||
|
||||
public function getRealname(): string
|
||||
{
|
||||
return $this->realname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $realname
|
||||
*/
|
||||
public function setRealname($realname): void
|
||||
{
|
||||
$this->realname = $realname;
|
||||
}
|
||||
|
||||
public function getInfo(): string
|
||||
{
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $info
|
||||
*/
|
||||
public function setInfo($info)
|
||||
{
|
||||
$this->info = $info;
|
||||
}
|
||||
|
||||
public function getLevel(): int
|
||||
{
|
||||
@ -136,6 +154,21 @@ class User
|
||||
$this->saveUser();
|
||||
}
|
||||
|
||||
public function getMoney(): int
|
||||
{
|
||||
return $this->money;
|
||||
}
|
||||
|
||||
public function setMoney(int $money)
|
||||
{
|
||||
$this->money = max($money, 0);
|
||||
}
|
||||
|
||||
public function saveMoney()
|
||||
{
|
||||
Db::getInstance()->execute('update users set money = ? where id = ?', [$this->money, $this->id]);
|
||||
}
|
||||
|
||||
public function getAdmin(): int
|
||||
{
|
||||
return $this->admin;
|
||||
@ -173,7 +206,7 @@ class User
|
||||
'm01', 'm02', 'm03', 'm04', 'm05', 'm06', 'm07', 'm08', 'm09', 'm10',
|
||||
'f01', 'f02', 'f03', 'f04', 'f05', 'f06', 'f07', 'f08', 'f09', 'f10',
|
||||
];
|
||||
if (in_array($shadow, $shadows) && $this->getShadow() === '0.png') {
|
||||
if (in_array($shadow, $shadows) && $this->getShadow() == '0.png') {
|
||||
$this->shadow = $shadow . '.png';
|
||||
}
|
||||
}
|
||||
@ -183,13 +216,9 @@ class User
|
||||
return $this->experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $experience
|
||||
*/
|
||||
public function addExperience(int $experience): void
|
||||
public function addExperience(int $amount): void
|
||||
{
|
||||
$this->experience += $experience;
|
||||
Db::getInstance()->execute('update users set experience = ? where id = ?', [$experience, $this->id]);
|
||||
$this->experience += max($amount, 0);
|
||||
}
|
||||
|
||||
public function getBattle(): int
|
||||
@ -197,6 +226,11 @@ class User
|
||||
return $this->battle;
|
||||
}
|
||||
|
||||
public function getInTower(): int
|
||||
{
|
||||
return $this->in_tower;
|
||||
}
|
||||
|
||||
public function getZayavka(): int
|
||||
{
|
||||
return $this->zayavka;
|
||||
@ -207,14 +241,53 @@ class User
|
||||
Db::getInstance()->execute('update online set real_time = ? where user_id = ?', [time(), $this->getId()]);
|
||||
}
|
||||
|
||||
public function setInjury(int $type): bool
|
||||
{
|
||||
if (!in_array($type, [11, 12, 13, 14])) {
|
||||
return false;
|
||||
}
|
||||
$names1 = ['разбитый нос', 'сотрясение первой степени', 'потрепанные уши', 'прикушенный язык', 'перелом переносицы', 'растяжение ноги', 'растяжение руки', 'подбитый глаз', 'синяк под глазом', 'кровоточащее рассечение', 'отбитая «пятая точка»', 'заклинившая челюсть', 'выбитый зуб «мудрости»', 'косоглазие'];
|
||||
$names2 = ['отбитые почки', 'вывих «вырезано цензурой»', 'сотрясение второй степени', 'оторванное ухо', 'вывих руки', 'оторванные уши', 'поврежденный позвоночник', 'поврежденный копчик', 'разрыв сухожилия', 'перелом ребра', 'перелом двух ребер', 'вывих ноги', 'сломанная челюсть'];
|
||||
$names3 = ['пробитый череп', 'разрыв селезенки', 'смещение позвонков', 'открытый перелом руки', 'открытый перелом «вырезано цензурой»', 'излом носоглотки', 'непонятные, но множественные травмы', 'сильное внутреннее кровотечение', 'раздробленная коленная чашечка', 'перелом шеи', 'смещение позвонков', 'открытый перелом ключицы', 'перелом позвоночника', 'вывих позвоночника', 'сотрясение третьей степени'];
|
||||
$param_names = ['str', 'dex', 'int', 'end', 'intel', 'wis',];
|
||||
shuffle($param_names);
|
||||
switch ($type) {
|
||||
case 11:
|
||||
shuffle($names1);
|
||||
$name = UserEffects::$effectName[$type] . ': ' . $names1(0);
|
||||
self::addUserEffect($this->id, $type, $name, strtotime('30min'), json_encode([$param_names(0) => -1]));
|
||||
break;
|
||||
case 12:
|
||||
shuffle($names2);
|
||||
$name = UserEffects::$effectName[$type] . ': ' . $names2(0);
|
||||
self::addUserEffect($this->id, $type, $name, strtotime('3hours'), json_encode([$param_names(0) => mt_rand(-3, -1), $param_names(1) => mt_rand(-3, -1)]));
|
||||
break;
|
||||
case 13:
|
||||
shuffle($names3);
|
||||
$name = UserEffects::$effectName[$type] . ': ' . $names3(0);
|
||||
self::addUserEffect($this->id, $type, $name, strtotime('12hours'), json_encode([$param_names(0) => mt_rand(-5, -1), $param_names(1) => mt_rand(-5, -1), $param_names(2) => mt_rand(-5, -1)]));
|
||||
break;
|
||||
default: //type 14
|
||||
self::addUserEffect($this->id, $type, UserEffects::$effectName[$type], strtotime('1day'), json_encode([$param_names(0) => -10]));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Сохраняет в базу актуальные логин, пароль, email, имя, дату рождения, текст инфы, склонность, клан, образ, права админа.
|
||||
*
|
||||
*/
|
||||
public function saveUser()
|
||||
{
|
||||
$query = 'update users set login = ?, align = ?, clan = ?, shadow = ?, admin = ? where id = ?';
|
||||
$query = 'update users set login = ?, pass = ?, email = ?, realname = ?, borndate = ?, info = ?, align = ?, clan = ?, shadow = ?, admin = ? where id = ?';
|
||||
$vals = [
|
||||
$this->login, //set
|
||||
$this->pass,
|
||||
$this->email,
|
||||
$this->realname,
|
||||
$this->borndate,
|
||||
$this->info,
|
||||
$this->align,
|
||||
$this->clan,
|
||||
$this->shadow,
|
||||
@ -223,5 +296,4 @@ class User
|
||||
];
|
||||
Db::getInstance()->execute($query, $vals);
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
<?php
|
||||
# Date: 16.02.2022 (23:01)
|
||||
# Date: 16.09.2020 (08:28)
|
||||
# Названия эффектов, налагаемых на персонажа.
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class UserEffect
|
||||
trait UserEffects
|
||||
{
|
||||
public static array $effectName = [
|
||||
public static $effectName = [
|
||||
2 => 'Заклинание молчания',
|
||||
3 => 'Заклятие форумного молчания',
|
||||
4 => 'Заклятие хаоса',
|
||||
5 => 'Заклятие обезличивания',
|
||||
8 => 'Сон',
|
||||
10 => 'паралич',
|
||||
11 => 'Легкая травма',
|
||||
12 => 'Средняя травма',
|
||||
@ -53,7 +50,7 @@ class UserEffect
|
||||
9994 => 'Антидот/Путы (Эликсир?)',
|
||||
];
|
||||
|
||||
public static array $effectImage = [
|
||||
public static $effectImage = [
|
||||
1 => 'travma.gif',
|
||||
2 => 'magic/sleep.gif',
|
||||
3 => 'magic/sleepf.gif',
|
||||
@ -88,75 +85,4 @@ class UserEffect
|
||||
227 => 'magic/attack_defence.gif',
|
||||
1022 => 'sh/hidden.gif',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $type
|
||||
* @param string $name
|
||||
* @param int $time
|
||||
* @param string|null $json_modifiers_list (str, dex, int, end, intel, wis).
|
||||
*/
|
||||
public static function add(int $userId, int $type, string $name, int $time, string $json_modifiers_list = null)
|
||||
{
|
||||
$mods = json_decode($json_modifiers_list);
|
||||
Db::getInstance()->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intelligence, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]);
|
||||
}
|
||||
|
||||
public static function updateTime(int $userId, int $type, int $time)
|
||||
{
|
||||
if (self::hasEffect($userId, $type)) {
|
||||
Db::getInstance()->execute('update users_effects set remaining_time = remaining_time + ? where owner_id = ? and type = ?', [$time, $userId, $type]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function remove(int $userId, int $type): bool
|
||||
{
|
||||
if (self::hasEffect($userId, $type)) {
|
||||
Db::getInstance()->execute('DELETE FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function massRemove(int $userId, array $type): bool
|
||||
{
|
||||
if (Db::getInstance()->fetchColumn('SELECT count(*) FROM users_effects WHERE owner_id = ? AND type in (?)', [$userId, $type])) {
|
||||
Db::getInstance()->execute('DELETE FROM users_effects WHERE owner_id = ? AND type in (?)', [$userId, $type]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function hasEffect(int $userId, int $type): bool
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('select count(*) from users_effects where owner_id = ? and type = ?', [$userId, $type]) > 0;
|
||||
}
|
||||
|
||||
public static function getRemainingEffectTime(int $userId, int $type): int
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('select remaining_time from users_effects where owner_id = ? and type = ?', [$userId, $type]);
|
||||
}
|
||||
|
||||
public static function isInvisible(int $userId): bool
|
||||
{
|
||||
return self::hasEffect($userId, 1022);
|
||||
}
|
||||
|
||||
public static function hasHiddenProfile(int $userId): string
|
||||
{
|
||||
$time = self::getRemainingEffectTime($userId, 5);
|
||||
if (empty($time)) {
|
||||
return '';
|
||||
}
|
||||
if ($time === -1) {
|
||||
return 'навсегда';
|
||||
}
|
||||
return 'до' . date('d.m.Y', strtotime($time));
|
||||
}
|
||||
|
||||
public static function isOverEncumbered(int $userid, int $addWeight = 0): bool
|
||||
{
|
||||
$query = 'select strength * 5 + ' . $addWeight . ' as max from inventory left join users u on owner_id = id where owner_id = ? having sum(weight) > max';
|
||||
return Db::getInstance()->fetchColumn($query, $userid) > 0;
|
||||
}
|
||||
}
|
@ -2,83 +2,71 @@
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Models\User\Effects;
|
||||
use Exceptions\GameException;
|
||||
use Battles\Database\Db;
|
||||
use Battles\Models\EffectsModel;
|
||||
|
||||
class UserInfo extends UserStats
|
||||
{
|
||||
private const PERCENT_20 = (20 / 100);
|
||||
private const PERCENT_80 = (80 / 100);
|
||||
use Rooms;
|
||||
|
||||
private int $bankMoney;
|
||||
|
||||
public function __construct($user)
|
||||
{
|
||||
parent::__construct($user);
|
||||
$bank = new Bank($this->id);
|
||||
$this->bankMoney = $bank->getMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
* Отображает куклу персонажа (образ и слоты).
|
||||
*
|
||||
* @param int $isBattle установить 1, если куклу нужно отобразить в поединке (показывает параметры при наведении
|
||||
* на образ).
|
||||
* @param int $isMain установить 1, если куклу надо показать на странице игрока (по клику на предмет снимает
|
||||
* @param int $isMain установить 1, если куклу надо показать на странице игрока (по клику на предмет снимает
|
||||
* его).
|
||||
*
|
||||
* @throws GameException
|
||||
*/
|
||||
private function UserInfoDoll(int $isBattle = 0, int $isMain = 0): string
|
||||
private function UserInfoDoll(int $isBattle = 0, int $isMain = 0)
|
||||
{
|
||||
$di = new DressedItems($this->id);
|
||||
$stats = new UserStats($this->id);
|
||||
$dressedItems = $di->getItemsInSlots();
|
||||
$str = null;
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$str .= sprintf('<div class="slot-%s">', $i);
|
||||
echo sprintf('<div class="slot-%s">', $i);
|
||||
if (!empty($dressedItems->$i)) {
|
||||
if (!$isBattle && $isMain) {
|
||||
$str .= sprintf('<a href="?edit=%s&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>',
|
||||
echo sprintf('<a href="?edit=%s&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>',
|
||||
mt_rand(), $i, $dressedItems->$i->image, $dressedItems->$i->name, $dressedItems->$i->name);
|
||||
} else {
|
||||
$str .= sprintf('<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>',
|
||||
echo sprintf('<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>',
|
||||
$dressedItems->$i->image, $dressedItems->$i->name, $dressedItems->$i->name);
|
||||
}
|
||||
} else {
|
||||
$str .= sprintf('<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">', $i, $i);
|
||||
echo sprintf('<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">', $i, $i);
|
||||
}
|
||||
$str .= sprintf('</div><!-- slot-%s -->', $i);
|
||||
echo sprintf('</div><!-- slot-%s -->', $i);
|
||||
}
|
||||
$str .= '<div class="slot-image">';
|
||||
echo '<div class="slot-image">';
|
||||
if ($isBattle) {
|
||||
$str .= sprintf('<img src="/i/shadow/%s" alt="%s" class="tip"><span class="tiptext"><b>%s</b>Уровень: %s<br>Сила: %s<br>Ловкость: %s<br>Интуиция: %s<br>Выносливость: %s<br>Интеллект: %s<br>Мудрость: %s</span>',
|
||||
$this->shadow, $stats->getLogin(), $stats->getLogin(), $stats->getLevel(), $stats->getStat('strength'), $stats->getStat('dexterity'), $stats->getStat('intuition'), $stats->getStat('endurance'), $stats->getStat('intelligence'), $stats->getStat('wisdom'));
|
||||
echo sprintf('<img src="/i/shadow/%s" alt="%s" class="tip"><span class="tiptext"><b>%s</b>Уровень: %s<br>Сила: %s<br>Ловкость: %s<br>Интуиция: %s<br>Выносливость: %s<br>Интеллект: %s<br>Мудрость: %s</span>',
|
||||
$this->shadow, $this->login, $this->login, $this->level, $this->strength, $this->dexterity, $this->intuition, $this->endurance, $this->intelligence, $this->wisdom);
|
||||
unset($sh);
|
||||
} else {
|
||||
$str .= '<img src="/i/shadow/' . $this->shadow . '" alt="' . $this->login . '">';
|
||||
echo '<img src="/i/shadow/' . $this->shadow . '" alt="' . $this->login . '">';
|
||||
}
|
||||
$str .= '</div><!-- slot-image -->';
|
||||
return $str;
|
||||
echo '</div><!-- slot-image -->';
|
||||
}
|
||||
|
||||
public function test(): array
|
||||
{
|
||||
return [
|
||||
'Сила' => $this->strength,
|
||||
'Ловкость' => $this->dexterity,
|
||||
'Интуиция' => $this->intuition,
|
||||
'Выносливость' => $this->endurance,
|
||||
'Интеллект' => $this->intelligence,
|
||||
'Мудрость' => $this->wisdom,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** Вызов из inf.php */
|
||||
private function ttz(): string
|
||||
private function ttz()
|
||||
{
|
||||
$stat = $this->getFullStats();
|
||||
$arr = [
|
||||
'Уровень' => $this->level,
|
||||
'Сила' => $this->strength,
|
||||
'Ловкость' => $this->dexterity,
|
||||
'Интуиция' => $this->intuition,
|
||||
'Выносливость' => $this->endurance,
|
||||
'Интеллект' => $this->intelligence,
|
||||
'Мудрость' => $this->wisdom,
|
||||
'Сила' => $this->printStat('strength'),
|
||||
'Ловкость' => $this->printStat('dexterity'),
|
||||
'Интуиция' => $this->printStat('intuition'),
|
||||
'Выносливость' => $this->printStat('endurance'),
|
||||
'Интеллект' => $this->printStat('intelligence'),
|
||||
'Мудрость' => $this->printStat('wisdom'),
|
||||
'Уворот' => $stat->evasion,
|
||||
'Точность' => $stat->accuracy,
|
||||
'Шанс крита' => $stat->criticals,
|
||||
@ -89,146 +77,185 @@ class UserInfo extends UserStats
|
||||
$str = null;
|
||||
$i = 0;
|
||||
foreach ($arr as $item => $value) {
|
||||
$str .= "<div class='column' style='text-align: right; margin-right: 10px;'>$item</div><div class='column' style='width: max-content;'>$value</div>";
|
||||
if (in_array($i, [6, 9])) {
|
||||
$str .= "<div class='column' style='text-align: right; margin-right: 10px;'>$item</div><div class='column'>$value</div>";
|
||||
if (in_array($i,[6,9])) {
|
||||
$str .= "<div style='margin-top: 10px;'></div><div></div>";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return sprintf(
|
||||
"<div class='info'>%s</div><!-- info --><div class='stats-container' style='display: grid; grid-template-columns: 150px 100px; font-size: 1.2em;'>%s</div>",
|
||||
Nick::id($this->id)->full(1),
|
||||
$str
|
||||
);
|
||||
$nameString = $this->align ? "<img src='/i/align_$this->align.png' alt='Склонность'>" : "";
|
||||
$nameString .= $this->block ? "<span class='private' style='text-decoration: line-through;'>$this->login</span>" : "<b>$this->login</b>";
|
||||
$nameString .= $this->clan ? "<img src='/i/clan/$this->clan.png' alt='Клан'>" : "";
|
||||
echo "<div class='info'><b>$nameString</b></div><!-- info -->";
|
||||
echo "<div class='stats-container' style='display: grid; grid-template-columns: 150px 100px; font-size: 1.2em;'>$str</div>";
|
||||
}
|
||||
|
||||
private function showProgressBar(int $value, int $max_value)
|
||||
private function printStat($statName): string
|
||||
{
|
||||
$values = [
|
||||
'%20%' => (int)round(self::PERCENT_20 * $max_value),
|
||||
'%80%' => (int)round(self::PERCENT_80 * $max_value),
|
||||
'%value' => $value,
|
||||
'%max' => $max_value
|
||||
];
|
||||
$string = '<meter max="%max" low="%20%" high="%80%" optimum="%max" value="%value">%value / %max</meter>';
|
||||
return str_replace(array_keys($values), array_values($values), $string);
|
||||
$stat = $this->getFullStats();
|
||||
return $this->getFreeStatPoints() ? $this->getStat($statName, 1) . '(' . $stat->$statName . ')' : $stat->$statName;
|
||||
}
|
||||
|
||||
/** Для вызова из main.php
|
||||
* @throws GameException
|
||||
*/
|
||||
private function UserInfoStats(): string
|
||||
//TODO вызывать из main.php
|
||||
private function UserInfoStats($isMainWindow = 0)
|
||||
{
|
||||
$captions = 'Уровень:<br>Здоровье:<br>Пыль:
|
||||
<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:
|
||||
<br>Опыт:<br>Очки характеристик:<br>Деньги:<br>Деньги в банке:
|
||||
';
|
||||
$stat = $this->getFullStats();
|
||||
$captions = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
|
||||
$variables =
|
||||
$this->level . '<br>' .
|
||||
$this->showProgressBar($this->health, $this->maxHealth) . '<br>' .
|
||||
$this->showProgressBar($this->mana, $this->maxMana) . '<br>' .
|
||||
parent::getStat('strength', 1) . '<br>' .
|
||||
parent::getStat('dexterity', 1) . '<br>' .
|
||||
parent::getStat('intuition', 1) . '<br>' .
|
||||
parent::getStat('endurance', 1) . '<br>' .
|
||||
parent::getStat('intelligence', 1) . '<br>' .
|
||||
parent::getStat('wisdom', 1) . '<br>' .
|
||||
$this->experience . '<br>' .
|
||||
$this->free_stat_points . '<br>' .
|
||||
User::getInstance()->money()->get() . '<br>' .
|
||||
User::getInstance()->money()->getBank();
|
||||
$stat->strength . '<br>' .
|
||||
$stat->dexterity . '<br>' .
|
||||
$stat->intuition . '<br>' .
|
||||
$stat->endurance . '<br>' .
|
||||
$stat->intelligence . '<br>' .
|
||||
$stat->wisdom . '<br>' .
|
||||
Rooms::$roomNames[$this->room];
|
||||
if ($isMainWindow) {
|
||||
$captions = 'Уровень:<br>Здоровье:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Опыт:<br>Очки характеристик:<br>Деньги:<br>Деньги в банке:';
|
||||
$variables =
|
||||
$this->level . '<br>' .
|
||||
$this->health . '<br>' .
|
||||
parent::getStat('strength', 1) . '<br>' .
|
||||
parent::getStat('dexterity', 1) . '<br>' .
|
||||
parent::getStat('intuition', 1) . '<br>' .
|
||||
parent::getStat('endurance', 1) . '<br>' .
|
||||
parent::getStat('intelligence', 1) . '<br>' .
|
||||
parent::getStat('wisdom', 1) . '<br>' .
|
||||
$this->experience . '<br>' .
|
||||
$this->free_stat_points . '<br>' .
|
||||
$this->money . '<br>' .
|
||||
$this->bankMoney;
|
||||
}
|
||||
$nameString = null;
|
||||
if ($this->align) {
|
||||
if (file_exists("/i/align_$this->align.png")) {
|
||||
$nameString .= "<img src='/i/align_$this->align.png' alt='Склонность'>";
|
||||
} else {
|
||||
$nameString .= "<svg width=16 height=16><circle cx=8 cy=8 r=6 stroke=darkorange stroke-width=1 fill=orange></circle></svg>";
|
||||
}
|
||||
} else {
|
||||
$nameString .= "";
|
||||
}
|
||||
$nameString .= $this->block ? "<span class='private' style='text-decoration: line-through;'>$this->login</span>" : "<b>$this->login</b>";
|
||||
if ($this->clan) {
|
||||
if (file_exists("/i/clan/$this->clan.png")) {
|
||||
$nameString .= "<img src='/i/clan/$this->clan.png' alt='Клан'>";
|
||||
} else {
|
||||
$nameString .= "<svg width=16 height=16><circle cx=8 cy=8 r=6 stroke=darkred stroke-width=1 fill=red></circle></svg>";
|
||||
}
|
||||
} else {
|
||||
$nameString .= "";
|
||||
}
|
||||
|
||||
$nameString = Nick::id($this->id)->full();
|
||||
|
||||
return <<<HTML
|
||||
echo <<<HTML
|
||||
<div class="user-info">
|
||||
<div class="info"><b>$nameString</b></div><!-- info -->
|
||||
<div class="stats-container">
|
||||
<div class="column" style="float: left;">$captions</div><!-- column -->
|
||||
<div class="column">$captions</div><!-- column -->
|
||||
<div class="column">$variables</div><!-- column -->
|
||||
</div><!-- stats-container -->
|
||||
</div><!-- user-info -->
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function userInfoStatsTest(): array
|
||||
/**
|
||||
* О персонаже для модераторов.
|
||||
* @return string|null
|
||||
*/
|
||||
private function showPrivateData(): ?string
|
||||
{
|
||||
$stat = $this->getFullStats();
|
||||
return [
|
||||
'Сила' => $this->strength,
|
||||
'Ловкость' => $this->dexterity,
|
||||
'Интуиция' => $this->intuition,
|
||||
'Выносливость' => $this->endurance,
|
||||
'Интеллект' => $this->intelligence,
|
||||
'Мудрость' => $this->wisdom,
|
||||
'<br>HP' => $this->health . ' / ' . $this->maxHealth,
|
||||
'MP' => $this->mana . ' / ' . $this->maxMana,
|
||||
'Уворот' => $stat->evasion,
|
||||
'Точность' => $stat->accuracy,
|
||||
'Шанс крита' => $stat->criticals,
|
||||
'Урон' => $stat->min_physical_damage . ' - ' . $stat->max_physical_damage,
|
||||
'<br>Уровень' => $this->level,
|
||||
'Опыт' => $this->experience,
|
||||
'Деньги' => $this->money()->get(),
|
||||
'<br>Локация' => Rooms::$roomNames[$this->room],
|
||||
|
||||
];
|
||||
$birthday = date('d.m.Y', strtotime($this->borndate));
|
||||
$userLogs = GameLogs::getUserLogs($this->id);
|
||||
$log = null;
|
||||
while ($userLogRow = $userLogs->fetchArray(SQLITE3_ASSOC)) {
|
||||
$log .= sprintf('<code>%s</code><br>', date('d.m.Y H:i ', strtotime($userLogRow['date'])) . $userLogRow['text']);
|
||||
}
|
||||
$adminData = User::getInstance()->getAdmin() ? $this->showAdminOnlyData() : null;
|
||||
return <<<INFO
|
||||
<div class="secret-info">
|
||||
E-Mail: $this->email<br>
|
||||
ДР Игрока: $birthday<br>
|
||||
IP Регистрации: $this->ip<br>
|
||||
$adminData<br>
|
||||
<div class="secret-info-user-log"><b>Личное дело</b><br>
|
||||
$log
|
||||
</div><!-- secret-info-user-log -->
|
||||
</div><!-- secret-info -->
|
||||
INFO;
|
||||
}
|
||||
|
||||
/** Для вызова из inf.php
|
||||
* @throws GameException
|
||||
/**
|
||||
* О персонаже для администраторов.
|
||||
* @return string|null
|
||||
*/
|
||||
private function showAdminOnlyData(): ?string
|
||||
{
|
||||
return <<<INFO
|
||||
⁑ ИД Игрока: $this->id<br>
|
||||
⁑ ИД Комнаты: $this->room<br>
|
||||
⁑ Деньги: $this->money<br>
|
||||
⁑ Деньги в банке: $this->bankMoney<br>
|
||||
⁑ Опыт: $this->experience<br>
|
||||
⁑ Нераспределённые очки: $this->free_stat_points<br>
|
||||
INFO;
|
||||
|
||||
}
|
||||
|
||||
private function Info()
|
||||
{
|
||||
echo '<div class="user-info-container">';
|
||||
$this->UserInfoDoll();
|
||||
$this->ttz();
|
||||
echo '<div class="slot-lower"> <!-- statuses! --></div>';
|
||||
echo '</div><!-- u-i-c -->';
|
||||
echo '<hr><!-- Нижняя часть -->';
|
||||
echo '<div class="user-info-container-lower">';
|
||||
echo '<h2>Об игроке</h2>';
|
||||
echo $this->realname ? "Имя: $this->realname" : "";
|
||||
echo $this->info ? "<br>" . nl2br($this->info) : "";
|
||||
echo '</div><!-- u-i-c-l -->';
|
||||
if (User::getInstance()->getAdmin() || User::getInstance()->getAlign() == 1) {
|
||||
echo $this->showPrivateData();
|
||||
}
|
||||
}
|
||||
|
||||
public function showUserInfo()
|
||||
{
|
||||
$str = null;
|
||||
$hidden = UserEffect::hasHiddenProfile($this->id);
|
||||
if ($this->block && !User::getInstance()->getAdmin()) {
|
||||
$str .= "<span class='error'>Персонаж $this->login заблокирован!</span>";
|
||||
} elseif (!empty($hidden) && !User::getInstance()->getAdmin()) {
|
||||
$str .= "<span class='error'>Персонаж $this->login обезличен $hidden.</span>";
|
||||
} else {
|
||||
$str .= '<div class="user-info-container">';
|
||||
$str .= $this->UserInfoDoll();
|
||||
$str .= $this->ttz();
|
||||
$str .= '<div class="slot-lower" style="font-size: xxx-large">' . $this->showProgressBar($this->health, $this->maxHealth) . '<br>' . $this->showProgressBar($this->mana, $this->maxMana) . '</div>';
|
||||
$str .= '</div><!-- u-i-c -->';
|
||||
$str .= '<hr><!-- Нижняя часть -->';
|
||||
$str .= '<div class="user-info-container-lower">';
|
||||
$str .= '<h2>Об игроке</h2>';
|
||||
$str .= $this->profile()->getRealname() ? "Имя: {$this->profile()->getRealname()}" : '';
|
||||
$str .= $this->profile()->getInfo() ? '<br>' . nl2br($this->profile()->getInfo()) : '';
|
||||
$str .= '</div><!-- u-i-c-l -->';
|
||||
if (User::getInstance()->getAdmin()) {
|
||||
$str .= UserPrivateInfo::get(User::getInstance());
|
||||
$effects = new EffectsModel($this->id);
|
||||
|
||||
if ($this->block && (!User::getInstance()->getAdmin() || !User::getInstance()->getAlign() == 1)) {
|
||||
echo "<span class='error'>Персонаж $this->login заблокирован!</span>";
|
||||
} elseif ($effects->getHideUserInfoStatus() && (!User::getInstance()->getAdmin() || !User::getInstance()->getAlign() == 1)) {
|
||||
if ($effects->getHideUserInfoStatus() == -1) {
|
||||
$date = 'навсегда';
|
||||
} else {
|
||||
$date = 'до' . date('d.m.Y', strtotime($effects->getHideUserInfoStatus()));
|
||||
}
|
||||
}
|
||||
echo $str;
|
||||
}
|
||||
|
||||
public function showUserDoll($isBattle = 0, $isMain = 0): string
|
||||
{
|
||||
try {
|
||||
return '<div class="user-info-container">' . $this->UserInfoDoll($isBattle, $isMain) . '</div><!-- u-i-c -->';
|
||||
} catch (GameException $e) {
|
||||
return $e;
|
||||
echo "<span class='error'>Персонаж $this->login обезличен $date.</span>";
|
||||
} else {
|
||||
$this->Info();
|
||||
}
|
||||
}
|
||||
|
||||
/** Отображение на main.php
|
||||
*/
|
||||
public function showUserInfoMain(): string
|
||||
public function showUserDoll($isBattle = 0, $isMain = 0)
|
||||
{
|
||||
try {
|
||||
return '<div class="user-doll-container">' . $this->UserInfoDoll() . '</div><!-- user-doll-container -->' . $this->userInfoStats();
|
||||
} catch (GameException $e) {
|
||||
return $e;
|
||||
}
|
||||
echo '<div class="user-info-container">';
|
||||
$this->UserInfoDoll($isBattle, $isMain);
|
||||
echo '</div><!-- user-info-container -->';
|
||||
}
|
||||
|
||||
public function showUserInfoMain()
|
||||
{
|
||||
echo '<div class="user-info-container">';
|
||||
$this->UserInfoDoll();
|
||||
$this->userInfoStats(1);
|
||||
echo '</div><!-- user-info-container -->';
|
||||
}
|
||||
|
||||
public function showUserEffects(): string
|
||||
{
|
||||
$effs = Effects::getAll($this->id);
|
||||
$img = UserEffect::$effectImage;
|
||||
$effs = Db::getInstance()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $this->id);
|
||||
$img = UserEffects::$effectImage;
|
||||
$r = '';
|
||||
foreach ($effs as $effect) {
|
||||
$timeleft = timeOut($effect->remaining_time - time());
|
||||
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
# Date: 19.02.2022 (18:54)
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class UserMoney
|
||||
{
|
||||
private int $uid;
|
||||
private int $wallet_money;
|
||||
private Bank $bank;
|
||||
|
||||
public function __construct(int $uid, int $money)
|
||||
{
|
||||
$this->uid = $uid;
|
||||
$this->wallet_money = $money;
|
||||
$this->initBank();
|
||||
}
|
||||
|
||||
private function initBank()
|
||||
{
|
||||
$this->bank = new Bank($this->uid);
|
||||
}
|
||||
|
||||
public function get(): int
|
||||
{
|
||||
return $this->wallet_money;
|
||||
}
|
||||
|
||||
public function set(int $money)
|
||||
{
|
||||
$this->wallet_money = max($money, 0);
|
||||
}
|
||||
|
||||
public function getBank(): int
|
||||
{
|
||||
return $this->bank->getMoney();
|
||||
}
|
||||
|
||||
public function modifyBank(int $money, string $logType = '')
|
||||
{
|
||||
$this->bank->modify($money, $logType);
|
||||
}
|
||||
|
||||
private function save()
|
||||
{
|
||||
Db::getInstance()->execute('update users set money = ? where id = ?', [$this->wallet_money, $this->uid]);
|
||||
}
|
||||
|
||||
/** Тратим деньги */
|
||||
public function spend(int $value): bool
|
||||
{
|
||||
if ($this->wallet_money > $value && $value > 0) {
|
||||
$this->wallet_money -= $value;
|
||||
$this->save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Получаем деньги */
|
||||
public function earn(int $value): bool
|
||||
{
|
||||
if ($value <= 0) {
|
||||
return false;
|
||||
}
|
||||
$this->wallet_money += $value;
|
||||
$this->save();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
# Date: 17.02.2022 (22:27)
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class UserPrivateInfo
|
||||
{
|
||||
/** Блок информации для модераторов. */
|
||||
public static function get(User $user)
|
||||
{
|
||||
$userLogs = GameLogs::getUserLogs($user->getId());
|
||||
$log = null;
|
||||
while ($userLogRow = $userLogs->fetchArray(SQLITE3_ASSOC)) {
|
||||
$log .= sprintf('<code>%s</code><br>', date('d.m.Y H:i ', strtotime($userLogRow['date'])) . $userLogRow['text']);
|
||||
}
|
||||
$data = [
|
||||
'%email' => $user->profile()->getEmail(),
|
||||
'%bday' => date('d.m.Y', strtotime($user->profile()->getBorndate())),
|
||||
'%regip' => $user->profile()->getIp(),
|
||||
'%uid' => $user->getId(),
|
||||
'%room' => $user->getRoom(),
|
||||
'%wallet' => $user->money()->get(),
|
||||
'%bank' => Db::getInstance()->fetchColumn('select money from bank where user_id = ?', $user->getId()),
|
||||
'%exp' => $user->getExperience(),
|
||||
'%fp' => Db::getInstance()->fetchColumn('select free_stat_points from users where id = ?', $user->getId()),
|
||||
'%log' => $log ?? 'Журнал пуст.',
|
||||
];
|
||||
$string = '<div class="secret-info">E-Mail: %email<br>ДР Игрока: %bday<br>IP Регистрации: %regip<br>
|
||||
⁑ ИД Игрока: %uid<br> ⁑ ИД Комнаты: %room<br> ⁑ Деньги: %wallet<br> ⁑ Деньги в банке: %bank<br>
|
||||
⁑ Опыт: %exp<br> ⁑ Нераспределённые очки: %fp<br><br>
|
||||
<div class="secret-info-user-log"><b>Личное дело</b><br>%log</div><!-- secret-info-user-log -->
|
||||
</div><!-- secret-info -->';
|
||||
return str_replace(array_keys($data), array_values($data), $string);
|
||||
}
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
<?php
|
||||
# Date: 16.02.2022 (21:22)
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class UserProfile
|
||||
{
|
||||
|
||||
private int $id;
|
||||
private string $pass;
|
||||
private string $email;
|
||||
private string $realname;
|
||||
private string $borndate;
|
||||
private string $info;
|
||||
private string $ip;
|
||||
private const INFO_CHAR_LIMIT = 1500;
|
||||
private string $status = '';
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $pass
|
||||
* @param string $email
|
||||
* @param string $realname
|
||||
* @param string $borndate
|
||||
* @param string $info
|
||||
* @param string $ip
|
||||
*/
|
||||
public function __construct(
|
||||
int $id,
|
||||
string $pass,
|
||||
string $email,
|
||||
string $realname,
|
||||
string $borndate,
|
||||
string $info,
|
||||
string $ip
|
||||
)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->pass = $pass;
|
||||
$this->email = $email;
|
||||
$this->realname = $realname;
|
||||
$this->borndate = $borndate;
|
||||
$this->info = $info;
|
||||
$this->ip = $ip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function changePassword($old_password, $new_password)
|
||||
{
|
||||
if (password_verify($old_password, $this->pass)) {
|
||||
$this->pass = password_hash($new_password, PASSWORD_DEFAULT);
|
||||
} else {
|
||||
$this->status .= 'Неверный пароль!';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*/
|
||||
public function setEmail(string $email): void
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRealname(): string
|
||||
{
|
||||
return $this->realname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $realname
|
||||
*/
|
||||
public function setRealname(string $realname): void
|
||||
{
|
||||
$this->realname = htmlspecialchars($realname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBorndate(): string
|
||||
{
|
||||
return $this->borndate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $borndate
|
||||
*/
|
||||
public function setBorndate(string $borndate): void
|
||||
{
|
||||
$this->borndate = $borndate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInfo(): string
|
||||
{
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $info
|
||||
*/
|
||||
public function setInfo(string $info): void
|
||||
{
|
||||
if (strlen($info) > self::INFO_CHAR_LIMIT) {
|
||||
$this->status .= 'Максимальная длинна поля Хобби: ' . self::INFO_CHAR_LIMIT . ' символов!';
|
||||
} else {
|
||||
$info = htmlspecialchars($info);
|
||||
$info = str_replace("\\n", '<br />', $info);
|
||||
$info = str_replace("\\r", '', $info);
|
||||
$info = str_replace('<br />', '<br />', $info);
|
||||
$this->info = $info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIp(): string
|
||||
{
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
/** Сохраняет в базу актуальные имя, пароль, email, дату рождения, текст инфы.
|
||||
*
|
||||
*/
|
||||
public function save(): string
|
||||
{
|
||||
if ($this->status) {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
$query = 'update users set pass = ?, email = ?, realname = ?, borndate = ?, info = ? where id = ?';
|
||||
$vals = [
|
||||
//set
|
||||
$this->pass,
|
||||
$this->email,
|
||||
$this->realname,
|
||||
$this->borndate,
|
||||
$this->info,
|
||||
// where
|
||||
$this->id
|
||||
];
|
||||
Db::getInstance()->execute($query, $vals);
|
||||
return 'Успешно!';
|
||||
}
|
||||
|
||||
}
|
@ -3,35 +3,33 @@
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Models\Inventory;
|
||||
use Battles\Models\User\Effects;
|
||||
use Battles\Models\User\Stats;
|
||||
use Battles\Database\Db;
|
||||
use Exceptions\GameException;
|
||||
|
||||
class UserStats extends User
|
||||
{
|
||||
protected int $id;
|
||||
protected int $strength;
|
||||
protected int $dexterity;
|
||||
protected int $intuition;
|
||||
protected int $endurance;
|
||||
protected int $intelligence;
|
||||
protected int $wisdom;
|
||||
protected int $health;
|
||||
protected int $mana;
|
||||
protected int $free_stat_points = 0;
|
||||
protected int $level;
|
||||
protected $strength;
|
||||
protected $dexterity;
|
||||
protected $intuition;
|
||||
protected $endurance;
|
||||
protected $intelligence;
|
||||
protected $wisdom;
|
||||
protected $health;
|
||||
protected $mana;
|
||||
protected $free_stat_points;
|
||||
private const STAT_MAXIMUM_AMOUNT = 40;
|
||||
private const ERROR_STAT_IS_MAXIMUM = 'Ошибка: Параметр достиг своего лимита!';
|
||||
private const ERROR_STAT_UNKNOWN = 'Ошибка: Неизвестный параметр!';
|
||||
private const STAT_NAMES_ARRAY = ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'];
|
||||
|
||||
//// Неизменяемые для игрока(!) переменные.
|
||||
// Удар кулаком всегда 1-2.
|
||||
protected int $minDamage = 1;
|
||||
protected int $maxDamage = 2;
|
||||
// Природная броня всегда 0.
|
||||
|
||||
// Зачем их три, если во всех формулах она одна?
|
||||
protected int $headArmor = 0;
|
||||
protected int $chestArmor = 0;
|
||||
protected int $legArmor = 0;
|
||||
// Динамически рассчитываемые
|
||||
protected int $maxHealth;
|
||||
protected int $maxMana;
|
||||
@ -43,19 +41,6 @@ class UserStats extends User
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
|
||||
$data = Stats::getAll($user);
|
||||
$this->id = $data->id;
|
||||
$this->strength = $data->strength;
|
||||
$this->dexterity = $data->dexterity;
|
||||
$this->intuition = $data->intuition;
|
||||
$this->endurance = $data->endurance;
|
||||
$this->intelligence = $data->intelligence;
|
||||
$this->wisdom = $data->wisdom;
|
||||
$this->health = $data->health;
|
||||
$this->mana = $data->mana;
|
||||
$this->free_stat_points = $data->free_stat_points;
|
||||
$this->level = $data->level;
|
||||
parent::__construct($user);
|
||||
$this->maxHealth = round(($this->endurance * 3) + ($this->endurance / 2) * ($this->level - 1) + ($this->endurance / 5) * (($this->level - 1) * ($this->level - 2) / 2));
|
||||
$this->maxMana = round(($this->wisdom * 3) + ($this->wisdom / 2) * ($this->level - 1) + ($this->wisdom / 5) * (($this->level - 1) * ($this->level - 2) / 2));
|
||||
@ -64,25 +49,23 @@ class UserStats extends User
|
||||
/**
|
||||
* Отдаёт информацию о базовом(!) стате.
|
||||
*
|
||||
* @param string $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition',
|
||||
* 'endurance', 'intelligence', 'wisdom'.
|
||||
* @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку
|
||||
* на повышение стата на 1, при условии наличия свободных очков статов.
|
||||
* @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition',
|
||||
* 'endurance', 'intelligence', 'wisdom'.
|
||||
* @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку
|
||||
* на повышение стата на 1, при условии наличия свободных очков статов.
|
||||
*
|
||||
* @return string
|
||||
* @throws GameException
|
||||
*/
|
||||
public function getStat(string $stat_name, int $isMainWindow = 0): string
|
||||
public function getStat($stat_name, int $isMainWindow = 0): string
|
||||
{
|
||||
if (!in_array($stat_name, self::STAT_NAMES_ARRAY)) {
|
||||
throw new GameException(self::ERROR_STAT_UNKNOWN);
|
||||
if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) {
|
||||
return self::ERROR_STAT_UNKNOWN;
|
||||
}
|
||||
$stat = strval($this->$stat_name);
|
||||
if ($this->free_stat_points && $isMainWindow && $this->$stat_name < self::STAT_MAXIMUM_AMOUNT) {
|
||||
$rand = strval(mt_rand());
|
||||
$stat .= " <a href='/main.php?edit=$rand&ups=$stat_name'>[+]</a>";
|
||||
$this->$stat_name .= " <a href='/main.php?edit=" . mt_rand() . "&ups=$stat_name'>[+]</a>";
|
||||
}
|
||||
return $stat;
|
||||
return $this->$stat_name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,19 +79,20 @@ class UserStats extends User
|
||||
*/
|
||||
public function addOnePointToStat(string $stat_name)
|
||||
{
|
||||
if (!in_array($stat_name, self::STAT_NAMES_ARRAY)) {
|
||||
if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) {
|
||||
throw new GameException(self::ERROR_STAT_UNKNOWN);
|
||||
}
|
||||
if ($this->free_stat_points <= 0 || $this->$stat_name >= self::STAT_MAXIMUM_AMOUNT) {
|
||||
throw new GameException(self::ERROR_STAT_IS_MAXIMUM);
|
||||
} else {
|
||||
Stats::addOne($stat_name, $this->id);
|
||||
$query = "UPDATE users SET {$stat_name} = {$stat_name} + 1, free_stat_points = free_stat_points - 1 WHERE id = ?";
|
||||
Db::getInstance()->execute($query, $this->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaxWeight(): int
|
||||
{
|
||||
return max($this->strength * 5, 50);
|
||||
return $this->strength * 4;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,21 +135,71 @@ class UserStats extends User
|
||||
return $this->maxMana;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHeadArmor(): int
|
||||
{
|
||||
return $this->headArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChestArmor(): int
|
||||
{
|
||||
return $this->chestArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLegArmor(): int
|
||||
{
|
||||
return $this->legArmor;
|
||||
}
|
||||
|
||||
public function getFullStats(): object
|
||||
{
|
||||
$stats = Stats::getAll($this->id);
|
||||
$itemBonuses = Inventory::getBonuses($this->id);
|
||||
$effectBonuses = Effects::getStatMods($this->id);
|
||||
$stats = Db::getInstance()->ofetch("
|
||||
select
|
||||
strength,
|
||||
dexterity,
|
||||
intuition,
|
||||
endurance,
|
||||
intelligence,
|
||||
wisdom
|
||||
from users where id = $this->id");
|
||||
$itemBonuses = Db::getInstance()->ofetch("
|
||||
select
|
||||
sum(add_strength) as item_strength,
|
||||
sum(add_dexterity) as item_dexterity,
|
||||
sum(add_intuition) as item_intuition,
|
||||
sum(add_endurance) as item_endurance,
|
||||
sum(add_intelligence) as item_intelligence,
|
||||
sum(add_wisdom) as item_wisdom,
|
||||
sum(add_accuracy) as item_accuracy,
|
||||
sum(add_evasion) as item_evasion,
|
||||
sum(add_criticals) as item_criticals,
|
||||
sum(add_min_physical_damage) as item_min_physical_damage,
|
||||
sum(add_max_physical_damage) as item_max_physical_damage
|
||||
from inventory where dressed_slot != 0 and owner_id = $this->id");
|
||||
$effectBonuses = Db::getInstance()->ofetch("
|
||||
select
|
||||
sum(mod_strength) as effect_strength,
|
||||
sum(mod_dexterity) as effect_dexterity,
|
||||
sum(mod_intuition) as effect_intuition,
|
||||
sum(mod_endurance) as effect_endurance,
|
||||
sum(mod_intelligence) as effect_intelligence,
|
||||
sum(mod_wisdom) as effect_wisdom
|
||||
from users_effects where owner_id = $this->id");
|
||||
$obj = (object)[];
|
||||
foreach (self::STAT_NAMES_ARRAY as $stat) {
|
||||
$obj->$stat = max(0, $stats->$stat + $itemBonuses->{'item_' . $stat} + $effectBonuses->{'effect_' . $stat});
|
||||
}
|
||||
//$obj->strength = max(0, $stats->strength + $itemBonuses->item_strength + $effectBonuses->effect_strength);
|
||||
//$obj->dexterity = max(0, $stats->dexterity + $itemBonuses->item_dexterity + $effectBonuses->effect_dexterity);
|
||||
//$obj->intuition = max(0, $stats->intuition + $itemBonuses->item_intuition + $effectBonuses->effect_intuition);
|
||||
//$obj->endurance = max(0, $stats->endurance + $itemBonuses->item_endurance + $effectBonuses->effect_endurance);
|
||||
//$obj->intelligence = max(0, $stats->intelligence + $itemBonuses->item_intelligence + $effectBonuses->effect_intelligence);
|
||||
//$obj->wisdom = max(0, $stats->wisdom + $itemBonuses->item_wisdom + $effectBonuses->effect_wisdom);
|
||||
$obj->strength = max(0,$stats->strength + $itemBonuses->item_strength + $effectBonuses->effect_strength);
|
||||
$obj->dexterity = max(0,$stats->dexterity + $itemBonuses->item_dexterity + $effectBonuses->effect_dexterity);
|
||||
$obj->intuition = max(0,$stats->intuition + $itemBonuses->item_intuition + $effectBonuses->effect_intuition);
|
||||
$obj->endurance = max(0,$stats->endurance + $itemBonuses->item_endurance + $effectBonuses->effect_endurance);
|
||||
$obj->intelligence = max(0,$stats->intelligence + $itemBonuses->item_intelligence + $effectBonuses->effect_intelligence);
|
||||
$obj->wisdom = max(0,$stats->wisdom + $itemBonuses->item_wisdom + $effectBonuses->effect_wisdom);
|
||||
$obj->accuracy = max(0, $itemBonuses->item_accuracy);
|
||||
$obj->evasion = max(0, $itemBonuses->item_evasion);
|
||||
$obj->criticals = max(0, $itemBonuses->item_criticals);
|
||||
@ -178,17 +212,20 @@ class UserStats extends User
|
||||
{
|
||||
$this->level += 1;
|
||||
$this->free_stat_points += 2;
|
||||
$this->save();
|
||||
Chat::addSYSMessage('Внимание, вы получили ' . $this->level . 'уровень. Доступны очки распределения параметров.');
|
||||
$this->saveStats();
|
||||
Chat::sendSys('Внимание, вы получили ' . $this->level . 'уровень. Доступны очки распределения параметров.');
|
||||
return 'Персонаж перешёл на ' . $this->level . 'уровень.';
|
||||
}
|
||||
|
||||
/** Сохраняет в базу актуальные статы, здоровье, ману, свободные очки статов и уровень.
|
||||
*
|
||||
*/
|
||||
private function save()
|
||||
private function saveStats()
|
||||
{
|
||||
Stats::save([
|
||||
$query = 'update users set strength = ?, dexterity = ?, intuition = ?, endurance = ?,
|
||||
intelligence = ?, wisdom = ?, health = ?, mana = ?, free_stat_points = ?,
|
||||
level = ? where id = ?';
|
||||
$vals = [
|
||||
$this->strength, //set
|
||||
$this->dexterity,
|
||||
$this->intuition,
|
||||
@ -200,6 +237,7 @@ class UserStats extends User
|
||||
$this->free_stat_points,
|
||||
$this->level,
|
||||
$this->id //where
|
||||
]);
|
||||
];
|
||||
Db::getInstance()->execute($query, $vals);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
# Date: 23.02.2022 (1:49)
|
||||
namespace Battles;
|
||||
|
||||
trait Users
|
||||
{
|
||||
protected int $id = 0;
|
||||
protected string $login = '';
|
||||
protected int $level = 0;
|
||||
protected ?int $align = null;
|
||||
protected ?string $clan = null;
|
||||
protected ?int $admin = null;
|
||||
protected int $room = 0;
|
||||
protected int $block = 0;
|
||||
protected string $shadow = '';
|
||||
//userprofile
|
||||
private string $pass = '';
|
||||
private string $email = '';
|
||||
private string $realname = '';
|
||||
private string $borndate = '';
|
||||
private string $info = '';
|
||||
private string $ip = '';
|
||||
|
||||
private ?int $money = null;
|
||||
|
||||
private bool $fuk;
|
||||
|
||||
|
||||
}
|
@ -1612,9 +1612,9 @@ class fbattle
|
||||
addchp('<font color=red>Внимание!</font> Победа! Бой окончен. Всего вами нанесено урона : ' . $this->damage[$v] . ' HP. Получено опыта : ' . $this->exp[$v] . ' (' . $dop_exp . '%)' . $ads . ' ', '{[]}' . Nick::id($v)->short() . '{[]}');
|
||||
|
||||
mysql_query('UPDATE `users` SET `win` = (`win` +1), `fullhptime` = ' . time() . ' WHERE `id` = "' . $v . '"');
|
||||
\Battles\User::getInstance($v)->addExperience($this->exp[$v]);
|
||||
GiveExp($v, $this->exp[$v]);
|
||||
if ($user['caveleader'] > 0 || $user['laba'] > 0) {
|
||||
\Battles\User::getInstance($v)->addExperience($rep);
|
||||
GiveRep($v, $rep);
|
||||
}
|
||||
if ($user['klan']) {
|
||||
mysql_query('UPDATE `clans` SET `clanexp` = (`clanexp`+' . (int)$this->exp[$user['id']] . ') WHERE `id` = "' . $v[$user['klan']] . '" LIMIT 1');
|
||||
@ -1628,7 +1628,7 @@ class fbattle
|
||||
$flag = 2;
|
||||
foreach ($this->t2 as $k => $v) {
|
||||
mysql_query('UPDATE `battle` SET `win` = 2 WHERE `id` = "' . $this->user['battle'] . '" LIMIT 1');
|
||||
$this->t2[$k] = \Battles\Nick::id($v)->short();
|
||||
$this->t2[$k] = Nick::id($v)->short();
|
||||
|
||||
if ($this->battle_data['aren_of'] == 1 && $this->t2[$k] && $v < _BOTSEPARATOR_) {
|
||||
mysql_query('INSERT INTO `logs_arena` (`battle`, `user`, `uid`, `damage`, `team`) VALUES ("' . $this->user['battle'] . '", "' . $this->t1[$k] . '", "' . $v . '", "' . $this->damage[$v] . '", "2")');
|
||||
@ -1668,9 +1668,9 @@ class fbattle
|
||||
echo "<script>console.log('Win fiz 1');</script>";
|
||||
}
|
||||
mysql_query('UPDATE `users` SET `win` = (`win` +1), `fullhptime` = ' . time() . ' WHERE `id` = "' . $v . '"');
|
||||
\Battles\User::getInstance($v)->addExperience($this->exp[$v]);
|
||||
GiveExp($v, $this->exp[$v]);
|
||||
if ($user['caveleader'] > 0 || $user['laba'] > 0) {
|
||||
\Battles\User::getInstance($v)->addExperience($rep);
|
||||
GiveRep($v, $rep);
|
||||
}
|
||||
if ($user['klan']) {
|
||||
mysql_query('UPDATE `clans` SET `clanexp` = (`clanexp`+' . (int)$this->exp[$user['id']] . ') WHERE `id` = "' . $v[$user['klan']] . '" LIMIT 1');
|
@ -419,7 +419,7 @@ TASK;
|
||||
return $ins;
|
||||
}
|
||||
|
||||
public function timeOut($ttm): string
|
||||
public function timeOut($ttm)
|
||||
{
|
||||
$out = '';
|
||||
$time_still = $ttm;
|
||||
@ -590,3 +590,5 @@ TASK;
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
$q = new Quests;
|
44
classes/showpers.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2018.
|
||||
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
class showpers
|
||||
{
|
||||
private $pers_data;
|
||||
private $weared_items;
|
||||
|
||||
private function __construct($id)
|
||||
{
|
||||
if (!$this->pers_data) {
|
||||
$query = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $id)->fetch_assoc();
|
||||
$this->pers_data = $query;
|
||||
}
|
||||
if (!$this->weared_items) {
|
||||
$query = db::c()->query('SELECT `name`, `img`, `type` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 1', $id);
|
||||
$this->weared_items = $query;
|
||||
}
|
||||
}
|
||||
|
||||
private function dgfs()
|
||||
{
|
||||
$w_items['sergi'] = $this->pers_data['sergi'];
|
||||
$w_items['kulon'] = $this->pers_data['kulon'];
|
||||
$w_items['weap'] = $this->pers_data['weap'];
|
||||
$w_items['bron'] = $this->pers_data['bron'];
|
||||
$w_items['r1'] = $this->pers_data['r1'];
|
||||
$w_items['r2'] = $this->pers_data['r2'];
|
||||
$w_items['r3'] = $this->pers_data['r3'];
|
||||
$w_items['helm'] = $this->pers_data['helm'];
|
||||
$w_items['perchi'] = $this->pers_data['perchi'];
|
||||
$w_items['shit'] = $this->pers_data['shit'];
|
||||
$w_items['boots'] = $this->pers_data['boots'];
|
||||
$w_items['rubax'] = $this->pers_data['rubax'];
|
||||
$w_items['plaw'] = $this->pers_data['plaw'];
|
||||
$w_items['rune1'] = $this->pers_data['rune1'];
|
||||
$w_items['rune2'] = $this->pers_data['rune2'];
|
||||
$w_items['rune3'] = $this->pers_data['rune3'];
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
*/
|
||||
|
||||
spl_autoload_register(function ($className) {
|
||||
$fileName = __DIR__ . '/classes/' . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php');
|
||||
$fileName = __DIR__ . '/classes/' . str_replace('\\', '/', $className . '.php');
|
||||
if (file_exists($fileName)) {
|
||||
require_once $fileName;
|
||||
}
|
||||
|
@ -372,9 +372,9 @@ class fbattle
|
||||
addchp('<font color=red>Внимание!</font> Победа! Бой окончен. Всего вами нанесено урона : ' . $this->damage[$v] . ' HP. Получено опыта : ' . $this->exp[$v] . ' (' . $dop_exp . '%)' . $ads . ' ', '{[]}' . Nick::id($v)->short() . '{[]}');
|
||||
|
||||
mysql_query('UPDATE `users` SET `win` = (`win` +1), `fullhptime` = ' . time() . ' WHERE `id` = "' . $v . '"');
|
||||
\Battles\User::getInstance($v)->addExperience($this->exp[$v]);
|
||||
GiveExp($v, $this->exp[$v]);
|
||||
if ($user['caveleader'] > 0 || $user['laba'] > 0) {
|
||||
\Battles\User::getInstance($v)->addExperience($rep);
|
||||
GiveRep($v, $rep);
|
||||
}
|
||||
if ($user['klan']) {
|
||||
mysql_query('UPDATE `clans` SET `clanexp` = (`clanexp`+' . (int)$this->exp[$user['id']] . ') WHERE `id` = "' . $v[$user['klan']] . '" LIMIT 1');
|
||||
@ -449,7 +449,7 @@ class fbattle
|
||||
addchp('<font color=red>Внимание!</font> Победа! Бой окончен. Всего вами нанесено урона : ' . (int)$this->damage[$v] . ' HP. Получено опыта ' . $this->exp[$v] . ' (' . $dop_exp . '%). ', '{[]}' . Nick::id($v)->short() . '{[]}');
|
||||
|
||||
mysql_query('UPDATE `users` SET `win` = (`win`+1), `fullhptime` = ' . time() . ' WHERE `id` = "' . $v . '"');
|
||||
\Battles\User::getInstance($v)->addExperience($this->exp[$v]);
|
||||
GiveExp($v, $this->exp[$v]);
|
||||
}
|
||||
|
||||
$winers .= implode("</B>, <B>", $this->t2);
|
||||
|
69
css/main.css
@ -319,7 +319,7 @@ img.tip:hover + span.tiptext {
|
||||
/* Отображение информации о персонаже в inf.php (класс User.php) */
|
||||
div.user-info-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 75px) auto;
|
||||
grid-template-columns: repeat(4, 75px) auto 100px;
|
||||
grid-template-rows: repeat(5, 75px) auto;
|
||||
grid-gap: 10px;
|
||||
}
|
||||
@ -409,68 +409,11 @@ div.user-info-container > div.user-info > div.stats-container > div.column {
|
||||
div.user-info-container > div.user-info > div.stats-container > div.column + div.column {
|
||||
text-align: left;
|
||||
}
|
||||
/*--DOLL-----------------------*/
|
||||
div.user-doll-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 75px);
|
||||
grid-template-rows: repeat(5, 75px);
|
||||
grid-gap: 10px;
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-1,
|
||||
div.user-doll-container > div.slot-2,
|
||||
div.user-doll-container > div.slot-3,
|
||||
div.user-doll-container > div.slot-4 {
|
||||
grid-column: 1;
|
||||
div.user-info-container > div.user-signs {
|
||||
grid-column: 6;
|
||||
grid-row: 1 / 6;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-5,
|
||||
div.user-doll-container > div.slot-6,
|
||||
div.user-doll-container > div.slot-7,
|
||||
div.user-doll-container > div.slot-8 {
|
||||
grid-column: 4;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-1,
|
||||
div.user-doll-container > div.slot-5 {
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-2,
|
||||
div.user-doll-container > div.slot-6 {
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-3,
|
||||
div.user-doll-container > div.slot-7 {
|
||||
grid-row: 3;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-4,
|
||||
div.user-doll-container > div.slot-8 {
|
||||
grid-row: 4;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-9,
|
||||
div.user-doll-container > div.slot-10,
|
||||
div.user-doll-container > div.slot-11,
|
||||
div.user-doll-container > div.slot-12 {
|
||||
grid-row: 5;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-image {
|
||||
grid-column: 2 / 4;
|
||||
grid-row: 1 / 5;
|
||||
}
|
||||
|
||||
div.user-doll-container > div.slot-image > img {
|
||||
width: 160px;
|
||||
height: 330px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/*-----------------------------*/
|
||||
div.debug {
|
||||
background:#fef;
|
||||
@ -479,14 +422,14 @@ div.debug {
|
||||
padding:5px;
|
||||
margin: 3px;
|
||||
}
|
||||
.secret-info {
|
||||
div.secret-info {
|
||||
background:#fee;
|
||||
border:1px dashed #faa;
|
||||
border-radius:5px;
|
||||
padding:5px;
|
||||
margin: 3px;
|
||||
}
|
||||
.secret-info > span {
|
||||
div.secret-info > span {
|
||||
color: #966;
|
||||
}
|
||||
/* for classes/City.php included in /city.php */
|
||||
|
10
fbattle.php
@ -137,7 +137,10 @@ Template::header('fbattle');
|
||||
<table width=250 cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td valign=top width=250 nowrap>
|
||||
<?= \Battles\User::getInstance()->userInfo()->showUserDoll(1) ?>
|
||||
<?php
|
||||
$myinfo = new User($_SESSION['uid']);
|
||||
$myinfo->showUserDoll(1);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -162,7 +165,7 @@ Template::header('fbattle');
|
||||
$dressed = db::c()->query('SELECT `id` FROM `inventory` WHERE `id` = ?i AND `dressed` = 1', $_GET['use'])->fetch_row();
|
||||
if ((int)$dressed[0] > 0) {
|
||||
$my_class = $fbattle->my_class;
|
||||
|
||||
usemagic($_GET['use'], "" . $_POST['target']);
|
||||
$bb = explode("<!--", ob_get_clean());
|
||||
$bb = str_replace('"', """, (strip_tags($bb[0])));
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . "?buf=" . $bb);
|
||||
@ -470,7 +473,8 @@ Template::header('fbattle');
|
||||
<?php
|
||||
|
||||
if ($fbattle->return == 1) {
|
||||
echo \Battles\User::getInstance($fbattle->enemy)->userInfo()->showUserDoll(1);
|
||||
$enemyInfo = new User($fbattle->enemy);
|
||||
$enemyInfo->showUserDoll(1);
|
||||
} else {
|
||||
if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) {
|
||||
$a = [6, 16];
|
||||
|
311
functions.php
@ -5,7 +5,10 @@
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
use Battles\Chat;
|
||||
use Battles\Database\Db;
|
||||
use Battles\DressedItems;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Travel;
|
||||
use Battles\User;
|
||||
use Battles\UserStats;
|
||||
@ -22,7 +25,59 @@ if (User::getInstance()->getBlock()) {
|
||||
}
|
||||
|
||||
//Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
||||
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle());
|
||||
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle(), User::getInstance()->getInTower());
|
||||
|
||||
///*
|
||||
// * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
||||
// */
|
||||
//$fbattleCheckFiles = [
|
||||
// 'c_haos_in.php',
|
||||
// 'c_haos.php',
|
||||
// 'c_park.php',
|
||||
// 'city.php',
|
||||
// 'clan_castle.php',
|
||||
// 'enter_cave.php',
|
||||
// 'library.php',
|
||||
// 'atk.php',
|
||||
// 'podzem_dialog.php',
|
||||
// 'post.php',
|
||||
// 'shop.php',
|
||||
// 'tournament.php',
|
||||
// 'vxod.php',
|
||||
// 'bank.php',
|
||||
// 'canalizaciya,php',
|
||||
// 'forest.php',
|
||||
// 'main.php',
|
||||
// 'repair.php',
|
||||
// 'towerstamp.php',
|
||||
// 'hell.php',
|
||||
// 'ul_clans.php',
|
||||
// 'labirint.php',
|
||||
// 'akadem.php',
|
||||
// 'towerin.php',
|
||||
// 'user_anketa.php',
|
||||
// 'zayavka.php',
|
||||
//];
|
||||
////Может просто отовсюду? О_о
|
||||
//if (User::$current->getBattle() && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], $fbattleCheckFiles)) {
|
||||
// header('location: fbattle.php');
|
||||
// exit;
|
||||
//}
|
||||
//$towerinCheckFiles = ['main.php', 'city.php', 'tower.php'];
|
||||
//if (User::$current->getInTower() && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], $towerinCheckFiles)) {
|
||||
// header('location: towerin.php');
|
||||
// exit;
|
||||
//}
|
||||
//$roomsCheck = [22, 23, 25, 27, 29, 30, 31, 37, 38, 39, 40, 41, 45, 53, 61, 401, 402, 600, 601, 602, 621, 650, 1051, 1052];
|
||||
//// Если я в одной из этих комнат,
|
||||
//// [И] Имя файла который инклюдит файл с проверкой не совпадает с именем файла локации в которой я нахожусь
|
||||
//// [И] Номер комнаты который я пытаюсь открыть есть в списке проверяемых
|
||||
//if (in_array(User::$current->getRoom(), $roomsCheck)
|
||||
// && pathinfo(debug_backtrace()[0]['file'])['basename'] != Travel::$roomFileName[User::$current->getRoom()]
|
||||
// && in_array(array_search(pathinfo(debug_backtrace()[0]['file'])['basename'], Travel::$roomFileName), $roomsCheck)) {
|
||||
// header('location: main.php');
|
||||
// exit;
|
||||
//}
|
||||
|
||||
if (
|
||||
!empty($_GET['goto']) &&
|
||||
@ -35,19 +90,15 @@ if (
|
||||
User::getInstance()->setRoom(intval($_GET['goto']));
|
||||
}
|
||||
|
||||
function createbot($bot, $login = null): array
|
||||
function createbot($bot, $login = null)
|
||||
{
|
||||
if (empty($login)) {
|
||||
$login = Db::getInstance()->fetchColumn('select login from users where id = ?', $bot);
|
||||
if (!User::getInstance($bot)->getId()) {
|
||||
return false;
|
||||
}
|
||||
if (empty($login)) {
|
||||
return [];
|
||||
}
|
||||
Db::getInstance()->execute('insert into bots (name, prototype) values (?,?)', [$login, $bot]);
|
||||
return [
|
||||
'id' => Db::getInstance()->lastInsertId(),
|
||||
'login' => $login,
|
||||
];
|
||||
$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 = [
|
||||
@ -71,14 +122,17 @@ function savecavedata($cavedata, $caveleader, $floor)
|
||||
fclose($f1);
|
||||
}
|
||||
|
||||
function GiveExp($id, $exp)
|
||||
{
|
||||
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
|
||||
@ -88,8 +142,7 @@ function showProgressBar($current, $maximum, string $line_color = 'limegreen', s
|
||||
<div style="width: 100%; height: 16px; background: $bg_color; overflow: hidden; border-radius: 3px;">
|
||||
<div style="height: 16px; background: $line_color; border-radius: 3px; width: $bar%;"></div>
|
||||
</div>
|
||||
<div style="width: 100%; height: 16px; font-size: 14px; text-align: center; margi
|
||||
n-top: -16px;">
|
||||
<div style="width: 100%; height: 16px; font-size: 14px; text-align: center; margin-top: -16px;">
|
||||
$current / $maximum
|
||||
</div>
|
||||
HTML;
|
||||
@ -101,56 +154,115 @@ HTML;
|
||||
*
|
||||
* @param $slot
|
||||
*
|
||||
* @return string
|
||||
* @throws \Krugozor\Database\Mysql\Exception
|
||||
*/
|
||||
function echoscroll($slot): string
|
||||
function echoscroll($slot)
|
||||
{
|
||||
$all_magic = 0;
|
||||
if (User::getInstance()->getBattle()) {
|
||||
$script = 'fbattle';
|
||||
$all_magic = Db::getInstance()->fetchColumn('select magic from battle where id = ?', User::getInstance()->getBattle());
|
||||
$all_magic = unserialize($all_magic);
|
||||
$bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', User::getInstance()->getBattle())->fetch_assoc();
|
||||
$all_magic = unserialize($bat['magic']);
|
||||
} else {
|
||||
$script = 'main';
|
||||
}
|
||||
$dress = Db::getInstance()->fetch('select magic, name, image, durability from inventory where item_id - ?', User::getInstance()->$slot);
|
||||
$need_charge = Db::getInstance()->fetchColumn('select needcharge from magic where id = ?', $dress['magic']);
|
||||
$str = null;
|
||||
if ((User::getInstance()->$slot > 0) && ($all_magic[User::getInstance()->getId()] < 1 || empty($need_charge))) {
|
||||
|
||||
$dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', User::getInstance()->$slot)->fetch_assoc();
|
||||
$need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
|
||||
|
||||
if ((User::getInstance()->$slot > 0) && ($all_magic[User::getInstance()->getId()] < 1 || empty($need_charge['needcharge']))) {
|
||||
$row['id'] = User::getInstance()->$slot;
|
||||
if ($dress['magic']) {
|
||||
$magic_targeted = Db::getInstance()->fetchColumn('select targeted from magic where id = ?', $dress['magic']);
|
||||
$str .= "<a onclick=\"";
|
||||
if ($magic_targeted === 1) {
|
||||
$str .= "okno('Введите название предмета', '" . $script . ".php?use={$row['id']}', 'target'); ";
|
||||
$magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
|
||||
echo "<a onclick=\"";
|
||||
if ($magic['targeted'] == 1) {
|
||||
echo "okno('Введите название предмета', '" . $script . ".php?use={$row['id']}', 'target'); ";
|
||||
} else
|
||||
if ($magic_targeted === 2) {
|
||||
$str .= "findlogin('Введите имя персонажа', '" . $script . ".php?use={$row['id']}', 'target'); ";
|
||||
if ($magic['targeted'] == 2) {
|
||||
echo "findlogin('Введите имя персонажа', '" . $script . ".php?use={$row['id']}', 'target'); ";
|
||||
} else {
|
||||
$str .= "if(confirm('Использовать сейчас?')) { window.location='" . $script . ".php?use=" . $row['id'] . "';}";
|
||||
echo "if(confirm('Использовать сейчас?')) { window.location='" . $script . ".php?use=" . $row['id'] . "';}";
|
||||
}
|
||||
$str .= "\"href='#'>";
|
||||
echo "\"href='#'>";
|
||||
}
|
||||
$str .= <<<ACTIVE_SCROLL
|
||||
echo <<<ACTIVE_SCROLL
|
||||
<img class='tooltip' src="i/sh/{$dress['img']}" width='40' title="<b>{$dress['name']}</b><br> Прочность {$dress['duration']} / {$dress['maxdur']} " height='25' alt="Свиток"></a>
|
||||
ACTIVE_SCROLL;
|
||||
} elseif ((User::getInstance()->$slot > 0) && ($all_magic[User::getInstance()->getId()] >= 1) && $need_charge['needcharge'] > 0) {
|
||||
$str .= <<<INACTIVE_SCROLL
|
||||
echo <<<INACTIVE_SCROLL
|
||||
<img src="i/sh/magicclock.gif" width="40" height="25" title='Произведите размен ударами и магия снова станет доступна' alt="Свиток">
|
||||
INACTIVE_SCROLL;
|
||||
} else {
|
||||
$str .= <<<EMPTY_SLOT
|
||||
echo <<<EMPTY_SLOT
|
||||
<img class="tooltip" src="i/w13.gif" width="40" height="25" title='<b>Пустой слот магия</b>' alt="Слот для свитка">
|
||||
EMPTY_SLOT;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
function timeOut($ttm): string
|
||||
// ссылка на магию
|
||||
function showhrefmagic(array $dress): string
|
||||
{
|
||||
require_once 'classes/quests_class.php';
|
||||
$q = new Quests();
|
||||
return $q->timeOut($ttm);
|
||||
$magic = new Battles\Magic\Magic(Db::getInstance(), $dress['includemagic']);
|
||||
|
||||
$r = '';
|
||||
$script = User::getInstance()->getBattle() ? 'fbattle' : 'main';
|
||||
|
||||
$r .= "<a onclick=\"";
|
||||
if ($magic->getMagic()->targeted == 1) {
|
||||
$r .= "okno('Введите название предмета', '{$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'] . "';";
|
||||
}
|
||||
$r .= "\"href='#'>";
|
||||
$r .= "<img src=\"i/sh/{$dress['img']}\" style=\"filter:shadow(color=red, direction=90, strength=3);\" title=\"" . $dress['name'] . (($dress['text'] != null) ? "<br />На оружии выгравировано '{$dress['text']}'" : "") . "\"><br>";
|
||||
return $r;
|
||||
}
|
||||
|
||||
function timeOut($ttm)
|
||||
{
|
||||
$out = '';
|
||||
$time_still = $ttm;
|
||||
$tmp = floor($time_still / 2592000);
|
||||
$id = 0;
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " мес. ";
|
||||
}
|
||||
$time_still = $time_still - $tmp * 2592000;
|
||||
}
|
||||
$tmp = floor($time_still / 86400);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " дн. ";
|
||||
}
|
||||
$time_still = $time_still - $tmp * 86400;
|
||||
}
|
||||
$tmp = floor($time_still / 3600);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " ч. ";
|
||||
}
|
||||
$time_still = $time_still - $tmp * 3600;
|
||||
}
|
||||
$tmp = floor($time_still / 60);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " мин. ";
|
||||
}
|
||||
}
|
||||
if ($out == '') {
|
||||
if ($time_still < 0) {
|
||||
$time_still = 0;
|
||||
}
|
||||
$out = $time_still . ' сек.';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,14 +270,103 @@ function timeOut($ttm): string
|
||||
* @param $vars
|
||||
* @param $vls
|
||||
* @param $uid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function addActions($time, $vars, $vls, $uid)
|
||||
{
|
||||
$query = 'insert into actions (uid, time, city, room, vars, ip, vals) values (?,?,?,?,?,?,?)';
|
||||
$values = [$uid, $time, 'capitalcity', 0, $vars, $_SERVER['REMOTE_ADDR'], $vls];
|
||||
Db::getInstance()->execute('lock tables actions write');
|
||||
Db::getInstance()->execute($query, $values);
|
||||
Db::getInstance()->execute('unlock tables');
|
||||
db::c()->query('LOCK TABLES `actions` WRITE');
|
||||
$ins = db::c()->query('INSERT INTO `actions` (`uid`,`time`,`city`,`room`,`vars`,`ip`,`vals`) VALUES (?i, ?i, "?s", ?i, "?s", "?s", "?s")', $uid, $time, "capitalcity", 0, $vars, $_SERVER['REMOTE_ADDR'], $vls);
|
||||
db::c()->query('UNLOCK TABLES');
|
||||
return $ins;
|
||||
}
|
||||
|
||||
// использовать магию
|
||||
function usemagic($id, $target)
|
||||
{
|
||||
$user = Db::getInstance()->fetch('select * from users where id = ?', $_SESSION['uid']);
|
||||
$row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', User::getInstance()->getId(), $id)->fetch_assoc_array();
|
||||
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', User::getInstance()->getBattle())->fetch_assoc_array();
|
||||
$all_magic = unserialize($bat['magic']);
|
||||
$charge = 0;
|
||||
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['magic'])->fetch_assoc_array();
|
||||
|
||||
if ($magic['needcharge'] > 0) {
|
||||
$charge = $magic['needcharge'];
|
||||
}
|
||||
|
||||
$incmagic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['includemagic'])->fetch_assoc_array();
|
||||
if ($incmagic['needcharge'] > 0) {
|
||||
$charge = $incmagic['needcharge'];
|
||||
}
|
||||
//Переделать под новую базу
|
||||
if (($all_magic[User::getInstance()->getId()] < 1 || $charge == 0) &&
|
||||
($user['sila'] >= $row['nsila'] &&
|
||||
$user['lovk'] >= $row['nlovk'] &&
|
||||
$user['inta'] >= $row['ninta'] &&
|
||||
$user['vinos'] >= $row['nvinos'] &&
|
||||
$user['intel'] >= $row['nintel'] &&
|
||||
$user['level'] >= $row['nlevel'] &&
|
||||
(($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) &&
|
||||
$user['noj'] >= $row['nnoj'] &&
|
||||
$user['topor'] >= $row['ntopor'] &&
|
||||
$user['dubina'] >= $row['ndubina'] &&
|
||||
$user['mec'] >= $row['nmech'] &&
|
||||
($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) &&
|
||||
$user['mwater'] >= $row['nwater'] &&
|
||||
$user['mair'] >= $row['nair'] &&
|
||||
$user['mearth'] >= $row['nearth'] &&
|
||||
$user['mlight'] >= $row['nlight'] &&
|
||||
$user['mgray'] >= $row['ngray'] &&
|
||||
$user['mdark'] >= $row['ndark'] &&
|
||||
$row['needident'] == 0
|
||||
) || $row['magic'] == 48 || $row['magic'] == 50) {
|
||||
|
||||
|
||||
if (!$row['magic']) {
|
||||
$incmagic['name'] = $row['includemagicname'];
|
||||
$incmagic['cur'] = $row['includemagicdex'];
|
||||
$incmagic['max'] = $row['includemagicmax'];
|
||||
if ($incmagic['cur'] <= 0) {
|
||||
return false;
|
||||
}
|
||||
$magic['targeted'] = $incmagic['targeted'];
|
||||
echo "<span class='error'>";
|
||||
include("magic/" . $incmagic['file']);
|
||||
echo "</span>";
|
||||
} else {
|
||||
echo "<span class='error'>";
|
||||
include("magic/" . $magic['file']);
|
||||
echo "</span>";
|
||||
}
|
||||
if ($bat) {
|
||||
if ($row['maxdur'] <= ($row['duration'] + 1)) {
|
||||
InventoryItem::destroyItem($row['id']);
|
||||
} else {
|
||||
if (!$row['magic']) {
|
||||
$query = 'update inventory set includemagicdex = includemagicdex - ? where item_id = ?';
|
||||
} else {
|
||||
$query = 'update inventory set durability = durability + ? where item_id = ?';
|
||||
}
|
||||
Db::getInstance()->execute($query, [$bat, $row['id']]);
|
||||
}
|
||||
if (!$charge) {
|
||||
$charge = 0;
|
||||
}
|
||||
//ограничение по кол-ву за ход
|
||||
if (User::getInstance()->getBattle()) {
|
||||
$batMagic = Db::getInstance()->fetchColumn('select magic from battle where battle_id = ?', User::getInstance()->getBattle());
|
||||
}
|
||||
if (empty($batMagic)) {
|
||||
$all_magic = [];
|
||||
} else {
|
||||
$all_magic = unserialize($batMagic);
|
||||
}
|
||||
$all_magic[User::getInstance()->getId()] += $charge;
|
||||
Db::getInstance()->execute('update battle set magic = ? where battle_id = ?', [serialize($all_magic), User::getInstance()->getBattle()]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ВАЖНО! (#44)
|
||||
@ -192,20 +393,6 @@ function err($t)
|
||||
echo '<span class="error">' . $t . '</span>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param string $text
|
||||
*
|
||||
*/
|
||||
function telegraph(int $userId, string $text)
|
||||
{
|
||||
$userExists = Db::getInstance()->fetchColumn('select count(*) from users where id = ?', $userId) > 0;
|
||||
if ($userExists) {
|
||||
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
|
||||
{
|
||||
$mods = [
|
||||
|
327
hostel.php
@ -1,60 +1,315 @@
|
||||
<?php
|
||||
|
||||
use Battles\{Database\Db, Hostel, Travel, User, UserEffect};
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'config.php';
|
||||
$hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "' . User::getInstance()->getId() . '" LIMIT 1'));
|
||||
$error = '';
|
||||
$rs = '';
|
||||
$base = [1 => ['type' => 'Сумка'], 2 => ['type' => 'Сундук'], 3 => ['type' => 'Комната'], 4 => ['type' => 'Амбар']];
|
||||
$times = [1 => 7, 2 => 14, 3 => 21, 4 => 28];
|
||||
$cost = [1 => [8, 16, 24, 32], 2 => [15, 30, 45, 60], 3 => [25, 50, 75, 100], 4 => [40, 80, 120, 160]];
|
||||
|
||||
$host = new Hostel();
|
||||
|
||||
if (!empty($_GET['exit'])) {
|
||||
Travel::toRoom(26, 661);
|
||||
}
|
||||
|
||||
if (!empty($_GET['to_room'])) {
|
||||
if (empty($host->getHid())) {
|
||||
$host->setError('У Вас, нету комнаты!');
|
||||
}
|
||||
if ($host->getTime() <= time()) {
|
||||
$host->setError('У Вас просрочена аренда. Оплатите что-бы продолжить пользоваться нашими услугами!');
|
||||
}
|
||||
if ($host->getStatus()['type'] !== 'error') {
|
||||
Travel::toRoom(661, 26);
|
||||
function remove_hostel_items($u)
|
||||
{
|
||||
$itms = mysql_query('SELECT `id`, `owner` FROM `inventory` WHERE `owner` = "-101' . $u . '"');
|
||||
while ($pl = mysql_fetch_array($itms)) {
|
||||
mysql_query('UPDATE `inventory` SET `owner` = "' . $u . '" WHERE `id` = "' . $pl['id'] . '" AND `owner` = "-101' . $u . '"');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['pays'])) {
|
||||
$host->changeTime($_GET['pays']);
|
||||
function select_arenda($u, $type, $redirect = false)
|
||||
{
|
||||
$hostel = mysql_fetch_array(mysql_query('SELECT `id` FROM `hostel` WHERE `uid` = "' . $u['id'] . '" LIMIT 1'));
|
||||
$price = [1 => 8, 2 => 15, 3 => 25, 4 => 40];
|
||||
if (!isset($u['id'])) {
|
||||
$r = 'Персонаж не найден ...';
|
||||
} else {
|
||||
if ($type > 0 && $type <= 4) {
|
||||
if (isset($hostel['id'])) {
|
||||
$r = 'Не более 1 арендованного места ...';
|
||||
} else {
|
||||
if ($u['money'] >= $price[$type]) {
|
||||
$u['money'] -= $price[$type];
|
||||
mysql_query('UPDATE `users` SET `money` = "' . $u['money'] . '" WHERE `id` = "' . $u['id'] . '" LIMIT 1');
|
||||
mysql_query('INSERT INTO `hostel` (`uid`, `type`, `time`) VALUES ("' . $u['id'] . '", "' . $type . '", "' . (time() + 60 * 60 * 24 * 7) . '")');
|
||||
$r = 'Поздравляем с успешной арендой ...';
|
||||
} else {
|
||||
$r = 'Недостаточно денег ...';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$r = 'Неверный тип аренды ...';
|
||||
}
|
||||
}
|
||||
if ($redirect) {
|
||||
header('Location: main.php');
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
if (!empty($_POST['select']) && !empty($_POST['tariff'])) {
|
||||
$host->newRent((int)$_POST['tariff']);
|
||||
if ($_GET['exit'] == 1) {
|
||||
if ($user['sleep'] == 0) {
|
||||
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 26, `online`.`room` = 26 WHERE `users`.`id` = "' . User::getInstance()->getId() . '" AND `online`.`id` = "' . User::getInstance()->getId() . '"');
|
||||
header('Location: city.php');
|
||||
} else {
|
||||
$error = 'Вы спите ...';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['del'])) {
|
||||
$host->remove();
|
||||
if ($_GET['to_room'] == 1) {
|
||||
if (isset($hostel['id'])) {
|
||||
if ($hostel['time'] > time()) {
|
||||
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 661, `online`.`room` = 661 WHERE `users`.`id` = "' . User::getInstance()->getId() . '" AND `online`.`id` = "' . User::getInstance()->getId() . '"');
|
||||
header('Location: hostel_room.php');
|
||||
} else {
|
||||
$error = 'У Вас просрочена аренда. Оплатите что-бы продолжить пользоваться нашими услугами ...';
|
||||
}
|
||||
} else {
|
||||
$error = 'У Вас, нету комнаты ...';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['deselect']) && !empty($_POST['retariff'])) {
|
||||
$host->changeType((int)$_POST['retariff']);
|
||||
header('Location: main.php');
|
||||
if ($_GET['pays'] && (int)$_GET['pays'] >= 1 && (int)$_GET['pays'] <= 4) {
|
||||
if (isset($hostel['id'])) {
|
||||
if (User::getInstance()->getMoney() >= $cost[$hostel['type']][(int)$_GET['pays']]) {
|
||||
$time = $hostel['time'] + 60 * 60 * 24 * $times[(int)$_GET['pays']];
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() -= $cost[$hostel['type']][(int)$_GET['pays']]);
|
||||
$hostel['time'] = $time;
|
||||
mysql_query('UPDATE `users` SET `money` = "' . User::getInstance()->getMoney() . '" WHERE `id` = "' . User::getInstance()->getId() . '" LIMIT 1');
|
||||
mysql_query('UPDATE `hostel` SET `time` = "' . $time . '" WHERE `uid` = "' . User::getInstance()->getId() . '" AND `id` = "' . $hostel['id'] . '" LIMIT 1');
|
||||
$error = 'Всё прошло успешно ...';
|
||||
} else {
|
||||
$error = 'Недостаточно денег ...';
|
||||
}
|
||||
} else {
|
||||
$error = 'Ошибка #1';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['sleep'])) {
|
||||
if (UserEffect::getRemainingEffectTime(User::getInstance()->getId(), 8) <= time()) {
|
||||
//Разморозка таймеров эффектов??!
|
||||
UserEffect::add(User::getInstance()->getId(), 8, UserEffect::$effectName[8], time() + 60 * 60 * 2);
|
||||
Db::getInstance()->execute('update users_effects set remaining_time = remaining_time - ? where owner_id = ? and type not in (11,12,13,14,5,4,3,2,8)', [time(), User::getInstance()->getId()]);
|
||||
if (isset($_POST['select']) && isset($_POST['tariff'])) {
|
||||
if ($_POST['tariff'] == 0) {
|
||||
$error = 'Выберите тариф ...';
|
||||
} else {
|
||||
$error = select_arenda(User::getInstance(), (int)$_POST['tariff']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET['del'] == 1) {
|
||||
if (isset($hostel['id']) && $hostel['time'] > time()) {
|
||||
mysql_query('DELETE FROM `hostel` WHERE `uid` = "' . User::getInstance()->getId() . '" AND `id` = "' . $hostel['id'] . '" LIMIT 1');
|
||||
remove_hostel_items(User::getInstance()->getId());
|
||||
$error = 'Вы успешно отказались от аренды ...';
|
||||
unset($hostel);
|
||||
} elseif (isset($hostel['id']) && $hostel['time'] < time()) {
|
||||
$error = 'Нельзя отказаться от услуг если имеется задолежнность ...';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['deselect']) && isset($_POST['retariff'])) {
|
||||
if (isset($hostel['id']) && $hostel['time'] > time()) {
|
||||
mysql_query('DELETE FROM `hostel` WHERE `uid` = "' . User::getInstance()->getId() . '" AND `id` = "' . $hostel['id'] . '" LIMIT 1');
|
||||
remove_hostel_items(User::getInstance()->getId());
|
||||
select_arenda(User::getInstance(), (int)$_POST['retariff'], true);
|
||||
} elseif (isset($hostel['id']) && $hostel['time'] < time()) {
|
||||
$error = 'Нельзя сменить услугу если имеется задолежнность ...';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET['sleep'] && $user['sleep'] == 0) {
|
||||
if ($user['sleep_time'] <= time()) {
|
||||
$sl = 2;
|
||||
mysql_query('UPDATE `users` SET `sleep` = "' . (time() + 60 * 60 * $sl) . '", `sleep_time` = "' . (time() + 60 * 60 * 8) . '" WHERE `id` = "' . User::getInstance()->getId() . '" LIMIT 1');
|
||||
mysql_query('INSERT INTO `effects` (`type`, `name`, `time`, `owner`) VALUES ("8", "Сон", "' . (time() + 60 * 60 * $sl) . '", "' . User::getInstance()->getId() . '")');
|
||||
$ef = mysql_query('SELECT `id`, `time`, `type` FROM `effects` WHERE `owner` = "' . User::getInstance()->getId() . '" AND `type` != 11 AND `type` != 12 AND `type` != 13 AND `type` != 14 AND `type` != 5 AND `type` != 4 AND `type` != 2 AND `type` != 3 AND `type` != 8');
|
||||
while ($pl = mysql_fetch_array($ef)) {
|
||||
$tm = $pl['time'] - time();
|
||||
mysql_query('UPDATE `effects` SET `sleep` = "' . $tm . '" WHERE `id` = "' . $pl['id'] . '" AND `owner` = "' . User::getInstance()->getId() . '"');
|
||||
}
|
||||
header('Location: hostel.php');
|
||||
} else {
|
||||
$host->setError('Нельзя спать! Приходите через: ' . timeOut($user['sleep_time'] - time()));
|
||||
$error = 'Нельзя спать ... Приходите через : ' . timeOut($user['sleep_time'] - time());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['unsleep'])) {
|
||||
//Заморозка таймеров эффектов??!
|
||||
UserEffect::remove(User::getInstance()->getId(), 8);
|
||||
Db::getInstance()->execute('update users_effects set remaining_time = remaining_time + ? where owner_id = ? and type not in (11,12,13,14,5,4,3,2,8)', [time(), User::getInstance()->getId()]);
|
||||
if ($_GET['unsleep'] && $user['sleep'] > 0) {
|
||||
mysql_query('UPDATE `users` SET `sleep` = "0" WHERE `id` = "' . User::getInstance()->getId() . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `effects` WHERE `owner` = "' . User::getInstance()->getId() . '" AND `type` = "8" LIMIT 1');
|
||||
$ef = mysql_query('SELECT `id`, `time`, `sleep` FROM `effects` WHERE `owner` = "' . User::getInstance()->getId() . '" AND `sleep` != 0');
|
||||
while ($pl = mysql_fetch_array($ef)) {
|
||||
$tm = time() + $pl['sleep'];
|
||||
mysql_query('UPDATE `effects` SET `time` = "' . $tm . '", `sleep` = "0" WHERE `id` = "' . $pl['id'] . '" AND `owner` = "' . User::getInstance()->getId() . '"');
|
||||
}
|
||||
header('Location: hostel.php');
|
||||
}
|
||||
Template::header('Хостел');
|
||||
?>
|
||||
<script src="js/ajaxLoad.js"></script>
|
||||
<? if (isset($hostel['id'])) { ?>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#retariff option[value='<?=$hostel['type']; ?>']").remove();
|
||||
});
|
||||
</script>
|
||||
<? } ?>
|
||||
<link rel="stylesheet" href="css/hostel.css"/>
|
||||
<div class="contentContainer">
|
||||
<div style="text-align: center;"><span class="hs">Гостиница, Холл</span></div>
|
||||
<div class="buttonContainer">
|
||||
<? if ($user['sleep'] == 0) { ?>
|
||||
<input type="button" class="btns button-route" value="Уснуть" onclick="location.href='?sleep=1';"/>
|
||||
<? } else { ?>
|
||||
<input type="button" class="btns button-route" value="Пробудиться" onclick="location.href='?unsleep=1';"/>
|
||||
<? } ?>
|
||||
<input type="button" class="btns" value="Обновить" onclick="location.href='main.php';"/>
|
||||
<input type="button" class="btns button-route" value="На улицу" onclick="location.href='?exit=1';"/>
|
||||
<input type="button" class="btns button-route" value="Комната" onclick="location.href='?to_room=1';"/>
|
||||
</div>
|
||||
|
||||
require_once 'views/hostel.php';
|
||||
<div id="hostelLeft">
|
||||
<div id="hostelInteractive">
|
||||
<? if (!isset($hostel['id'])) { ?>
|
||||
<fieldset class="hostelClientState">
|
||||
<legend>Станьте нашим клиентом</legend>
|
||||
<form method="post" style="text-align: center; width: 100%;">
|
||||
<input type="hidden" name="act" value="settariff"/>
|
||||
<p>Выберите подходящий для Вас вариант обслуживания:</p>
|
||||
<div style="text-align: center; width: 100%;">
|
||||
<select name="tariff" class="tariff">
|
||||
<option value="0">Выбор ...</option>
|
||||
<option value="1">Сумка</option>
|
||||
<option value="2">Сундук</option>
|
||||
<option value="3">Комната</option>
|
||||
<option value="4">Амбар</option>
|
||||
</select>
|
||||
<input type="submit" class="button" value="Выбрал" name="select"/>
|
||||
<? if ($error != '') {
|
||||
echo '<br /><b style="color: Red;">' . $error . '</b><br />';
|
||||
} ?>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
<? } else { ?>
|
||||
<fieldset class="hostelClientState">
|
||||
<legend>Добро пожаловать!</legend>
|
||||
<form method="post" style="text-align: center; width: 100%;">
|
||||
<p>Вы выбрали вариант предоставления жилья : <b><?= $base[$hostel['type']]['type']; ?></b></p>
|
||||
<p>Аренда оплачена по: <? echo date('h:i d.m.y', $hostel['time']); ?>
|
||||
(<small><? echo timeOut($hostel['time'] - time()); ?></small>)</p>
|
||||
<div style="text-align: center; width: 100%;">
|
||||
Сменить вариант аренды <select name="retariff" id="retariff">
|
||||
<option value="0">Выбор ...</option>
|
||||
<option value="1">Сумка</option>
|
||||
<option value="2">Сундук</option>
|
||||
<option value="3">Комната</option>
|
||||
<option value="4">Амбар</option>
|
||||
</select>
|
||||
<input type="submit" class="button" value="Сменить" name="deselect"/>
|
||||
</div>
|
||||
</form>
|
||||
<a href="javascript: void(0);" style="float: left; margin-left: 3px;"
|
||||
onclick="if(confirm('Вы уверены?')) { location.href='?del=1'; }">Расторгнуть договор</a> <a
|
||||
href="javascript: void(0);"
|
||||
onclick="ajaxLoad('/hostel_checkpoint.php', 'hostelInteractive', {act:'pay'})"
|
||||
style="float: right; margin-right: 3px;">Внести предоплату</a>
|
||||
<? if ($error != '') {
|
||||
echo '<br /><center><b style="color: Red;">' . $error . '</b></center><br />';
|
||||
} ?>
|
||||
</fieldset>
|
||||
<? } ?>
|
||||
</div>
|
||||
<fieldset class="hostelRules" style="overflow: hidden;">
|
||||
<legend>Правила проживания</legend>
|
||||
<div style="overflow: auto; height: 168px !important; margin: 0; padding: 0;">
|
||||
<div style="margin: 0; padding: 0; height: 100%;">
|
||||
<h2>И что я получу за свои кровные?</h2>
|
||||
У нас ты можешь:
|
||||
<br/>- хранить свое барахло и прочий хлам.
|
||||
<h2>Охрана у вас есть? Не воруют?</h2>
|
||||
Самые любопытные могут получить в сурло прямо здесь - в холле.
|
||||
<br/>- Устраивать беспорядки в комнатах не позволено.
|
||||
<br/>- Прислуга у нас проверенная - пожитки твои не тронут.
|
||||
<h2>И сколько стоит всё это удовольствие?</h2>
|
||||
- Комнаты есть разные, для людей разного достатка. Смотри справа расценки.
|
||||
<br/>- Платить нужно каждый день. Пока не заплатишь - на лестницу не ногой.
|
||||
<br/>- Вместимость - это сколько твоих вещей влезет в комнату, имеется ввиду общая масса инвентаря.
|
||||
|
||||
<h2>Как всем этим пользоваться?</h2>
|
||||
Всё просто. Плати и живи.
|
||||
<br/>Приходишь, платишь по долгам, проходишь в аппартаменты. В сундуке есть секции для каждого вида
|
||||
вещей, фильтр поможет разобраться.
|
||||
<h2>Что ещё мне нужно знать?</h2>
|
||||
- При смене размера комнаты, ты теряешь оставшееся оплаченное время.
|
||||
<br/>- При просрочке платы более 60 суток, мы оставляем за собой право сдать вещи на аукцион для
|
||||
погашения задолжености.
|
||||
<br/>- Если долг будет разумный, то подарки забирать с полки не будем.
|
||||
<br/>- Быстро сориентироваться с шмотом поможет фильтр предметов.
|
||||
<br/>- Если что потеряешь - твои проблемы.
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div id="hostelRight">
|
||||
<fieldset>
|
||||
<legend>Тарифы и услуги</legend>
|
||||
<br/>
|
||||
<table class="tarifsList" cellpadding="0" cellspacing="0">
|
||||
<caption>Сумка</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Вместимость</td>
|
||||
<td class="tarifListValue">15 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Стоимость (7 сут.)</td>
|
||||
<td class="tarifListValue">8.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table class="tarifsList" cellpadding="0" cellspacing="0">
|
||||
<caption>Сундук</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Вместимость</td>
|
||||
<td class="tarifListValue">30 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Стоимость (7 сут.)</td>
|
||||
<td class="tarifListValue">15.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table class="tarifsList" cellpadding="0" cellspacing="0">
|
||||
<caption>Комната</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Вместимость</td>
|
||||
<td class="tarifListValue">50 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Стоимость (7 сут.)</td>
|
||||
<td class="tarifListValue">25.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table class="tarifsList" cellpadding="0" cellspacing="0">
|
||||
<caption>Амбар</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Вместимость</td>
|
||||
<td class="tarifListValue">100 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tarifListLabel">Стоимость (7 сут.)</td>
|
||||
<td class="tarifListValue">40.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
@ -1,9 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Battles\Hostel;
|
||||
use Battles\User, Battles\Database\Db;
|
||||
|
||||
require_once 'config.php';
|
||||
require_once "functions.php";
|
||||
$hostel = Db::getInstance()->execute('select id, time, type from hostel where uid = ?', User::getInstance()->getId());
|
||||
$base = [1 => [8, 16, 24, 32], 2 => [15, 30, 45, 60], 3 => [25, 50, 75, 100], 4 => [40, 80, 120, 160]];
|
||||
|
||||
$host = new Hostel();
|
||||
if (isset($_POST['act']) && $_POST['act'] == 'pay' && isset($user['id']) && !empty($hostel->fetchColumn())) {
|
||||
echo '<fieldset class="hostelClientState">';
|
||||
echo '<legend>Предварительная оплата</legend>';
|
||||
echo '<div style="text-align: center;"><p class="NORMAL" style="margin: 5px 0">';
|
||||
echo 'Аренда оплачена по: <b>' . date('h:i d.m.y', $hostel->fetchColumn(1)) . '</b> <small>(' . timeOut($hostel->fetchColumn(1) - time()) . ')</small></p></div>';
|
||||
|
||||
require_once 'views/hostel-checkpoint.php';
|
||||
echo '<table align="center" class="periods"><caption style="text-align: left;">Выберите срок предоплаты.</caption>
|
||||
<tbody>
|
||||
<tr class="caption"><th>Сутки</th><td title="7 дн.">7</td><td title="14 дн.">14</td><td title="21 дн.">21</td><td title="28 дн.">28</td></tr>
|
||||
<tr class="value"><th>Сумма</th><td title="7 дн."><a href="?pays=1">' . $base[$hostel->fetchColumn(2)][0] . '</a></td><td title="14 дн."><a href="?pays=2">' . $base[$hostel->fetchColumn(2)][1] . '</a></td><td title="21 дн."><a href="?pays=3">' . $base[$hostel->fetchColumn(2)][2] . '</a></td><td title="28 дн."><a href="?pays=4">' . $base[$hostel->fetchColumn(2)][3] . '</a></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div style="color: red; font-size: 9px; padding-top: 3px;"><b>Внимание!</b> При расторжении договора или смене тарифа, внесенная плата не возвращается</div></fieldset></div>';
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Models\Inventory;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
use Battles\UserInfo;
|
||||
@ -30,7 +29,7 @@ function get_meshok(): object
|
||||
function show_item($row, $txt, $place)
|
||||
{
|
||||
if (($row['maxdur'] <= $row['duration']) || ($row['dategoden'] && $row['dategoden'] <= time())) {
|
||||
Inventory::destroyItem($row['id'], User::getInstance()->getId());
|
||||
InventoryItem::destroyItem($row['id']);
|
||||
}
|
||||
$r = '';
|
||||
|
||||
|
27
index.php
@ -6,4 +6,29 @@ if ($_SESSION['uid']) {
|
||||
header('Location: fight.php');
|
||||
exit;
|
||||
}
|
||||
require_once 'views/index.html';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<meta charset="utf-8">
|
||||
<link href="/css/main.css" rel="stylesheet">
|
||||
<link href="/css/btn.css" rel="stylesheet">
|
||||
<title>Игра</title>
|
||||
<h1>Демонстрационная версия</h1>
|
||||
<div>
|
||||
<p>Ребята, давайте сперва сделаем чтобы работало, а потом будем делать красиво. Идёт?</p>
|
||||
<p>Пол персонажа выбирать нельзя. Это не ошибка. Все ограничения только для мальчиков или только для девочек
|
||||
постепенно будут удалены.<br>
|
||||
Любой человек может играть любым персонажем. Только его образ сможет показать кто перед вами. Мы живём в эпоху
|
||||
толерантности, знаете ли! 😉</p>
|
||||
<form method='post' action="enter.php">
|
||||
Авторизация<br>
|
||||
<input name='username' placeholder='Логин'>
|
||||
<input name='password' placeholder='Пароль' type="password">
|
||||
<br>
|
||||
<input type=submit value='Войти в игру' class="button big">
|
||||
</form>
|
||||
</div>
|
||||
<div class="button-group minor-group">
|
||||
<a class="button" href="register.php">Зарегистрироваться</a>
|
||||
<a class="button" href="rememberpassword.php">Восстановить пароль</a>
|
||||
</div>
|
18
inf.php
@ -1,15 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Battles\{Template, User};
|
||||
use Battles\Models\Presents;
|
||||
use Battles\Models\PresentsModel;
|
||||
use Battles\Template;
|
||||
use Battles\UserInfo;
|
||||
|
||||
include_once 'config.php';
|
||||
$presentsList = (new Presents())->getAll(User::getInstance($_SERVER['QUERY_STRING'])->getId());
|
||||
Template::header('Информация о ' . User::getInstance($_SERVER['QUERY_STRING'])->getLogin());
|
||||
if (!User::getInstance($_SERVER['QUERY_STRING'])->getId()) {
|
||||
$userInfo = new UserInfo(urldecode($_SERVER['QUERY_STRING']));
|
||||
$presentsModel = new PresentsModel($userInfo->getId());
|
||||
$presentsList = $presentsModel->getAllPresents();
|
||||
Template::header('Информация о ' . $userInfo->getLogin());
|
||||
if (!$userInfo->getId()) {
|
||||
echo sprintf('Ошибка: персонаж <em>%s</em> не найден...<p><a style="color: #99f;" href="javascript:window.history.go(-1);">←назад</a></p>', urldecode($_SERVER['QUERY_STRING']));
|
||||
exit;
|
||||
}
|
||||
User::getInstance($_SERVER['QUERY_STRING'])->userInfo()->showUserInfo();
|
||||
|
||||
include_once 'views/inf-presents.php';
|
||||
$userInfo->showUserInfo();
|
||||
include_once 'views/presents-list.php';
|
@ -34,6 +34,8 @@ if ($user['battle'] > 0) {
|
||||
echo "Персонаж под защитой от нападений ...";
|
||||
} elseif(isset($effect['id'])) {
|
||||
echo "Персонаж под защитой от нападений ...";
|
||||
} elseif ($us['align']==2.99) {
|
||||
echo "Не атакуйте Администратора!";
|
||||
} elseif ($owntravma['id'] && !$us['battle']) {
|
||||
echo "Персонаж тяжело травмирован...";
|
||||
} elseif ($user['klan'] != '' && ($user['klan'] == $us['klan'])) {
|
||||
@ -42,6 +44,10 @@ if ($user['battle'] > 0) {
|
||||
echo "Персонаж в другой комнате!";
|
||||
} elseif ($us['room'] == 31 || $us['room'] == 46 || $us['room'] == 47 || $us['room'] == 48 || $us['room'] == 49 ||$us['room'] == 600 || $us['room'] == 601 || $us['room'] == 45 || $us['room'] ==603 || $us['room'] == 602 || $us['room'] == 43 || $us['room'] ==45) {
|
||||
echo "Нападения в этой локации запрещены!";
|
||||
} elseif ($us['align'] == 2.9) {
|
||||
echo "Нападение на Ангела строго запрещено!";
|
||||
} elseif ($us['align'] == 4.99) {
|
||||
echo "Нападение на Комментатора запрещено!";
|
||||
} elseif ($us['level'] < 1) {
|
||||
echo "Новички находятся под защитой Мироздателя!";
|
||||
} elseif ($us['hp'] < $us['maxhp']*0.33 && !$us['battle']) {
|
||||
|
@ -43,7 +43,7 @@ if ($user['battle'] > 0) {
|
||||
echo "<font color=red><b>Этот свиток нельзя встраивать в предметы!<b></font>";
|
||||
} else {
|
||||
// встраиваем
|
||||
\Battles\Models\Inventory::destroyItem($svitok['id'], \Battles\User::getInstance()->getId());
|
||||
\Battles\InventoryItem::destroyItem($svitok['id']);
|
||||
echo "<font color=red><b>Свиток \"" . $svitok['name'] . "\" удачно встроен в \"" . $dress['name'] . "\"<b></font>";
|
||||
mysql_query("UPDATE `inventory` SET
|
||||
" . ($dress['nintel'] < $svitok['nintel'] ? "`nintel`='" . $svitok['nintel'] . "'," : "") . "
|
||||
|
326
main.php
@ -1,50 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Battles\{Database\Db, DressedItems, InventoryItem, Travel, User, UserInfo, UserEffect};
|
||||
use Battles\Database\Db;
|
||||
use Battles\DressedItems;
|
||||
use Battles\GameLogs;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Template;
|
||||
use Battles\Travel;
|
||||
use Battles\UserInfo;
|
||||
use Battles\UserStats;
|
||||
use Battles\User;
|
||||
use Exceptions\GameException;
|
||||
|
||||
if (filter_input(INPUT_SERVER, 'QUERY_STRING') === 'exit') {
|
||||
//session_destroy();
|
||||
echo 'EXIT PRESSED';
|
||||
$get = filter_input(INPUT_SERVER, 'QUERY_STRING');
|
||||
if ($get == 'exit') {
|
||||
session_destroy();
|
||||
header("Location: fight.php");
|
||||
}
|
||||
require_once 'functions.php';
|
||||
|
||||
User::getInstance()->setOnline();
|
||||
|
||||
if (!empty($_GET['edit'])) {
|
||||
if (!empty($_GET['ups'])) {
|
||||
$req = (object)[];
|
||||
$keys = ['ups', 'drop', 'dress', 'destruct', 'use', 'undress', 'edit', 'goto', 'obraz', 'setshadow'];
|
||||
foreach ($keys as $key) {
|
||||
$req->$key = $_REQUEST[$key] ?? null;
|
||||
}
|
||||
|
||||
if ($req->edit) {
|
||||
if ($req->ups) {
|
||||
try {
|
||||
$up = new UserInfo(User::getInstance()->getId());
|
||||
$up->addOnePointToStat($_GET['ups']);
|
||||
$up->addOnePointToStat($req->ups);
|
||||
unset($up);
|
||||
} catch (GameException $e) {
|
||||
echo $e;
|
||||
}
|
||||
}
|
||||
if (!empty($_GET['drop'])) {
|
||||
if ($req->drop) {
|
||||
$items = new DressedItems(User::getInstance()->getId());
|
||||
$items->undressItem($_GET['drop']);
|
||||
$items->undressItem($req->drop);
|
||||
unset($items);
|
||||
}
|
||||
//Пока что одеваем предмет отсюда.
|
||||
if (!empty($_GET['dress'])) {
|
||||
$dressing = new InventoryItem(Db::getInstance()->ofetch('select * from inventory where item_id = ? ', $_GET['dress']));
|
||||
if ($req->dress) {
|
||||
$dressing = new InventoryItem(Db::getInstance()->ofetch('select * from inventory where item_id = ? ', $req->dress));
|
||||
$dressing->dressItem();
|
||||
unset($dressing);
|
||||
}
|
||||
//Выбросить предмет. Ниоткуда не вызывается. О_о
|
||||
if (!empty($_GET['destruct'])) {
|
||||
$item = new InventoryItem(Db::getInstance()->ofetch('select * from inventory where item_id = ? ', $_GET['destruct']));
|
||||
echo $item->drop();
|
||||
unset($item);
|
||||
if ($req->destruct) {
|
||||
$q = Db::getInstance()->ofetch('select name,dressed_slot from inventory where owner_id = ? and item_id = ?', [User::getInstance()->getId(), $req->destruct]);
|
||||
if ($q) {
|
||||
if (empty($q->dressed_slot)) {
|
||||
InventoryItem::destroyItem($req->destruct);
|
||||
GameLogs::addUserLog(User::getInstance()->getId(), User::getInstance()->getLogin() . ' выбросил предмет ' . $q->name . ' id:(cap' . $req->destruct . ')');
|
||||
err('Предмет ' . $q->name . ' выброшен.');
|
||||
} else {
|
||||
err('Ошибка: нельзя выбросить одетый предмет!');
|
||||
}
|
||||
} else {
|
||||
err('Ошибка: предмет не найден!');
|
||||
}
|
||||
}
|
||||
if (!empty($_GET['undress']) && $_GET['undress'] === 'all') {
|
||||
if ($req->use) {
|
||||
usemagic($req->use, $req->useTarget);
|
||||
}
|
||||
if ($req->undress) {
|
||||
DressedItems::undressAllItems(User::getInstance()->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Подготавливаем отображение инфы и предметов.
|
||||
$userInfo = new UserInfo(User::getInstance()->getId());
|
||||
$userStats = new UserStats(User::getInstance()->getId());
|
||||
$stat = $userStats->getFullStats();
|
||||
$data = Db::getInstance()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', User::getInstance()->getId());
|
||||
$iteminfo = [];
|
||||
foreach ($data as $row) {
|
||||
@ -52,28 +81,28 @@ foreach ($data as $row) {
|
||||
}
|
||||
|
||||
//Обработчики нажатий на кнопки.
|
||||
if (!empty($_POST['battlefield']) && User::getInstance()->getRoom() === 1) {
|
||||
if ($req->battlefield ?? 0 && User::getInstance()->getRoom() == 1) {
|
||||
header('Location: zayavka.php');
|
||||
exit();
|
||||
}
|
||||
if (!empty($_POST['module_quest'])) {
|
||||
if ($req->module_quest ?? 0) {
|
||||
header('Location: module_quest.php');
|
||||
exit();
|
||||
}
|
||||
if (!empty($_POST['move_inside']) && User::getInstance()->getRoom() === 20) {
|
||||
if ($req->move_inside ?? 0 && User::getInstance()->getRoom() == 20) {
|
||||
header('Location: main.php?goto=arena');
|
||||
exit();
|
||||
}
|
||||
if (!empty($_POST['move_outside']) && User::getInstance()->getRoom() === 1) {
|
||||
if ($req->move_outside ?? 0 && User::getInstance()->getRoom() == 1) {
|
||||
header('Location: main.php?goto=plo');
|
||||
exit();
|
||||
}
|
||||
if (!empty($_POST['main_page'])) {
|
||||
if ($req->main_page ?? 0) {
|
||||
header('Location: main.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (empty($_GET['edit'])) {
|
||||
if (!$req->edit) {
|
||||
/* === проверяем соответствие комнаты и скрипта === */
|
||||
if (in_array(User::getInstance()->getRoom(), [20, 21, 26, 48, 51, 52, 651, 2655, 2601, 2701, 2702, 2111])) {
|
||||
header('Location: city.php');
|
||||
@ -84,45 +113,256 @@ if (empty($_GET['edit'])) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
function del_efs($id, $type)
|
||||
{
|
||||
if ($id && !in_array($type, [2, 3, 4, 5, 8, 10, 11, 12, 13, 14, 20])) {
|
||||
db::c()->query('DELETE FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $_SESSION['uid'], $id);
|
||||
if ($type == 1022) {
|
||||
db::c()->query('UPDATE `users` SET `invis` = 0 WHERE `id` = ?i', $_SESSION['uid']);
|
||||
}
|
||||
return 'Эффект удалён.';
|
||||
} else {
|
||||
return 'Эффект нельзя удалить.';
|
||||
}
|
||||
}
|
||||
|
||||
// Входим и выходим если можем.
|
||||
if (!empty($_GET['goto'])) {
|
||||
if ($req->goto) {
|
||||
$imove = true;
|
||||
$isInjured = Db::getInstance()->fetchColumn('select count(*) from users_effects where owner_id = ? and (type = 14 or type = 13)') > 0;
|
||||
function gotoroom($room_id)
|
||||
{
|
||||
$query = 'update users, online set users.room = ' . '$room_id' . ', online.room = ' . '$room_id' . ' where user_id = id and user_id = ?';
|
||||
Db::getInstance()->execute($query, User::getInstance()->getId());
|
||||
}
|
||||
$d = db::c()->query('SELECT SUM(weight) AS sum_weight FROM inventory WHERE owner_id = ?i AND on_sale = 0', User::getInstance()->getId())->fetch_assoc();
|
||||
$eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', User::getInstance()->getId());
|
||||
//(масса: <?= $getItemsBonuses->getItemsWeight() . '/' . User::getInstance()->strength * 4
|
||||
|
||||
if (UserEffect::isOverEncumbered(User::getInstance()->getId())) {
|
||||
if ($d['sum_weight'] > $userStats->getMaxWeight()) {
|
||||
err('У вас переполнен рюкзак, вы не можете передвигаться...');
|
||||
$imove = false;
|
||||
}
|
||||
if ($isInjured) {
|
||||
if ($eff->getNumRows()) {
|
||||
err('У вас тяжелая травма, вы не можете передвигатся...');
|
||||
$imove = false;
|
||||
}
|
||||
if ($_GET['goto'] === 'plo' && !User::getInstance()->getZayavka() && $imove && User::getInstance()->getRoom() != 20) {
|
||||
Travel::toRoom(20, User::getInstance()->getRoom());
|
||||
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle());
|
||||
if ($req->goto == 'plo' && !User::getInstance()->getZayavka() && $imove && User::getInstance()->getRoom() != 20) {
|
||||
db::c()->query('UPDATE users, online SET users.room = 20, online.room = 20 WHERE online.user_id = users.id AND online.user_id = ?i', User::getInstance()->getId());
|
||||
header('Location: city.php');
|
||||
exit("<i>Топ-топ-топ...</i>");
|
||||
} else {
|
||||
err('Подали заявку на бой и убегаете из клуба? Нехорошо...');
|
||||
}
|
||||
if ($_GET['goto'] === 'arena' && User::getInstance()->getRoom() == 20 && $imove) {
|
||||
Travel::toRoom(1, User::getInstance()->getRoom());
|
||||
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle());
|
||||
if ($req->goto == 'arena' && User::getInstance()->getRoom() == 20 && $imove) {
|
||||
db::c()->query('UPDATE users, online SET users.room = 1, online.room = 1 WHERE online.user_id = users.id AND online.user_id = ?i', User::getInstance()->getId());
|
||||
header('Location: main.php');
|
||||
exit("<i>Топ-топ-топ...</i>");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['obraz'])) {
|
||||
User::getInstance()->setShadow($_GET['obraz']);
|
||||
if ($req->use) {
|
||||
usemagic($req->use, $req->target);
|
||||
}
|
||||
|
||||
if ($req->obraz) {
|
||||
User::getInstance()->setShadow($req->obraz);
|
||||
User::getInstance()->saveUser();
|
||||
}
|
||||
|
||||
if (!empty($_POST['setshadow'])) {
|
||||
include_once 'views/main-setshadow.php';
|
||||
if ($req->setshadow) {
|
||||
Template::header('Образ персонажа');
|
||||
?>
|
||||
<div style="text-align: right;">
|
||||
<input type=button value="Вернуться" onClick="location.href='main.php?edit=<?= mt_rand() ?>';" class="button">
|
||||
</div>
|
||||
<table style="padding:5px; margin:auto;">
|
||||
<caption><b style="color: red;">Внимание! Образ персонажа выбирается только один раз.</b></caption>
|
||||
<tr>
|
||||
<td><a href="?edit=1&obraz=m1"><img alt="m01" src="i/shadow/m1.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m2"><img alt="m02" src="i/shadow/m2.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m3"><img alt="m03" src="i/shadow/m3.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m4"><img alt="m04" src="i/shadow/m4.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m5"><img alt="m05" src="i/shadow/m5.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m6"><img alt="m06" src="i/shadow/m6.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m7"><img alt="m07" src="i/shadow/m7.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m8"><img alt="m08" src="i/shadow/m8.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m9"><img alt="m09" src="i/shadow/m9.gif"></a>
|
||||
<td><a href="?edit=1&obraz=m10"><img alt="m10" src="i/shadow/m10.gif"></a>
|
||||
<tr>
|
||||
<td><a href="?edit=1&obraz=f1"><img alt="f01" src="i/shadow/f1.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f2"><img alt="f02" src="i/shadow/f2.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f3"><img alt="f03" src="i/shadow/f3.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f4"><img alt="f04" src="i/shadow/f4.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f5"><img alt="f05" src="i/shadow/f5.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f6"><img alt="f06" src="i/shadow/f6.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f7"><img alt="f07" src="i/shadow/f7.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f8"><img alt="f08" src="i/shadow/f8.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f9"><img alt="f09" src="i/shadow/f9.gif"></a>
|
||||
<td><a href="?edit=1&obraz=f10"><img alt="f10" src="i/shadow/f10.gif"></a>
|
||||
</table>
|
||||
<?php
|
||||
exit();
|
||||
}
|
||||
Template::header('Игра');
|
||||
?>
|
||||
<script src="js/funcs.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
|
||||
});
|
||||
|
||||
include_once 'views/main-game.php';
|
||||
let Hint3Name = '';
|
||||
|
||||
function okno(title, script, name, errk) {
|
||||
let errkom = '';
|
||||
let com = '';
|
||||
if (errk === 1) {
|
||||
errkom = 'Нельзя использовать символы: /\:*?"<>|+%<br>';
|
||||
}
|
||||
document.getElementById("hint3").innerHTML = `
|
||||
<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<b>${title}</b>
|
||||
</td>
|
||||
<td width=20 align=right valign=top style='cursor: pointer' onclick='closehint3();'>
|
||||
<BIG><B>x
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<form action="${script}" method=POST>
|
||||
<table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD>
|
||||
<tr>
|
||||
<INPUT TYPE=hidden name=sd4 value='6'>
|
||||
<td colspan=2>
|
||||
<span class='error'>${errkom}</span> введите название предмета
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD width=50% align=right>
|
||||
<INPUT TYPE=text NAME="${name}" value="${com}">
|
||||
</TD>
|
||||
<TD width=50%>
|
||||
<INPUT TYPE='submit' value=' »» '>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</FORM>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
`;
|
||||
document.getElementById("hint3").style.visibility = "visible";
|
||||
document.getElementById("hint3").style.left = '100';
|
||||
document.getElementById("hint3").style.top = '100';
|
||||
document.getElementById(name).focus();
|
||||
Hint3Name = name;
|
||||
}
|
||||
</script>
|
||||
<div id=hint3 class=ahint></div>
|
||||
<div id="chpassbank" style="display:none; position:absolute; top:50px; left:250px;"></div>
|
||||
<?php $userInfo->showUserInfoMain() ?>
|
||||
<table style="width: 100%;filter: sepia(1);background: white;">
|
||||
<TR>
|
||||
<td style="vertical-align: top; width: 350px">
|
||||
<?php $userInfo->showUserDoll(0, 1); ?> <!-- Первый столбец -->
|
||||
<div style="text-align: center;">
|
||||
<a href='main.php?edit=1&undress=all' class="button">Снять все</a><BR>
|
||||
<div class="effectList" style="padding-top: 15px; max-height: 150px; width: 220px;">
|
||||
<?= $userInfo->showUserEffects() ?>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
</td>
|
||||
<td style="vertical-align: top; width: 250px"> <!-- Второй столбец -->
|
||||
<div>
|
||||
<br>Уровень: <strong><?= User::getInstance()->getLevel() ?></strong>
|
||||
<br>Опыт: <strong><?= User::getInstance()->getExperience() ?></strong>
|
||||
<br>Побед: <strong>??</strong>
|
||||
<br>Поражений: <strong>??</strong>
|
||||
<br>Ничьих: <strong>??</strong>
|
||||
<br>Деньги: <strong><?= User::getInstance()->getMoney() ?></strong> кр.
|
||||
<HR>
|
||||
</div>
|
||||
<!--Параметры-->
|
||||
<div>
|
||||
<div class="container">
|
||||
Сила: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($stat->strength) . ')' : $stat->strength) ?>
|
||||
<br>
|
||||
Ловкость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($stat->dexterity) . ')' : $stat->dexterity) ?>
|
||||
<br>
|
||||
Интуиция: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($stat->intuition) . ')' : $stat->intuition) ?>
|
||||
<br>
|
||||
Выносливость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($stat->endurance) . ')' : $stat->endurance) ?>
|
||||
<br>
|
||||
Интеллект: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($stat->intelligence) . ')' : $stat->intelligence) ?>
|
||||
<br>
|
||||
Мудрость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($stat->wisdom) . ')' : $stat->wisdom) ?>
|
||||
<br>
|
||||
<?php if ($userStats->getFreeStatPoints()): ?>
|
||||
<small style="color: darkgreen;">Возможных
|
||||
увеличений: <?= $userStats->getFreeStatPoints() ?></small><br>
|
||||
<?php endif; ?>
|
||||
<br>
|
||||
<!-- #18 Разобраться в прогрессбарах -->
|
||||
Здоровье:
|
||||
<progress max="<?= $userStats->getMaxHealth() ?>"
|
||||
value="<?= $userStats->getHealth() ?>"><?= $userStats->getHealth() ?></progress>
|
||||
<br>
|
||||
Пыль:
|
||||
<progress max="<?= $userStats->getMaxMana() ?>"
|
||||
value="<?= $userStats->getMana() ?>"><?= $userStats->getMana() ?></progress>
|
||||
<br>
|
||||
Уворот: <?= $stat->evasion ?><br>
|
||||
Точность: <?= $stat->accuracy ?><br>
|
||||
Шанс крита: <?= $stat->criticals ?><br>
|
||||
Урон: <?= $stat->min_physical_damage ?>
|
||||
- <?= $stat->max_physical_damage ?> <br>
|
||||
<br>
|
||||
Защита от огня: ?? <br>
|
||||
Защита от воды: ?? <br>
|
||||
Защита от вохдуха: ?? <br>
|
||||
Защита от земли: ?? <br>
|
||||
Защита от яда: ?? <br>
|
||||
Броня головы: <?= $userStats->getHeadArmor() ?> <br>
|
||||
Броня корпуса: <?= $userStats->getChestArmor() ?> <br>
|
||||
Броня ног: <?= $userStats->getLegArmor() ?> <br>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="vertical-align: top;">
|
||||
<div class="button-container"> <!--Меню-кнопки-->
|
||||
<FORM METHOD=POST ACTION="?edit=1" name=f1>
|
||||
<?php if (User::getInstance()->getShadow() == '0.gif' || User::getInstance()->getAdmin() == 1): ?>
|
||||
<INPUT class="button primary icon user" TYPE="submit" name="setshadow" value="Образы"
|
||||
title="Образы">
|
||||
<?php endif; ?>
|
||||
<div class="button-group">
|
||||
<?php if (User::getInstance()->getRoom() == 20): ?>
|
||||
<input class="button icon move" type="submit" name="move_inside" value="Войти внутрь">
|
||||
<?php elseif (User::getInstance()->getRoom() == 1): ?>
|
||||
<input class="button primary" type="submit" name="battlefield" value="Поединки">
|
||||
<input class="button icon move" type="submit" name="move_outside" value="Выйти на улицу">
|
||||
<?php endif; ?>
|
||||
<input class="button" type="submit" name="module_quest" value="Активные задания">
|
||||
<input class="button" type="submit" name="main_page" value="На главную">
|
||||
</div>
|
||||
</div>
|
||||
<div> <!--рюкзак-->
|
||||
<table style="border: 0; padding: 2px; border-spacing: 1px; width: 100%; background-color: #a5a5a5">
|
||||
<caption>Рюкзак
|
||||
(масса: <?= '?? /' . $userStats->getMaxWeight() ?>)
|
||||
</caption>
|
||||
<?php
|
||||
foreach ($iteminfo as $ii) {
|
||||
echo "<tr><td style='width: 100px; text-align: center; background-color: #d3d3d3'>";
|
||||
$ii->printImage();
|
||||
$ii->printControls();
|
||||
echo "<td style='vertical-align: top; background-color: #d3d3d3'>";
|
||||
$ii->printInfo();
|
||||
}
|
||||
if (!$data) {
|
||||
echo "<tr><th colspan='3' style='text-align: center; background-color: #c7c7c7'>Пусто";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
@ -6,29 +6,32 @@ use Battles\User;
|
||||
require_once 'functions.php';
|
||||
require_once 'classes/quests_class.php';
|
||||
|
||||
if (!empty($_GET['end_qst_now'])) {
|
||||
$qEndNow = $_GET['end_qst_now'] ?? null;
|
||||
$qEnd = $_GET['end_qst'] ?? null;
|
||||
|
||||
if ($qEndNow) {
|
||||
$q->endq((int)$_GET['end_qst_now'], 'end', $user);
|
||||
}
|
||||
|
||||
if (!empty($_GET['end_qst'])) {
|
||||
if ($qEnd) {
|
||||
$q->winqst((int)$_GET['end_qst'], $user);
|
||||
}
|
||||
|
||||
$qsee = null;
|
||||
$qsee = '';
|
||||
$qx = 0;
|
||||
$error = '';
|
||||
$q = new Quests();
|
||||
|
||||
Template::header('module_quest');
|
||||
?>
|
||||
<link rel="stylesheet" href="css/hostel.css"/>
|
||||
<?php
|
||||
|
||||
//$sp = \Battles\Database\Db::getInstance()->fetchall('select vars from actions where vars like ? and vals = ? and uid = ? limit 100', ['%start_quest%', 'go', User::getInstance()->getId()]);
|
||||
//foreach ($sp as $row) {
|
||||
// $questId = str_replace('start_quest', '', $pl['vars']);
|
||||
// $pq = \Battles\Database\Db::getInstance()->fetch('select id, name, info from quests where is = ?', $questId);
|
||||
// $qsee .= sprintf('<a href="?end_qst_now=%s"><img src="/i/clear.gif" title="Отказаться от задания"></a> <b>%s</b><span style="float: right;"><a href="?end_qst=%s">Выполнить</a></span><div style="padding-left: 15px; padding-bottom: 5px; border-bottom: 1px solid grey;"><small>%s<br>$s</small></div><br>', $pq['id'], $pq['name'], $pq['id'], $pq['info'], $q->info($pq, User::getInstance()->getId()));
|
||||
//}
|
||||
$sp = db::c()->query('SELECT `vars` FROM `actions` WHERE `vars` LIKE "?S" AND `vals` = "?s" AND `uid` = ?i LIMIT 100', "%start_quest%", "go", User::getInstance()->getId());
|
||||
while ($pl = $sp->fetch_assoc()) {
|
||||
$questId = str_replace('start_quest', '', $pl['vars']);
|
||||
$pq = db::c()->query('SELECT `id`,`name`,`info` FROM `quests` WHERE `id` = ?i', $questId)->fetch_assoc();
|
||||
$qsee .= sprintf('<a href="?end_qst_now=%s"><img src="/i/clear.gif" title="Отказаться от задания"></a> <b>%s</b><span style="float: right;"><a href="?end_qst=%s">Выполнить</a></span><div style="padding-left: 15px; padding-bottom: 5px; border-bottom: 1px solid grey;"><small>%s<br>$s</small></div><br>', $pq['id'], $pq['name'], $pq['id'], $pq['info'], $q->info($pq, User::getInstance()->getId()));
|
||||
$qx++;
|
||||
}
|
||||
|
||||
if (!$qsee) {
|
||||
$qsee = 'У вас нет заданий.';
|
||||
@ -39,9 +42,8 @@ if ($q->error) {
|
||||
?>
|
||||
|
||||
<div class="contentContainer">
|
||||
<div style="text-align: center; padding-top: 3px;">
|
||||
<span class="hs">Состояние персонажа, <?= User::getInstance()->getLogin() ?></span>
|
||||
</div>
|
||||
<div style="text-align: center; padding-top: 3px;"><span
|
||||
class="hs">Состояние персонажа, <?= $user['login']; ?></span></div>
|
||||
<div class="buttonContainer">
|
||||
<input type="button" class="btns button-route" value="Вернуться" onclick="location.href='main.php';"/>
|
||||
<input type="button" class="btns button-route" value="Обновить" onclick="location.href='module_quest.php';"/>
|
||||
|
@ -28,7 +28,7 @@ Template::header('Подземелье Луки');
|
||||
<TR>
|
||||
<TD valign=top>
|
||||
<div style="width: 250px; text-align: center;">
|
||||
<?= $userInfo->showUserDoll() ?>
|
||||
<?php $userInfo->showUserDoll(); ?>
|
||||
</div>
|
||||
</TD>
|
||||
<TD>
|
||||
@ -291,7 +291,8 @@ Template::header('Подземелье Луки');
|
||||
<?php
|
||||
$buser = Db::getInstance()->fetch('select * from users where login = ?', 'Лука');
|
||||
//Этот класс не умеет работать с ботами! Этот вызов - заглушка!
|
||||
echo User::getInstance('Лука')->userInfo()->showUserDoll();
|
||||
$botInfo = new UserInfo('Лука');
|
||||
$botInfo->showUserDoll();
|
||||
?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
49
post.php
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Battles\Database\Db;
|
||||
use Battles\Bank;
|
||||
use Battles\GameLogs;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Nick;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
|
||||
require_once 'functions.php';
|
||||
if ($_GET['change'] ?? 0) {
|
||||
unset($_SESSION['receiverName']);
|
||||
@ -27,37 +28,33 @@ if ($_SESSION['receiverName']) {
|
||||
$sendItemId = $_POST['item_id'] ?? 0;
|
||||
$telegraphText = $_POST['message'] ?? 0;
|
||||
|
||||
if ($submit == 'sendMessage' && User::getInstance()->money()->get()) {
|
||||
if ($submit == 'sendMessage' && $telegraphText && User::getInstance()->getMoney()) {
|
||||
|
||||
if ($telegraphText) {
|
||||
if (User::getInstance()->money()->spend(1)) {
|
||||
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, $telegraphText);
|
||||
$statusMessage = 'Сообщение отправлено.';
|
||||
} else {
|
||||
$statusMessage = 'Недостаточно денег.';
|
||||
}
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - 1);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, $telegraphText);
|
||||
$statusMessage = 'Сообщение отправлено.';
|
||||
} else {
|
||||
$statusMessage = 'Сообщение было оставлено пустым!';
|
||||
}
|
||||
}
|
||||
|
||||
if ($submit == 'sendItem' && $sendItemId && User::getInstance()->money()->get()) {
|
||||
$itemName = Db::getInstance()->fetchColumn('select name from inventory where owner_id = ? and item_id = ? and dressed_slot = 0 and on_sale = 0', [User::getInstance()->getId(), $sendItemId]);
|
||||
if (!$itemName) {
|
||||
if ($submit == 'sendItem' && $sendItemId && User::getInstance()->getMoney()) {
|
||||
$res = db::c()->query('SELECT name FROM inventory WHERE owner_id = ?i AND item_id = ?i AND dressed_slot = 0 AND on_sale = 0', User::getInstance()->getId(), $sendItemId)->fetch_assoc();
|
||||
if (!$res) {
|
||||
$statusMessage = "Предмет не найден в рюкзаке.";
|
||||
} else {
|
||||
if (User::getInstance()->money()->spend(1)) {
|
||||
db::c()->query('UPDATE `inventory` SET owner_id = ?i WHERE item_id= ?i AND owner_id = ?i', $receiverId, $sendItemId, $_SESSION['uid']);
|
||||
$statusMessage = 'Предмет "' . $itemName . '" передан персонажу ' . User::getInstance($receiverId)->getLogin();
|
||||
$receiverLogMessage = 'Получен предмет "' . $itemName . '" от персонажа ' . User::getInstance()->getLogin();
|
||||
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, 'Почтовый перевод: ' . $itemName . ' от персонажа ' . $user['login'] . '.');
|
||||
// Пишем в лог отправителю.
|
||||
GameLogs::addUserLog($_SESSION['uid'], $statusMessage, 'почта');
|
||||
// Пишем в лог получателю.
|
||||
GameLogs::addUserLog($receiverId, $receiverLogMessage, 'почта');
|
||||
} else {
|
||||
$statusMessage = 'Недостаточно денег.';
|
||||
}
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - 1);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
db::c()->query('UPDATE `inventory` SET owner_id = ?i WHERE item_id= ?i AND owner_id = ?i', $receiverId, $sendItemId, $_SESSION['uid']);
|
||||
$statusMessage = 'Предмет "' . $res['name'] . '" передан персонажу ' . User::getInstance($receiverId)->getLogin();
|
||||
$receiverLogMessage = 'Получен предмет "' . $res['name'] . '" от персонажа ' . User::getInstance()->getLogin();
|
||||
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, 'Почтовый перевод: ' . $res['name'] . ' от персонажа ' . $user['login'] . '.');
|
||||
// Пишем в лог отправителю.
|
||||
GameLogs::addUserLog($_SESSION['uid'], $statusMessage, 'почта');
|
||||
// Пишем в лог получателю.
|
||||
GameLogs::addUserLog($receiverId, $receiverLogMessage, 'почта');
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,9 +93,7 @@ Template::header('Почта');
|
||||
<td valign=top align=right>
|
||||
<table class="zebra" WIDTH=100%" cellspacing="1" cellpadding="2">
|
||||
<th colspan="2">Передача предметов
|
||||
<?php foreach ($iteminfo
|
||||
|
||||
as $ii): ?>
|
||||
<?php foreach ($iteminfo as $ii): ?>
|
||||
<tr>
|
||||
<td bgcolor='#d3d3d3'>
|
||||
<?php $ii->printImage(); ?>
|
||||
@ -114,7 +109,7 @@ Template::header('Почта');
|
||||
<?php if (empty($queryItems->getNumRows())): ?>
|
||||
<tr>
|
||||
<td align=center bgcolor=#C7C7C7>Нечего передавать...
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</table>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
|
@ -13,6 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
@ -46,7 +47,7 @@ if (!empty($_POST['sendAction'])) {
|
||||
$_POST['days'] = 1;
|
||||
}
|
||||
$cost = $_POST['days'] * 5;
|
||||
if (!User::getInstance()->money()->spend($cost)) {
|
||||
if (User::getInstance()->getMoney() < $cost) {
|
||||
$status = "Не хватает кредитов на оплату подарка!";
|
||||
return;
|
||||
}
|
||||
@ -59,8 +60,9 @@ if (!empty($_POST['sendAction'])) {
|
||||
$sender = "Подарок от " . User::getInstance()->getLogin();
|
||||
}
|
||||
|
||||
\Battles\Database\Db::getInstance()->execute('insert into users_presents (owner_id, sender_id, image) values (?,?,?)', [$receiver['id'], $sender, $_POST['present']]);
|
||||
//db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(CURDATE(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $sender, $_POST['days']);
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - $cost);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(CURDATE(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $sender, $_POST['days']);
|
||||
|
||||
$telegraphText = "Вам пришёл подарок от {$sender}!";
|
||||
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText);
|
||||
|
57
register.php
@ -1,24 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Battles\Template, Battles\Register;
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
if (
|
||||
!empty($_POST['login']) &&
|
||||
!empty($_POST['psw']) &&
|
||||
!empty($_POST['email']) &&
|
||||
!empty($_POST['birthday']) &&
|
||||
!empty($_POST['law']) &&
|
||||
!empty($_POST['law2']) &&
|
||||
!empty($_COOKIE[GAMEDOMAIN])
|
||||
) {
|
||||
$_SESSION['uid'] = Register::addUser($_POST['login'], $_POST['psw'], $_POST['email'], $_POST['birthday']);
|
||||
if ($_SESSION['uid'] !== 0) {
|
||||
$_SESSION['sid'] = session_id();
|
||||
setcookie(GAMEDOMAIN, $_SESSION['uid'], time() + 3600);
|
||||
if ($_COOKIE[GAMEDOMAIN] ?? null) {
|
||||
$error = "Не больше одной регистрации в час!";
|
||||
} else {
|
||||
$login = $_POST['login'] ?? null;
|
||||
$password = isset($_POST['psw']) ? password_hash($_POST['psw'], PASSWORD_DEFAULT) : null;
|
||||
$birthday = $_POST['birthday'] ?? null;
|
||||
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
|
||||
$law = filter_input(INPUT_POST, 'law', FILTER_VALIDATE_BOOLEAN);
|
||||
$law2 = filter_input(INPUT_POST, 'law2', FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if ($login && $password && $email && $birthday && $law && $law2) {
|
||||
$uid = Register::addUser($login, $password, $email, $birthday);
|
||||
setcookie(GAMEDOMAIN, $uid, time() + 3600);
|
||||
setcookie("battle", time());
|
||||
$_SESSION['uid'] = $uid;
|
||||
$_SESSION['sid'] = session_id();
|
||||
header('Location: fight.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
require_once 'views\register.php';
|
||||
Template::header('Регистрация персонажа');
|
||||
?>
|
||||
<a href="/"> ← на главную</a>
|
||||
<?php if (isset($error)): ?>
|
||||
<h3><?= $error ?></h3>
|
||||
<?php else: ?>
|
||||
<h1>Регистрация</h1>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input required name="login" placeholder='Имя персонажа'> Имя персонажа.
|
||||
</label><br>
|
||||
<label>
|
||||
<input required name="email" type=email placeholder='Электронная почта'> Электронная почта.
|
||||
</label><br>
|
||||
<label>
|
||||
<input required name="psw" type=text placeholder='Пароль'> Пароль.
|
||||
</label><br>
|
||||
<label for="bday">Дата рождения:</label><br>
|
||||
<input required id="bday" name="birthday" type='date' min=1970-01-01 max=2010-01-01><br>
|
||||
<input required id="law" name="law" type=checkbox> <label for="law">Это мой единственный персонаж!</label><br>
|
||||
<input required id="law2" name="law2" type=checkbox> <label for="law2">Я согласен на любые
|
||||
условия, давайте играть!</label><br>
|
||||
<input type=submit value=Зарегистрироваться>
|
||||
</form>
|
||||
<?php endif; ?>
|
@ -3,16 +3,19 @@
|
||||
use Battles\Template, Battles\RememberPassword;
|
||||
|
||||
require_once("config.php");
|
||||
|
||||
$_GET['change'] ??= null;
|
||||
$login = filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$password = isset($_POST['psw']) ? password_hash($_POST['psw'], PASSWORD_DEFAULT) : null;
|
||||
$_GET['change'] = $_GET['change'] ?? null;
|
||||
$newPassword = $_POST['newpasswd'] ?? 0;
|
||||
$hashCheck = $_POST['hashcheck'] ?? 0;
|
||||
$operation = new RememberPassword();
|
||||
|
||||
if (filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS)) {
|
||||
$statusMessage = $operation->sendRecoveryMail(filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS));
|
||||
if ($login) {
|
||||
$statusMessage = $operation->sendRecoveryMail($login);
|
||||
}
|
||||
|
||||
if (!empty($_POST['newpasswd']) && !empty($_POST['hashcheck'])) {
|
||||
$statusMessage = $operation->setNewPassword($_POST['newpasswd'], $_POST['hashcheck']);
|
||||
if ($newPassword && $hashCheck) {
|
||||
$statusMessage = $operation->setNewPassword($newPassword, $hashCheck);
|
||||
}
|
||||
Template::header('Восстановление пароля');
|
||||
?>
|
||||
@ -36,7 +39,7 @@ Template::header('Восстановление пароля');
|
||||
Восстанавливать пароль можно только раз в сутки.</p>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input required name="loginid" placeholder="Имя персонажа" value="<?= filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS) ?>"> Имя персонажа.
|
||||
<input required name="loginid" placeholder="Имя персонажа" value="<?= $login ?>"> Имя персонажа.
|
||||
</label><br>
|
||||
<input type=submit>
|
||||
</form>
|
||||
|
20
repair.php
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Database\Db;
|
||||
use Battles\GameLogs;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
require_once 'functions.php';
|
||||
|
||||
require_once("functions.php");
|
||||
const GRAV_LIMIT = 32;
|
||||
const GRAV_COST = 30;
|
||||
const REPAIR_STATUS = [
|
||||
@ -25,9 +27,11 @@ $gravirovka_query = null;
|
||||
|
||||
// Гравировка 30 кред. Максимум 32 символа.
|
||||
if ($gravirovkaText && $itemId) {
|
||||
if (User::getInstance()->money()->spend(GRAV_COST)) {
|
||||
if (User::getInstance()->getMoney() >= GRAV_COST) {
|
||||
if (iconv_strlen($gravirovkaText) <= GRAV_LIMIT) {
|
||||
Db::getInstance()->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, User::getInstance()->getId(), $itemId]);
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - GRAV_COST);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
$status = REPAIR_STATUS['OK_GRAV_ADDED'];
|
||||
} else {
|
||||
$status = REPAIR_STATUS['ERROR_SIZE_LIMIT'];
|
||||
@ -38,8 +42,10 @@ if ($gravirovkaText && $itemId) {
|
||||
}
|
||||
// Снять гравировку.
|
||||
if ($gravirovkaRemove) {
|
||||
if (User::getInstance()->money()->spend(GRAV_COST)) {
|
||||
if (User::getInstance()->getMoney() >= GRAV_COST) {
|
||||
Db::getInstance()->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [User::getInstance()->getId(), $itemId]);
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - GRAV_COST);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
$status = REPAIR_STATUS['OK_GRAV_REMOVED'];
|
||||
} else {
|
||||
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
|
||||
@ -49,9 +55,11 @@ if ($gravirovkaRemove) {
|
||||
// Пока что лимит ремонта поставлен на 25. Дальше можно обыграть.
|
||||
if ($action == 'repair' && $itemId) {
|
||||
$q = Db::getInstance()->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId);
|
||||
if (User::getInstance()->money()->spend(ceil($q->durability / 2))) {
|
||||
Db::getInstance()->execute('UPDATE inventory SET durability = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND item_id = ?', [User::getInstance()->getId(), $itemId]);
|
||||
GameLogs::addUserLog(User::getInstance()->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->durability / 2) . ' кр.');
|
||||
if (User::getInstance()->getMoney() > ceil($q->duration / 2)) {
|
||||
Db::getInstance()->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [User::getInstance()->getId(), $itemId]);
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - ceil($q->duration / 2));
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
GameLogs::addUserLog(User::getInstance()->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.');
|
||||
$status = REPAIR_STATUS['OK_REPAIRED'];
|
||||
} else {
|
||||
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
|
||||
|
58
shop.php
@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Item;
|
||||
use Battles\Shop;
|
||||
use Battles\ShopItem;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'functions.php';
|
||||
|
||||
@ -18,15 +22,63 @@ if (!empty($_GET['otdel'])) {
|
||||
}
|
||||
|
||||
if (!empty($_POST['sellshop'])) {
|
||||
ShopItem::sellItem($_POST['itemId'], 1);
|
||||
ShopItem::sellItem($_POST['itemId'], User::getInstance(), 1);
|
||||
}
|
||||
|
||||
if (!empty($_POST['buyshop'])) {
|
||||
ShopItem::buyItem($_POST['itemId']);
|
||||
ShopItem::buyItem($_POST['itemId'], User::getInstance());
|
||||
}
|
||||
|
||||
if (!empty($_POST['buymarket'])) {
|
||||
ShopItem::$status = 'попытка купить с рук предмет id: ' . $_POST['itemId'];
|
||||
}
|
||||
|
||||
require_once 'views/shop.php';
|
||||
Template::header('Магазин');
|
||||
?>
|
||||
<link href='/css/shop.css' rel='stylesheet'>
|
||||
<script src="js/main.js"></script>
|
||||
<h1>Государственный магазин</h1>
|
||||
<a href=# onclick=hrefToFrame('city.php?cp')> ← выйти на Центральную площадь</a>
|
||||
<div class="status"><?= ShopItem::$status ?></div>
|
||||
<div class="row shop">
|
||||
<div class="left column">
|
||||
<h3><?= Shop::id(Shop::GENERAL_SHOP)->getCategoryName() ?></h3>
|
||||
<div>
|
||||
<?php if (Shop::id(Shop::GENERAL_SHOP)->categoryType === -1): ?>
|
||||
Вы можете продать ваши предметы за сущие копейки.
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<!--Магазин-->
|
||||
<?= Shop::id(Shop::GENERAL_SHOP)->getItemsList() ?>
|
||||
</div>
|
||||
<div class="right column">
|
||||
<div>
|
||||
<strong>
|
||||
Масса всех вещей: <?= InventoryItem::getWeightData() ?> <br>
|
||||
Деньги: <?= User::getInstance()->getMoney() ?>.
|
||||
</strong>
|
||||
</div>
|
||||
<hr>
|
||||
<div>Отделы магазина</div>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_WEAPON ?>&rnd=<?= mt_rand() ?>">Оружие</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_HELMET ?>&rnd=<?= mt_rand() ?>">Шлемы</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_ARMOR ?>&rnd=<?= mt_rand() ?>">Броня</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_LEGS ?>&rnd=<?= mt_rand() ?>">Поножи</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_BOOTS ?>&rnd=<?= mt_rand() ?>">Сапоги</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_GLOVES ?>&rnd=<?= mt_rand() ?>">Перчатки</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_SHIELD ?>&rnd=<?= mt_rand() ?>">Щиты</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_BELT ?>&rnd=<?= mt_rand() ?>">Пояса</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_RING ?>&rnd=<?= mt_rand() ?>">Кольца</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_AMULET ?>&rnd=<?= mt_rand() ?>">Амулеты</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_CONSUMABLE ?>&rnd=<?= mt_rand() ?>">Расходники</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_OTHER ?>&rnd=<?= mt_rand() ?>">Разное</a>
|
||||
<a class="waretype alltypes" href="?rnd=<?= mt_rand() ?>">Все товары</a>
|
||||
<a class="waretype sell" href="?otdel=sale&rnd=<?= mt_rand() ?>">Продать вещи</a>
|
||||
<div id="hint3" class="ahint"></div>
|
||||
<div>
|
||||
<small>Если у вас не хватит денег на покупку, деньги будут автоматически сняты с вашего банковского
|
||||
счёта
|
||||
с вычетом банковской комиссии за услуги.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
10
towerin.php
@ -9,15 +9,7 @@ use Battles\User;
|
||||
|
||||
require_once "functions.php";
|
||||
$user = User::getInstance();
|
||||
$check = new class{
|
||||
|
||||
public static function getInTower(): bool
|
||||
{
|
||||
return \Battles\Database\Db::getInstance()->fetchColumn('select in_tower from users where id = ?', User::getInstance()->getId()) === 1;
|
||||
}
|
||||
};
|
||||
|
||||
if (!$check::getInTower()) {
|
||||
if (User::getInstance()->getInTower() != 1) {
|
||||
header('Location: main.php');
|
||||
exit;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
@ -17,13 +17,12 @@ if (!empty($_GET['teleport']) && User::getInstance()->getAdmin() == 1) {
|
||||
|
||||
# ORDEN PHP
|
||||
$_POST['use'] ??= null;
|
||||
|
||||
if (User::getInstance()->getAdmin()) {
|
||||
$abil = Db::getInstance()->execute('SELECT 1 FROM users WHERE id = ?', User::getInstance()->getId())->fetchColumn();
|
||||
$abil = Db::getInstance()->execute('SELECT 1 FROM users WHERE id = ?i', User::getInstance()->getId())->fetchColumn();
|
||||
//$abil = unserialize($abil['abil']);
|
||||
switch ($_POST['use']) {
|
||||
case "healing":
|
||||
include_once("./magic/Healing.php");
|
||||
include("./magic/Healing.php");
|
||||
break;
|
||||
case "ct1":
|
||||
if ($abil[0] > 0 && User::getInstance()->getAlign() == 6) {
|
||||
@ -31,7 +30,7 @@ if (User::getInstance()->getAdmin()) {
|
||||
//include("./magic/ct1.php");
|
||||
if ($outok == 1) {
|
||||
$abil[0] -= 1;
|
||||
Db::getInstance()->execute('update users set abil = ? where id = ?', [serialize($abil), User::getInstance()->getId()]);
|
||||
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), User::getInstance()->getId());
|
||||
}
|
||||
} elseif (User::getInstance()->getAlign() != 6) {
|
||||
//Заменён на CureInjury.php class. Придумать вызов.
|
||||
@ -44,7 +43,7 @@ if (User::getInstance()->getAdmin()) {
|
||||
//include("./magic/ct2.php");
|
||||
if ($outok == 1) {
|
||||
$abil[1] -= 1;
|
||||
Db::getInstance()->execute('update users set abil = ? where id = ?', [serialize($abil), User::getInstance()->getId()]);
|
||||
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), User::getInstance()->getId());
|
||||
}
|
||||
} elseif (User::getInstance()->getAlign() != 6) {
|
||||
//Заменён на CureInjury.php class. Придумать вызов.
|
||||
@ -57,7 +56,7 @@ if (User::getInstance()->getAdmin()) {
|
||||
//include("./magic/ct3.php");
|
||||
if ($outok == 1) {
|
||||
$abil[2] -= 1;
|
||||
Db::getInstance()->execute('update users set abil = ? where id = ?', [serialize($abil), User::getInstance()->getId()]);
|
||||
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), User::getInstance()->getId());
|
||||
}
|
||||
} elseif (User::getInstance()->getAlign() != 6) {
|
||||
//Заменён на CureInjury.php class. Придумать вызов.
|
||||
@ -69,30 +68,30 @@ if (User::getInstance()->getAdmin()) {
|
||||
//include("./magic/ct_all.php");
|
||||
break;
|
||||
case "attack":
|
||||
include_once("./magic/eattack.php");
|
||||
include("./magic/eattack.php");
|
||||
break;
|
||||
case "attack_t":
|
||||
include_once("./magic/attack_t.php");
|
||||
include("./magic/attack_t.php");
|
||||
if ($skipper == 1) {
|
||||
header("Location:fbattle.php");
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
case "battack":
|
||||
include_once("./magic/ebattack.php");
|
||||
include("./magic/ebattack.php");
|
||||
break;
|
||||
|
||||
case "attackk_close":
|
||||
if ($abil[1] > 0 && User::getInstance()->getAlign() == 2) {
|
||||
include_once("./magic/attackk_close.php");
|
||||
include("./magic/attackk_close.php");
|
||||
if ($outok == 1) {
|
||||
$abil[1] -= 1;
|
||||
Db::getInstance()->execute('update users set abil = ? where id = ?', [serialize($abil), User::getInstance()->getId()]);
|
||||
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), User::getInstance()->getId());
|
||||
header("Location:fbattle.php");
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
include_once("./magic/attackk_close.php");
|
||||
include("./magic/attackk_close.php");
|
||||
header("Location:fbattle.php");
|
||||
exit();
|
||||
}
|
||||
@ -100,22 +99,22 @@ if (User::getInstance()->getAdmin()) {
|
||||
|
||||
case "attackk_open":
|
||||
if ($abil[1] > 0 && User::getInstance()->getAlign() == 2) {
|
||||
include_once("./magic/attackk_open.php");
|
||||
include("./magic/attackk_open.php");
|
||||
if ($outok == 1) {
|
||||
$abil[2] -= 1;
|
||||
Db::getInstance()->execute('update users set abil = ? where id = ?', [serialize($abil), User::getInstance()->getId()]);
|
||||
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), User::getInstance()->getId());
|
||||
header("Location:fbattle.php");
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
include_once("./magic/attackk_open.php");
|
||||
include("./magic/attackk_open.php");
|
||||
header("Location:fbattle.php");
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
|
||||
case "brat":
|
||||
include_once("./magic/brat.php");
|
||||
include("./magic/brat.php");
|
||||
if ($skipper == 1) {
|
||||
header("Location:fbattle.php");
|
||||
exit();
|
||||
@ -123,23 +122,24 @@ if (User::getInstance()->getAdmin()) {
|
||||
break;
|
||||
|
||||
case "vampir":
|
||||
include_once("./magic/vampir.php");
|
||||
include("./magic/vampir.php");
|
||||
break;
|
||||
case "crush":
|
||||
include_once("./magic/devastate.php");
|
||||
include("./magic/devastate.php");
|
||||
break;
|
||||
case "def":
|
||||
include_once("./magic/defence.php");
|
||||
include("./magic/defence.php");
|
||||
break;
|
||||
case "bexit":
|
||||
include_once("./magic/bexit.php");
|
||||
include("./magic/bexit.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function show_byu($type): string
|
||||
function show_byu($type)
|
||||
{
|
||||
global $user;
|
||||
$type = $type + 20;
|
||||
$typeName = [
|
||||
21 => '15 минут тишины',
|
||||
@ -176,19 +176,23 @@ function show_byu($type): string
|
||||
35 => 'antimirror',
|
||||
];
|
||||
if (User::getInstance()->getClan()) {
|
||||
$clan_owner = Db::getInstance()->fetchColumn('select owner_id from clans where short_name = ?', User::getInstance()->getClan());
|
||||
if ($clan_owner === User::getInstance()->getId()) {
|
||||
$r = '<span><a href="javascript:void(0);" class="byu_klan" id="' . $type . '">купить 1 шт.</a></span>';
|
||||
$clan = db::c()->query('SELECT owner_id FROM clans WHERE short_name = "?s"', User::getInstance()->getClan())->fetch_assoc();
|
||||
if ($clan['owner_id'] == User::getInstance()->getId()) {
|
||||
$r = '<div style="text-align: center;"><a href="javascript:void(0);" class="byu_klan" id="' . $type . '">купить 1 шт.</a></div>';
|
||||
} else {
|
||||
$r = '<span><a href="javascript:void(0);">Вы не глава</a></span>';
|
||||
$r = '<div style="text-align: center;"><a href="javascript:void(0);">Вы не глава</a></div>';
|
||||
}
|
||||
} else {
|
||||
$r = '<span><a href="javascript:void(0);">Вы не состоите в клане</a></span>';
|
||||
$r = '<div style="text-align: center;"><a href="javascript:void(0);">Вы не состоите в клане</a></div>';
|
||||
}
|
||||
return <<<FFFF
|
||||
<div class="items" style="padding: 2px;">
|
||||
<img style="vertical-align: middle;" class="slot valign halign" src="/i/sh/$typeImage[$type].gif" alt="$typeName[$type]"> <span>$typeName[$type]</span> [$r]
|
||||
</div>
|
||||
<div class="items">
|
||||
<div class="title">$typeName[$type]</div>
|
||||
<div class="img"><img class="slot valign halign" src="/i/sh/$typeImage[$type].gif" alt="$typeName[$type]"></div>
|
||||
<div class="control">
|
||||
$r
|
||||
</div>
|
||||
</div>
|
||||
FFFF;
|
||||
}
|
||||
|
||||
@ -227,8 +231,8 @@ A;
|
||||
<?php
|
||||
if (User::getInstance()->getAlign() == 2 || User::getInstance()->getAdmin()) // Нейтралы
|
||||
{
|
||||
$abil = [null, null, null];
|
||||
//$abil = db::c()->query('SELECT 1 FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
|
||||
$abil = db::c()->query('SELECT 1 FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
//$abil = unserialize($abil['abil']);
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
if (!$abil[$i]) {
|
||||
@ -243,8 +247,8 @@ A;
|
||||
|
||||
if (User::getInstance()->getAlign() == 6 || User::getInstance()->getAdmin()) // Свет
|
||||
{
|
||||
$abil = [null, null, null];
|
||||
//$abil = db::c()->query('SELECT 1 FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
|
||||
$abil = db::c()->query('SELECT 1 FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
//$abil = unserialize($abil['abil']);
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
if (!$abil[$i]) {
|
||||
@ -279,7 +283,7 @@ A;
|
||||
<div style="padding-top: 13px; padding-bottom: 13px;">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend>Счёт</legend>
|
||||
На счету <b><?= User::getInstance()->money()->getBank() ?></b>
|
||||
На счету <b><?= $bank['ekr'] ?></b> еврокредитов.
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
@ -414,11 +418,21 @@ A;
|
||||
</div>
|
||||
|
||||
<div id="inlines">
|
||||
<?php
|
||||
foreach (range(1, 15) as $item) {
|
||||
echo show_byu($item);
|
||||
}
|
||||
?>
|
||||
<?= show_byu(1); ?>
|
||||
<?= show_byu(2); ?>
|
||||
<?= show_byu(3); ?>
|
||||
<?= show_byu(4); ?>
|
||||
<?= show_byu(5); ?>
|
||||
<?= show_byu(6); ?>
|
||||
<?= show_byu(7); ?>
|
||||
<?= show_byu(8); ?>
|
||||
<?= show_byu(9); ?>
|
||||
<?= show_byu(10); ?>
|
||||
<?= show_byu(11); ?>
|
||||
<?= show_byu(12); ?>
|
||||
<?= show_byu(13); ?>
|
||||
<?= show_byu(14); ?>
|
||||
<?= show_byu(15); ?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
@ -4,39 +4,50 @@ use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'functions.php';
|
||||
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
|
||||
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$newpsw = filter_input(INPUT_POST, 'newpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$hobbie = filter_input(INPUT_POST, 'hobbie', FILTER_SANITIZE_STRING);
|
||||
$hobbie = str_replace("\\n", "<br />", $hobbie);
|
||||
$hobbie = str_replace("\\r", "", $hobbie);
|
||||
$hobbie = str_replace("<br />", "<br />", $hobbie);
|
||||
|
||||
if (isset($_POST['name'])) {
|
||||
User::getInstance()->profile()->setRealname($_POST['name']);
|
||||
if ($name || $hobbie) {
|
||||
if (strlen($hobbie) > User::INFO_CHAR_LIMIT) {
|
||||
err('Максимальная длинна поля Хобби: ' . User::INFO_CHAR_LIMIT . ' символов!');
|
||||
} else {
|
||||
if ($name) {
|
||||
User::getInstance()->setRealname($name);
|
||||
}
|
||||
if ($hobbie) {
|
||||
User::getInstance()->setInfo($hobbie);
|
||||
}
|
||||
User::getInstance()->saveUser();
|
||||
}
|
||||
}
|
||||
if (isset($_POST['hobbie'])) {
|
||||
User::getInstance()->profile()->setInfo($_POST['hobbie']);
|
||||
if ($oldpsw && $newpsw) {
|
||||
if (password_verify($oldpsw, User::getInstance()->getPass())) {
|
||||
User::getInstance()->setPass(password_hash($newpsw, PASSWORD_DEFAULT));
|
||||
User::getInstance()->saveUser();
|
||||
} else {
|
||||
err('Неверный текущий пароль!');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['oldpsw']) && isset($_POST['newpsw'])) {
|
||||
User::getInstance()->profile()->changePassword($_POST['oldpsw'], $_POST['newpsw']);
|
||||
}
|
||||
|
||||
if (!empty($_POST)) {
|
||||
echo User::getInstance()->profile()->save();
|
||||
}
|
||||
|
||||
Template::header('Анкета');
|
||||
?>
|
||||
<a href="main.php">← на главную</a>
|
||||
<h1>Анкета персонажа <?= User::getInstance()->getLogin() ?></h1>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input name="name" placeholder="Реальное имя" value="<?= User::getInstance()->profile()->getRealname() ?>">
|
||||
<input name="name" placeholder="Реальное имя" value="<?= User::getInstance()->getRealname() ?>">
|
||||
Реальное имя
|
||||
</label><br>
|
||||
<label>
|
||||
<textarea name="hobbie" placeholder="Хобби"><?= User::getInstance()->profile()->getInfo() ?></textarea>
|
||||
</label><br>
|
||||
<textarea name="hobbie" placeholder="Хобби"><?= User::getInstance()->getInfo() ?></textarea><br>
|
||||
<input name="submit" type="submit">
|
||||
</form>
|
||||
<h1>Безопасность</h1>
|
||||
<form method="post">
|
||||
<label><input placeholder="Старый пароль" name="oldpsw"></label>
|
||||
<label><input placeholder="Новый пароль" name="newpsw"></label>
|
||||
<input placeholder="Старый пароль" name="oldpsw">
|
||||
<input placeholder="Новый пароль" name="newpsw">
|
||||
<input type="submit">
|
||||
</form>
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
# Date: 19.02.2022 (4:20)
|
||||
use Battles\{GameConfigs, Rooms, Template, User};
|
||||
Template::header(Rooms::$roomNames[User::getInstance()->getRoom()]);
|
||||
?>
|
||||
<link href="/css/secondary.css" rel="stylesheet"/>
|
||||
<script src="/js/main.js"></script>
|
||||
<?php Template::buildingTop(Rooms::$roomNames[User::getInstance()->getRoom()], 'strah') ?>
|
||||
<div><?= $_POST['action'] ? $bank->getStatus() : '' ?></div>
|
||||
<div class="appblock appblock-main">
|
||||
<span class="wrap">На счету: <span class="num"><?= User::getInstance()->money()->getBank() ?></span></span>
|
||||
<hr>
|
||||
<span class="wrap">На руках: <span class="num"><?= User::getInstance()->money()->get() ?></span></span>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
<span class="legend">Работа со счётом</span>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input size="10" name="summa" placeholder="Сумма">
|
||||
</label>
|
||||
<input type="hidden" name="action" value="depositMoney">
|
||||
<input type="submit" value="Положить деньги">
|
||||
</form>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input size="10" name="summa" placeholder="Сумма">
|
||||
</label>
|
||||
<input type="hidden" name="action" value="withdrawMoney">
|
||||
<input type="submit" value="Снять деньги">
|
||||
</form>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
<span class="legend">Перевод кредитов</span>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input size="10" name="summa" placeholder="Сумма">
|
||||
</label>
|
||||
<label>
|
||||
<input size="10" name="to-id" placeholder="Cчёт">
|
||||
</label><br>
|
||||
<input type="hidden" name="action" value="sendMoney">
|
||||
<input type="submit" value="Перевести кредиты">
|
||||
</form>
|
||||
<span class="wrap">Комиссия: <?= GameConfigs::BANK_COMISSION * 100 ?>% от переводимой суммы, но не менее 1 кр.</span>
|
||||
</div>
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
# Date: 19.02.2022 (2:47)
|
||||
use Battles\Hostel;
|
||||
|
||||
if (isset($_POST['act']) && $_POST['act'] === 'pay' && !empty($host->getHid())): ?>
|
||||
<fieldset class="hostelClientState">
|
||||
<legend>Предварительная оплата</legend>
|
||||
<div style="text-align: center;">
|
||||
<p class="NORMAL" style="margin: 5px 0">
|
||||
Аренда оплачена по: <strong><?= date('h:i d.m.y', $host->getTime()) ?></strong>
|
||||
<small>(<?= timeOut($host->getTime() - time()) ?>)</small>
|
||||
</p>
|
||||
</div>
|
||||
<table style="margin: 0 auto;" class="periods">
|
||||
<caption style="text-align: left;">Выберите срок предоплаты.</caption>
|
||||
<tbody>
|
||||
<tr class="caption">
|
||||
<th scope="col">Сутки</th>
|
||||
<?php foreach (range(1, 4) as $item): ?>
|
||||
<td title="<?= 7 * $item ?> дн."><?= 7 * $item ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<tr class="value">
|
||||
<th scope="col">Сумма</th>
|
||||
<?php foreach (range(1, 4) as $item): ?>
|
||||
<td title="<?= 7 * $item ?> дн.">
|
||||
<a href="?pays=<?= $item ?>"><?= Hostel::PRICEPERTYPE[$host->getType()][$item - 1] ?></a>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div style="color: red; font-size: 9px; padding-top: 3px;">
|
||||
<strong>Внимание!</strong> При расторжении договора или смене тарифа, внесенная плата не возвращается
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
192
views/hostel.php
@ -1,192 +0,0 @@
|
||||
<?php
|
||||
# Date: 19.02.2022 (2:39)
|
||||
use Battles\{Rooms, User, UserEffect, Template, Hostel};
|
||||
|
||||
Template::header(Rooms::$roomNames[User::getInstance()->getRoom()]);
|
||||
?>
|
||||
<script src="/js/ajaxLoad.js"></script>
|
||||
<?php if ($host->getHid()): ?>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#retariff option[value='<?= $host->getType() ?>']").remove();
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<link rel="stylesheet" href="/css/hostel.css"/>
|
||||
<div class="contentContainer">
|
||||
<div style="text-align: center;"><span class="hs">Гостиница, Холл</span></div>
|
||||
<div class="buttonContainer">
|
||||
<?php if (UserEffect::hasEffect(User::getInstance()->getId(), 8)): ?>
|
||||
<input type="button" class="btns button-route" value="Уснуть" onclick="location.href='?sleep=1';"/>
|
||||
<?php else: ?>
|
||||
<input type="button" class="btns button-route" value="Пробудиться" onclick="location.href='?unsleep=1';"/>
|
||||
<?php endif; ?>
|
||||
<input type="button" class="btns" value="Обновить" onclick="location.href='main.php';"/>
|
||||
<input type="button" class="btns button-route" value="На улицу" onclick="location.href='?exit=1';"/>
|
||||
<input type="button" class="btns button-route" value="Комната" onclick="location.href='?to_room=1';"/>
|
||||
</div>
|
||||
|
||||
<div id="hostelLeft">
|
||||
<div id="hostelInteractive">
|
||||
<?php if (!$host->getHid()): ?>
|
||||
<fieldset class="hostelClientState">
|
||||
<legend>Станьте нашим клиентом</legend>
|
||||
<form method="post" style="text-align: center; width: 100%;">
|
||||
<input type="hidden" name="act" value="settariff"/>
|
||||
<p>Выберите подходящий для Вас вариант обслуживания:</p>
|
||||
<div style="text-align: center; width: 100%;">
|
||||
<label>
|
||||
<select name="tariff" class="tariff">
|
||||
<option selected disabled>Выбор ...</option>
|
||||
<option value="1">Сумка</option>
|
||||
<option value="2">Сундук</option>
|
||||
<option value="3">Комната</option>
|
||||
<option value="4">Амбар</option>
|
||||
</select>
|
||||
</label>
|
||||
<input type="submit" class="button" value="Выбрал" name="select"/>
|
||||
<?php if ($host->getStatus()['type'] === 'error'): ?>
|
||||
<br>
|
||||
<span style="color: red; font-weight: bold;">
|
||||
<?= $host->getStatus()['message'] ?>
|
||||
</span>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
<?php else: ?>
|
||||
<fieldset class="hostelClientState">
|
||||
<legend>Добро пожаловать!</legend>
|
||||
<form method="post" style="text-align: center; width: 100%;">
|
||||
<p>Вы выбрали вариант предоставления жилья :
|
||||
<strong><?= Hostel::BASENAME[$host->getType()] ?></strong></p>
|
||||
<p>Аренда оплачена по: <?= date('h:i d.m.y', $host->getTime()); ?>
|
||||
(<small><?= timeOut($host->getTime() - time()); ?></small>)</p>
|
||||
<div style="text-align: center; width: 100%;">
|
||||
<label>Сменить вариант аренды<select name="retariff" id="retariff">
|
||||
<option selected disabled>Выбор ...</option>
|
||||
<option value="1">Сумка</option>
|
||||
<option value="2">Сундук</option>
|
||||
<option value="3">Комната</option>
|
||||
<option value="4">Амбар</option>
|
||||
</select></label>
|
||||
<input type="submit" class="button" value="Сменить" name="deselect"/>
|
||||
</div>
|
||||
</form>
|
||||
<a href="javascript: void(0);" style="float: left; margin-left: 3px;"
|
||||
onclick="if(confirm('Вы уверены?')) { location.href='?del=1'; }">Расторгнуть договор</a> <a
|
||||
href="javascript: void(0);"
|
||||
onclick="ajaxLoad('/hostel_checkpoint.php', 'hostelInteractive', {act:'pay'})"
|
||||
style="float: right; margin-right: 3px;">Внести предоплату</a>
|
||||
<?php if ($host->getStatus()['type'] === 'error'): ?>
|
||||
<br>
|
||||
<span style="color: red; font-weight: bold;">
|
||||
<?= $host->getStatus()['message'] ?>
|
||||
</span>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<fieldset class="hostelRules" style="overflow: hidden;">
|
||||
<legend>Правила проживания</legend>
|
||||
<div style="overflow: auto; height: 168px !important; margin: 0; padding: 0;">
|
||||
<div style="margin: 0; padding: 0; height: 100%;">
|
||||
<h2>И что я получу за свои кровные?</h2>
|
||||
У нас ты можешь:
|
||||
<ul>
|
||||
<li>хранить свое барахло и прочий хлам.
|
||||
</ul>
|
||||
<h2>Охрана у вас есть? Не воруют?</h2>
|
||||
Самые любопытные могут получить в сурло прямо здесь - в холле.
|
||||
<ul>
|
||||
<li>Устраивать беспорядки в комнатах не позволено.
|
||||
<li>Прислуга у нас проверенная - пожитки твои не тронут.
|
||||
</ul>
|
||||
<h2>И сколько стоит всё это удовольствие?</h2>
|
||||
<ul>
|
||||
<li>Комнаты есть разные, для людей разного достатка. Смотри справа расценки.
|
||||
<li>Платить нужно каждый день. Пока не заплатишь - на лестницу не ногой.
|
||||
<li>Вместимость - это сколько твоих вещей влезет в комнату, имеется ввиду общая масса инвентаря.
|
||||
</ul>
|
||||
<h2>Как всем этим пользоваться?</h2>
|
||||
Всё просто. Плати и живи.
|
||||
<br/>Приходишь, платишь по долгам, проходишь в аппартаменты. В сундуке есть секции для каждого вида
|
||||
вещей, фильтр поможет разобраться.
|
||||
<h2>Что ещё мне нужно знать?</h2>
|
||||
<ul>
|
||||
<li>При смене размера комнаты, ты теряешь оставшееся оплаченное время.
|
||||
<li>При просрочке платы более 60 суток, мы оставляем за собой право сдать вещи на аукцион для
|
||||
погашения задолжености.
|
||||
<li>Если долг будет разумный, то подарки забирать с полки не будем.
|
||||
<li>Быстро сориентироваться с шмотом поможет фильтр предметов.
|
||||
<li>Если что потеряешь - твои проблемы.
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div id="hostelRight">
|
||||
<fieldset>
|
||||
<legend>Тарифы и услуги</legend>
|
||||
<br/>
|
||||
<table style='border-collapse: collapse;' class="tarifsList">
|
||||
<caption>Сумка</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Вместимость</th>
|
||||
<td class="tarifListValue">15 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Стоимость (7 сут.)</th>
|
||||
<td class="tarifListValue">8.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table style='border-collapse: collapse;' class="tarifsList">
|
||||
<caption>Сундук</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Вместимость</th>
|
||||
<td class="tarifListValue">30 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Стоимость (7 сут.)</th>
|
||||
<td class="tarifListValue">15.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table style='border-collapse: collapse;' class="tarifsList">
|
||||
<caption>Комната</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Вместимость</th>
|
||||
<td class="tarifListValue">50 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Стоимость (7 сут.)</th>
|
||||
<td class="tarifListValue">25.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table style="border-collapse: collapse;" class="tarifsList">
|
||||
<caption>Амбар</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Вместимость</th>
|
||||
<td class="tarifListValue">100 ед.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="tarifListLabel">Стоимость (7 сут.)</th>
|
||||
<td class="tarifListValue">40.00 кр.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
@ -1,27 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<meta charset="utf-8">
|
||||
<link href="/css/main.css" rel="stylesheet">
|
||||
<link href="/css/btn.css" rel="stylesheet">
|
||||
<title>Игра</title>
|
||||
<h1>Battles v.0.7.0222</h1>
|
||||
<div>
|
||||
<p>Оставь надежду всяк сюда входящий.</p>
|
||||
<form method='post' action="/enter.php">
|
||||
Авторизация<br>
|
||||
<label>
|
||||
<input name='username' placeholder='Логин'>
|
||||
</label>
|
||||
<label>
|
||||
<input name='password' placeholder='Пароль' type="password">
|
||||
</label>
|
||||
<br>
|
||||
<input type=submit value='Войти в игру' class="button big">
|
||||
</form>
|
||||
</div>
|
||||
<br>
|
||||
<div class="button-group minor-group">
|
||||
<a class="button pill" href="/register.php">Зарегистрироваться</a>
|
||||
<a class="button" href="/rememberpassword.php">Восстановить пароль</a>
|
||||
<a class="button danger icon tag pill" href='//src.lopar.space/lopar/battles/issues' target="_blank">Сообщить об ошибке</a>
|
||||
</div>
|
@ -1,125 +0,0 @@
|
||||
<?php
|
||||
use Battles\{Template, User, InventoryItem};
|
||||
# Date: 18.02.2022 (16:03)
|
||||
Template::header('Игра');
|
||||
?>
|
||||
<script src="/js/funcs.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
|
||||
});
|
||||
|
||||
let Hint3Name = '';
|
||||
|
||||
function okno(title, script, name, errk) {
|
||||
let errkom = '';
|
||||
let com = '';
|
||||
if (errk === 1) {
|
||||
errkom = 'Нельзя использовать символы: /\:*?"<>|+%<br>';
|
||||
}
|
||||
document.getElementById("hint3").innerHTML = `
|
||||
<table style="width: 100%; border-spacing: 1px; background-color: #CCC3AA">
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<b>${title}</b>
|
||||
</td>
|
||||
<td style='cursor: pointer; width: 20px; text-align: right; vertical-align: top;' onclick='closehint3();'>
|
||||
<B style="font-size: large;">x
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<form action="${script}" method=POST>
|
||||
<table style="width: 100%; background-color: #fff6dd; border-spacing: 0; border-collapse: collapse;">
|
||||
<tr>
|
||||
<input type=hidden name=sd4 value='6'>
|
||||
<td style="padding: 2px;" colspan=2>
|
||||
<span class='error'>${errkom}</span> введите название предмета
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 2px; text-align: right; width: 50%;">
|
||||
<input type=text name="${name}" value="${com}">
|
||||
</td>
|
||||
<td style="padding: 2px; width: 50%;">
|
||||
<input type='submit' value=' »» '>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
`;
|
||||
document.getElementById("hint3").style.visibility = "visible";
|
||||
document.getElementById("hint3").style.left = '100';
|
||||
document.getElementById("hint3").style.top = '100';
|
||||
document.getElementById(name).focus();
|
||||
Hint3Name = name;
|
||||
}
|
||||
</script>
|
||||
<div id=hint3 class=ahint></div>
|
||||
<div id="chpassbank" style="display:none; position:absolute; top:50px; left:250px;"></div>
|
||||
|
||||
<table style="width: 100%;background: white;">
|
||||
<tr>
|
||||
<td style="vertical-align: top; width: 350px">
|
||||
<?= User::getInstance()->userInfo()->showUserDoll(0, 1) ?> <!-- Первый столбец -->
|
||||
<div style="text-align: center;">
|
||||
<a href='/main.php?edit=<?= mt_rand() ?>&undress=all' class="button">Снять все</a><BR>
|
||||
<div class="effectList" style="padding-top: 15px; max-height: 150px; width: 220px;">
|
||||
<?= User::getInstance()->userInfo()->showUserEffects() ?>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
</td>
|
||||
<td style="vertical-align: top; width: 250px"> <!-- Второй столбец -->
|
||||
<div>
|
||||
<?php foreach (User::getInstance()->userInfo()->userInfoStatsTest() as $item => $value): ?>
|
||||
<br><?= $item ?>: <strong><?= $value ?></strong>
|
||||
<?php endforeach; ?>
|
||||
<hr>
|
||||
</div>
|
||||
</td>
|
||||
<td style="vertical-align: top;">
|
||||
<div class="button-container"> <!--Меню-кнопки-->
|
||||
<FORM METHOD=POST ACTION="?edit=<?= mt_rand() ?>" name=f1>
|
||||
<?php if (User::getInstance()->getShadow() === '0.gif' || User::getInstance()->getAdmin() === 1): ?>
|
||||
<INPUT class="button primary icon user" TYPE="submit" name="setshadow" value="Образы"
|
||||
title="Образы">
|
||||
<?php endif; ?>
|
||||
<div class="button-group">
|
||||
<?php if (User::getInstance()->getRoom() === 20): ?>
|
||||
<input class="button icon move" type="submit" name="move_inside" value="Войти внутрь">
|
||||
<?php elseif (User::getInstance()->getRoom() === 1): ?>
|
||||
<input class="button primary" type="submit" name="battlefield" value="Поединки">
|
||||
<input class="button icon move" type="submit" name="move_outside" value="Выйти на улицу">
|
||||
<?php endif; ?>
|
||||
<input class="button" type="submit" name="module_quest" value="Активные задания">
|
||||
<input class="button" type="submit" name="main_page" value="На главную">
|
||||
</div>
|
||||
</div>
|
||||
<div> <!--рюкзак-->
|
||||
<table style="border: 0; padding: 2px; border-spacing: 1px; width: 100%; background-color: #a5a5a5">
|
||||
<caption>Рюкзак (масса: <?= InventoryItem::getWeightData() ?>)</caption>
|
||||
<?php foreach ($iteminfo as $ii): ?>
|
||||
<tr>
|
||||
<td style='width: 100px; text-align: center; background-color: #d3d3d3'>
|
||||
<?= $ii->printImage() ?>
|
||||
<?= $ii->printControls() ?>
|
||||
</td>
|
||||
<td style='vertical-align: top; background-color: #d3d3d3'>
|
||||
<?= $ii->printInfo() ?>
|
||||
<?php endforeach;
|
||||
if (!$data): ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan='3' style='text-align: center; background-color: #c7c7c7' scope="col">Пусто</th>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
# Date: 18.02.2022 (15:52)
|
||||
use Battles\Template;
|
||||
|
||||
Template::header('Образ персонажа');
|
||||
?>
|
||||
<div style="text-align: right;">
|
||||
<input type=button value="Вернуться" onClick="location.href='main.php?edit=<?= mt_rand() ?>';" class="button">
|
||||
</div>
|
||||
<table style="padding:5px; margin:auto;">
|
||||
<caption style="font-weight: bold; color: red;">Внимание! Образ персонажа выбирается только один раз.</caption>
|
||||
<tr><th scope="col">
|
||||
<tr>
|
||||
<?php foreach (range(1, 10) as $item): ?>
|
||||
<td><a href="?edit=1&obraz=m<?= $item ?>"><img alt="m<?= $item ?>" src="i/shadow/m<?= $item ?>.gif"></a>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<?php foreach (range(1, 10) as $item): ?>
|
||||
<td><a href="?edit=1&obraz=f<?= $item ?>"><img alt="f<?= $item ?>" src="i/shadow/f<?= $item ?>.gif"></a>
|
||||
<?php endforeach; ?>
|
||||
</table>
|