From 5714ab83f3cfc2e21fe20df06d7648f100098797 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Fri, 20 Aug 2021 20:40:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=20=D0=B7?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=B0=D0=BA.=20=D0=A4=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=D0=B0=20php?= =?UTF-8?q?7.2=20->=20php7.4.=20=D0=9F=D0=BE=D0=BA=D1=83=D0=BF=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B4=D0=B0=D0=B6=D0=B0=20=D0=B7?= =?UTF-8?q?=D0=B0=20=D0=B1=D0=B0=D0=BD=D0=BA=D0=BD=D0=BE=D1=82=D1=8B=20(#2?= =?UTF-8?q?5).=20=D0=A3=D0=BD=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=BA=20=D0=B2=20=D0=BC=D0=B0=D0=B3=D0=B0?= =?UTF-8?q?=D0=B7=D0=B8=D0=BD=D0=B5.=20=D0=A3=D0=B4=D0=B0=D0=BB=D1=91?= =?UTF-8?q?=D0=BD=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D0=B9=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=B4.=20=D0=91?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D1=88=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D1=82.=20=D0=9F=D0=BB=D0=B0=D0=B2=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=82=D0=B5=D0=BA=D1=83=D1=87=D0=BA=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=82=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D0=B8=20db::c=20=D0=B2=20=D1=81=D1=82=D0=BE=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D1=83=20DBPDO.=20=D0=98=20=D1=82=D0=BE=D0=BC=D1=83=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BE=D0=B1=D0=BD=D0=BE=D0=B5.=20=D0=9F=D1=80?= =?UTF-8?q?=D0=BE=D1=86=D0=B5=D1=81=D1=81=20=D0=B8=D0=B4=D1=91=D1=82...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/Bank.php | 15 +- classes/Battles/GameLogs.php | 1 - classes/Battles/InventoryItem.php | 25 +- classes/Battles/Item.php | 8 +- classes/Battles/ShopItem.php | 232 ++++++++++++++----- classes/Battles/User.php | 46 ---- classes/Battles/UserInfo.php | 125 ++++++---- config.php | 2 +- functions.php | 22 +- inf.php | 13 +- library.php | 62 +---- main.php | 12 +- shop.php | 369 ++++++++++-------------------- 13 files changed, 423 insertions(+), 509 deletions(-) diff --git a/classes/Battles/Bank.php b/classes/Battles/Bank.php index c01504f..8c672f8 100644 --- a/classes/Battles/Bank.php +++ b/classes/Battles/Bank.php @@ -7,17 +7,16 @@ namespace Battles; -use Config; use Exceptions\GameException; use Battles\Database\DBPDO; use Throwable; class Bank { - public $user_id; - private $money; + public int $user_id = 0; + private int $money = 0; private $user; - private static $db; + private static DBPDO $db; const ERROR_NO_MONEY_IN_WALLET = "Ошибка! Нет денег в кошельке!"; const ERROR_NO_BANK_ACCOUNT = "Ошибка! Счёта не существует!"; @@ -174,11 +173,11 @@ class Bank self::setBankMoney($this->money, $this->user_id); $this->bankLogs(0, $this->money, "withdrawMoney"); // Отдаём сумму в кошелёк получателя - $this->user->money += $amount; - self::setWalletMoney($this->user->money, $this->user_id); + $this->user['money'] += $amount; + self::setWalletMoney($this->user['money'], $this->user_id); // Возвращаем изменившиеся значения return [ - 'walletMoney' => $this->user->money, + 'walletMoney' => $this->user['money'], 'bankMoney' => $this->money ]; } @@ -223,7 +222,7 @@ class Bank } - public function getMoney() + public function getMoney(): int { return $this->money; } diff --git a/classes/Battles/GameLogs.php b/classes/Battles/GameLogs.php index 68d61cd..329b52c 100644 --- a/classes/Battles/GameLogs.php +++ b/classes/Battles/GameLogs.php @@ -3,7 +3,6 @@ namespace Battles; -use Config; use SQLite3; use SQLite3Result; diff --git a/classes/Battles/InventoryItem.php b/classes/Battles/InventoryItem.php index 0cd1c14..e62f1a0 100644 --- a/classes/Battles/InventoryItem.php +++ b/classes/Battles/InventoryItem.php @@ -21,6 +21,7 @@ class InventoryItem extends Item { parent::__construct($row); $this->owner_id = $row->owner_id; + $this->present = $row->present; $this->db = DBPDO::INIT(); } @@ -28,7 +29,7 @@ class InventoryItem extends Item { parent::printAllInfo(); if ($this->present) { - echo "

Это подарок от {$this->present}. Вы не можете передать его кому-либо ещё.

"; + echo "

Это подарок от $this->present. Вы не можете передать его кому-либо ещё.

"; } } @@ -71,7 +72,6 @@ IMG; */ public function dressItem() { - $db = new DBPDO(); $itemInSlot = []; if ($this->dressStatsChecks()) { return self::REQUIREMENTS_NOT_MET; @@ -79,8 +79,8 @@ IMG; // считаем сколько ОДЕТЫХ предметов в слоте в который мы хотим одеть предмет. 1=просто вещь 1-3=шашни с кольцами // Count добавленный в первый запрос возвращает одну строку в любом случае. // fetch возвращает одну строку в любом случае. - $weared = $db->ofetchAll('SELECT dressed_slot FROM inventory WHERE dressed_slot != 0 AND item_type = ? AND owner_id = ?', [$this->item_type, $this->owner_id]); - $wearedCount = $db->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]); + $weared = $this->db->ofetchAll('SELECT dressed_slot FROM inventory WHERE dressed_slot != 0 AND item_type = ? AND owner_id = ?', [$this->item_type, $this->owner_id]); + $wearedCount = $this->db->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) { @@ -95,11 +95,11 @@ IMG; //работаем с нормальными слотами if ($wearedCount->c == 1) { //если слот занят, снимаем старый предмет и одеваем новый предмет - DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$itemInSlot[0], $this->owner_id]); - DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]); + $this->db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$itemInSlot[0], $this->owner_id]); + $this->db->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]); } elseif (!$wearedCount->c) { //если слот пуст, одеваем новый предмет - DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]); + $this->db->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; @@ -113,11 +113,11 @@ IMG; // Сортируем массив свободных слотов по возрастанию. sort($emptyRingSlots); // Одеваем предмет в первый свободный слот. - DBPDO::INIT()->execute('update inventory set dressed_slot = ? where item_id = ?', [$emptyRingSlots[0], $this->item_id]); + $this->db->execute('update inventory set dressed_slot = ? where item_id = ?', [$emptyRingSlots[0], $this->item_id]); } elseif ($wearedCount->c == 3) { // Cнимаем предмет из последнего слота 11 и одеваем новый предмет - DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11'); - DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?', $this->item_id); + $this->db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11'); + $this->db->execute('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?', $this->item_id); } else { /* проверка на переполнение слотов */ $error = self::TOO_MANY_ITEMS_IN_SLOTS; @@ -127,7 +127,7 @@ IMG; $error = self::UNKNOWN_ITEM_TYPE; } - return isset($error) ? $error : true; + return $error ?? true; } /** @@ -137,7 +137,6 @@ IMG; */ public static function destroyItem($itemId): bool { - $db = new DBPDO(); - return $db->execute('delete from inventory where dressed_slot = 0 and owner_id = ? and item_id = ?', [$_SESSION['uid'], $itemId]); + return DBPDO::INIT()->execute('delete from inventory where dressed_slot = 0 and owner_id = ? and item_id = ?', [$_SESSION['uid'], $itemId]); } } \ No newline at end of file diff --git a/classes/Battles/Item.php b/classes/Battles/Item.php index c2105e4..d59a859 100644 --- a/classes/Battles/Item.php +++ b/classes/Battles/Item.php @@ -6,7 +6,6 @@ class Item protected $name; protected $item_type; protected $durability; - protected $price; protected $need_strength; protected $need_dexterity; protected $need_intuition; @@ -102,8 +101,6 @@ class Item } } - - protected function wrap(int $number):string { if ($number > 0) { @@ -134,10 +131,9 @@ class Item "Увёртливость" => $this->add_evasion, "Шанс крита" => $this->add_criticals, ]; - echo "" . $this->name . " (Масса: " . $this->weight . ")"; + echo "$this->name (Масса: $this->weight)"; echo "
Долговечность: " . $this->durability; - - echo "
{$this->typename}
"; + echo "
$this->typename
"; foreach ($needsLines as $stat => $value) { if ($value > 0) { echo "
Требуется $stat" . $this->wrap($value); diff --git a/classes/Battles/ShopItem.php b/classes/Battles/ShopItem.php index b01041c..f9ee210 100644 --- a/classes/Battles/ShopItem.php +++ b/classes/Battles/ShopItem.php @@ -3,107 +3,213 @@ namespace Battles; use Battles\Database\DBPDO; +use Exceptions\GameException; class ShopItem extends Item { + private const NO_ITEMS_IN_STOCK = "Товара нет в наличии!"; + private const NO_MONEY = "У вас нет денег!"; + private const BUTTON = [ + 'setmarket' => 'Сдать в магазин', + 'unsetmarket' => 'Снять с продажи', + 'buymarket' => 'Совершить обмен', + 'sellshop' => 'Продать', + 'buyshop' => 'Купить', + ]; + private const BUY_QUERY = 'insert into inventory (owner_id, name, item_type, durability, + need_strength, need_dexterity, need_intuition, need_endurance, need_intelligence, need_wisdom, + add_strength, add_dexterity, add_intuition, add_endurance, add_intelligence, add_wisdom, + add_accuracy, add_evasion, add_criticals, add_min_physical_damage, add_max_physical_damage, + image, weight, price) + select + ?, + ifnull(name,\'Неизвестный предмет\'), + ifnull(item_type,0), + ifnull(durability, 1), + ifnull(need_strength, 0), + ifnull(need_dexterity, 0), + ifnull(need_intuition, 0), + ifnull(need_endurance, 0), + ifnull(need_intelligence, 0), + ifnull(need_wisdom, 0), + ifnull(add_strength, 0), + ifnull(add_dexterity, 0), + ifnull(add_intuition, 0), + ifnull(add_endurance, 0), + ifnull(add_intelligence, 0), + ifnull(add_wisdom, 0), + ifnull(add_accuracy, 0), + ifnull(add_evasion, 0), + ifnull(add_criticals, 0), + ifnull(add_min_physical_damage, 0), + ifnull(add_max_physical_damage, 0), + ifnull(image, \'noitem.png\'), + ifnull(weight, 1), + ? + from items where id = ?'; + // Тип операции в магазине. Для отображения разных блоков в разных случаях. + private $optype; + private ?int $shop_item_quantity; + private ?int $bank_price; + private ?int $price; + + public function __construct($row, $operationType = null) + { + parent::__construct($row); + if ($operationType) { + $this->optype = $operationType; + } + $this->price = $row->price ?? null; + $this->shop_item_quantity = $row->shop_item_quantity ?? null; + $this->bank_price = $row->bank_price ?? null; + $this->item_id = $row->item_id ?? $row->id; + } + public function printInfo() { - parent::printAllInfo(); + $this->printAllInfo(); + if ($this->optype === 'buyshop') { + if ($this->bank_price) { + echo "
Цена: $this->bank_price банкнот.
"; + } + if ($this->shop_item_quantity > 0 && $this->shop_item_quantity < 20) { + echo "
На складе осталось $this->shop_item_quantity единиц товара!
"; + } + } + if ($this->optype === 'sellshop') { + if ($this->getSellPriceMean() < 50) { + $goods = 'этот хлам'; + } elseif ($this->getSellPriceMean() < 100) { + $goods = 'этот посредственный товар'; + } elseif ($this->getSellPriceMean() < 500) { + $goods = 'этот неплохой предмет'; + } elseif ($this->getSellPriceMean() < 1000) { + $goods = 'эту отличную штуку'; + } else { + $goods = 'это превосходное изделие'; + } + echo "
В среднем за $goods можно выручить {$this->getSellPriceMean()} кр.
"; + } + } + + public function printImage(): string + { + if (!$this->image) { + $this->image = 'noitem.png'; + } + return ""; } public static function buyItem($id, User $buyer): string { - //TODO Добавить снятие денег с проверками на их наличие. $db = new DBPDO(); - $item = $db->ofetch('select * from shop where item_id = ?', $id); - $query = "INSERT INTO inventory ( - owner_id, name, item_type, durability, price, - need_strength, need_dexterity, need_intuition, - need_endurance, need_intelligence, need_wisdom, - add_strength, add_dexterity, add_intuition, - add_endurance, add_intelligence, add_wisdom, - add_accuracy, add_evasion, add_criticals, - add_min_physical_damage, add_max_physical_damage, - image, weight) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - $values = [ - $buyer->getId(), $item->name, $item->item_type, $item->durability, $item->price, - $item->need_strength, $item->need_dexterity, $item->need_intuition, - $item->need_endurance, $item->need_intelligence, $item->need_wisdom, - $item->add_strength, $item->add_dexterity, $item->add_intuition, - $item->add_endurance, $item->add_intelligence, $item->add_wisdom, - $item->add_accuracy, $item->add_evasion, $item->add_criticals, - $item->add_min_physical_damage, $item->add_max_physical_damage, - $item->image, $item->weight - ]; - $db->execute($query, $values); - $deloText = "{$buyer->getLogin()} купил товар «{$item->name}» id:($id) в магазине за $item->price кр."; + $check = $db->ofetch("select * from trade_offers where shop_item_id = ?", $id); + $itemPrice = $check->bank_price ?? 0; + if (empty($check->shop_item_quantity) || empty($check->shop_item_id)) { + return self::NO_ITEMS_IN_STOCK; + } + + // TODO БАРТЕР! + if (isset($check->barter_item_list_json)) { + echo "Работаем по бартеру!"; + } + + $db->execute(self::BUY_QUERY, [$buyer->getId(), $itemPrice, $check->shop_item_id]); + $item = $db->ofetch("select item_id, name, price from inventory where item_id = ?", $db->lastInsertId()); + if (empty($item->item_id) || empty($item->name) || empty($item->price)) { + return 'Запрос в базу не прошёл.'; + } else { + $boughtItemId = $item->item_id; + $boughtItemName = $item->name; + $boughtItemPrice = $item->price; + if ($item->price > 0) { + try { + $bank = new Bank($buyer->getId()); + $bank->withdrawMoney($item->price); + } catch (GameException $e) { + echo 'Банковская ошибка!'; + return self::NO_MONEY; + } + } + } + + if ($check->shop_item_quantity != -1) { + $db->execute("update trade_offers set shop_item_quantity = shop_item_quantity -1 where shop_item_id = ?", $check->shop_item_id); + } + + $deloText = $buyer->getLogin() . " купил товар «" . $boughtItemName . "» id:(" . $boughtItemId . ") в магазине за " . $boughtItemPrice . " банкнот."; GameLogs::addUserLog($buyer->getId(), $deloText); - return "Предмет $item->name куплен за $item->price."; + return "Предмет " . $boughtItemName . " куплен за " . $boughtItemPrice . " банкнот."; } + //TODO не пишутся логи продажи! + + /** TODO + * Notice: Undefined index: shopsell in /volume2/web/battles/classes/Battles/Bank.php on line 199 Call Stack: 0.0003 430192 + * 1. {main}() /volume2/web/battles/shop.php:0 0.0051 966928 + * 2. Battles\ShopItem::sellItem() /volume2/web/battles/shop.php:21 0.1067 998536 + * 3. Battles\Bank::setBankMoney() /volume2/web/battles/classes/Battles/ShopItem.php:162 + * Не отработал запрос в БД в файле /volume2/web/battles/classes/Battles/GameLogs.php(20) + */ public static function sellItem($id, User $seller, $bankTrade = 0): string { $db = new DBPDO(); $item = $db->ofetch('select * from inventory where item_id = ?', $id); + $sellingItemName = $item->name; // Продажа за цену от нуля до половины стоимости. $sellingPrice = mt_rand(0, $item->price / 2); $db->execute('delete from inventory where item_id = ?', $id); if ($bankTrade) { $bank = new Bank($seller->getId()); - $bank->setMoney($bank->getMoney() - $sellingPrice); + $bank->setMoney($bank->getMoney() + $sellingPrice); Bank::setBankMoney($bank->getMoney(), $seller->getId(), 'shopsell'); } else { $db->execute('update users set money = money - ? where id = ?', [$sellingPrice, $_SESSION['uid']]); } - $deloText = "{$seller->getLogin()} продал товар «{$item->name}» id:($id) в магазине за $sellingPrice кр."; + $deloText = "{$seller->getLogin()} продал товар «{$sellingItemName}» id:($id) в магазине за $sellingPrice кр."; GameLogs::addUserLog($seller->getId(), $deloText); if ($sellingPrice == 0) { - $status = "После длительных и изнурительных торгов вы плюнули на всё и просто подарили ваш «{$item->name}» торговцу."; + $status = "После длительных и изнурительных торгов вы плюнули на всё и просто подарили ваш «{$sellingItemName}» торговцу."; } else { - $status = "Вы продали «{$item->name}» за $sellingPrice кр."; + $status = "Вы продали «{$sellingItemName}» за $sellingPrice кр."; } return $status; } + /** Подчсчёт средней суммы продажи. + * @return int + */ + private function getSellPriceMean(): ?int + { + if ($this->price) { + $arr = range(0, $this->price / 2); + return array_sum($arr) / sizeof($arr); + } + return null; + } + /** * Для кнопок управления под картинкой предмета в зависимости от ситуации. - * @param null $shopType */ - public function printControls($shopType = null) + public function printControls() { - if ($shopType === 'marketput') { - echo << - - -
+ if (in_array($this->optype, ['setmarket', 'unsetmarket', 'buymarket', 'sellshop', 'buyshop',])) { + $str = $this->optype == 'setmarket' ? '' : ''; + $button_name = self::BUTTON[$this->optype]; + echo <<
$str + +
-BTN; - } else { - switch ($shopType) { - default: - $btnValue = "Купить за " . intval($this->price) . " кр."; - $btnLink = "/shop.php?buy={$this->item_id}&rnd=" . mt_rand(); - break; - case 'sell': - $btnValue = "Продать"; - $btnLink = "/shop.php?sell={$this->item_id}&rnd=" . mt_rand(); - break; - case 'marketgetback': - $btnValue = "Снять с продажи"; - $btnLink = "?back={$this->item_id}&rnd=" . mt_rand(); - break; - case 'marketbuy': - $btnValue = "Купить за " . intval($this->setsale) . " кр."; - $btnLink = "?otdel={$this->item_type}&set={$this->item_id}&rnd=" . mt_rand(); - break; - } - - echo << -BTN; +FORM; } } + + /** + * @return mixed + */ + public function getItemType() + { + return $this->item_type; + } } \ No newline at end of file diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 851c20b..871250c 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -45,52 +45,6 @@ class User } } - - protected function showStarSign(): ?string - { - /* - * 1 aries - * 2 taurus - * 3 gemini - * 4 cancer - * 5 leo - * 6 virgo - * 7 libra - * 8 scorpio - * 9 sagittarios - * 10 capricorn - * 11 aquarius - * 12 pisches - */ - $zodiac = [ - 356 => "10", - 326 => "09", - 296 => "08", - 266 => "07", - 235 => "06", - 203 => "05", - 172 => "04", - 140 => "03", - 111 => "02", - 78 => "01", - 51 => "12", - 20 => "11", - 0 => "10", - ]; - $dayOfYear = date("z", strtotime($this->borndate)); - $isLeapYear = date("L", strtotime($this->borndate)); //Высокосный? - if ($isLeapYear && $dayOfYear > 59) { - --$dayOfYear; - } - foreach ($zodiac as $day => $sign) { - if ($dayOfYear > $day) { - break; - } - } - return $sign ?? null; - } - - /** * @param int $userId * @param int $type diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index e356a25..8b0f243 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -1,15 +1,24 @@ id); + $this->bankMoney = $bank->getMoney(); + } /** * Отображает куклу персонажа (образ и слоты). @@ -19,7 +28,7 @@ class UserInfo extends UserStats * @param int $isMain установить 1, если куклу надо показать на странице игрока (по клику на предмет снимает * его). */ - private function UserInfoDoll($isBattle = 0, $isMain = 0) + private function UserInfoDoll(int $isBattle = 0, int $isMain = 0) { $di = new DressedItems($this->id); $dressedItems = $di->getItemsInSlots(); @@ -49,6 +58,45 @@ class UserInfo extends UserStats echo ''; } + private function ttz() + { + $arr = [ + 'Уровень' => $this->level, + 'Сила' => $this->printStat('strength'), + 'Ловкость' => $this->printStat('dexterity'), + 'Интуиция' => $this->printStat('intuition'), + 'Выносливость' => $this->printStat('endurance'), + 'Интеллект' => $this->printStat('intelligence'), + 'Мудрость' => $this->printStat('wisdom'), + 'Уворот' => $this->getFullStats()->evasion, + 'Точность' => $this->getFullStats()->accuracy, + 'Шанс крита' => $this->getFullStats()->criticals, + 'Урон' => $this->getFullStats()->min_physical_damage . ' - ' . $this->getFullStats()->max_physical_damage, + 'Локация' => Rooms::$roomNames[$this->room], + + ]; + $str = null; + $i = 0; + foreach ($arr as $item => $value) { + $str .= "
$item
$value
"; + if (in_array($i,[6,9])) { + $str .= "
"; + } + $i++; + } + $nameString = $this->align ? "Склонность" : ""; + $nameString .= $this->block ? "$this->login" : "$this->login"; + $nameString .= $this->clan ? "Клан" : ""; + echo "
$nameString
"; + echo "
$str
"; + } + + private function printStat($statName): string + { + return $this->getFreeStatPoints() ? $this->getStat($statName, 1) . '(' . $this->getFullStats()->$statName . ')' : $this->getFullStats()->$statName; + } + + //TODO вызывать из main.php private function UserInfoStats($isMainWindow = 0) { $captions = 'Уровень:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Местонахождение:'; @@ -62,7 +110,6 @@ class UserInfo extends UserStats parent::getFullStats()->wisdom . '
' . Rooms::$roomNames[$this->room]; if ($isMainWindow) { - $this->Bank = new Bank($this->id); $captions = 'Уровень:
Здоровье:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Опыт:
Очки характеристик:
Деньги:
Деньги в банке:'; $variables = $this->level . '
' . @@ -76,7 +123,7 @@ class UserInfo extends UserStats $this->experience . '
' . $this->free_stat_points . '
' . $this->money . '
' . - $this->Bank->getMoney(); + $this->bankMoney; } $nameString = null; $nameString .= $this->align ? "Склонность" : ""; @@ -100,16 +147,13 @@ HTML; */ private function showPrivateData(): ?string { - if (!$this->watcherIsAdmin || !$this->watcherIsModerator) { - return null; - } $birthday = date('d.m.Y', strtotime($this->borndate)); $userLogs = GameLogs::getUserLogs($this->id); $log = null; while ($userLogRow = $userLogs->fetchArray(SQLITE3_ASSOC)) { $log .= sprintf('%s
', date('d.m.Y H:i ', strtotime($userLogRow['date'])) . $userLogRow['text']); } - $adminData = $this->watcherIsAdmin ? $this->showAdminOnlyData() : null; + $adminData = $this->watcher->getAdmin() ? $this->showAdminOnlyData() : null; return << E-Mail: $this->email
@@ -129,15 +173,13 @@ INFO; */ private function showAdminOnlyData(): ?string { - $this->Bank = new Bank($this->id); - $bankMoney = $this->Bank->getMoney(); return <<id
-ИД Комнаты: $this->room
-Деньги: $this->money
-Деньги в банке: $bankMoney
-Опыт: $this->experience
-Нераспределённые очки: $this->free_stat_points
+⁑ ИД Игрока: $this->id
+⁑ ИД Комнаты: $this->room
+⁑ Деньги: $this->money
+⁑ Деньги в банке: $this->bankMoney
+⁑ Опыт: $this->experience
+⁑ Нераспределённые очки: $this->free_stat_points
INFO; } @@ -146,30 +188,27 @@ INFO; { echo ''; + $this->ttz(); + echo '
'; + echo ''; echo '
'; echo ''; - echo $this->showPrivateData(); + echo ''; + if ($this->watcher->getAdmin() || $this->watcher->getAlign() == 1) { + echo $this->showPrivateData(); + } } public function showUserInfo() { - $this->WatcherStatus(); $effects = new EffectsModel($this->id); - if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) { + if ($this->block && (!$this->watcher->getAdmin() || !$this->watcher->getAlign() == 1)) { echo "Персонаж $this->login заблокирован!"; - } elseif ($effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) { + } elseif ($effects->getHideUserInfoStatus() && (!$this->watcher->getAdmin() || !$this->watcher->getAlign() == 1)) { if ($effects->getHideUserInfoStatus() == -1) { $date = 'навсегда'; } else { @@ -181,17 +220,6 @@ INFO; } } - private function WatcherStatus() - { - $query = parent::$db->fetch('SELECT align, admin FROM users WHERE id = ?', $this->watcher_id); - if ($query['admin']) { - $this->watcherIsAdmin = 1; - } - if ($query['align'] == 1) { - $this->watcherIsModerator = 1; - } - } - public function showUserDoll($isBattle = 0, $isMain = 0) { echo '