Новые требования php7.4 и мелкие баги отрисовки.
This commit is contained in:
parent
5714ab83f3
commit
326d93f259
@ -1,31 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Battles;
|
||||
class Item
|
||||
{
|
||||
protected $item_id;
|
||||
protected $name;
|
||||
protected $item_type;
|
||||
protected $durability;
|
||||
protected $need_strength;
|
||||
protected $need_dexterity;
|
||||
protected $need_intuition;
|
||||
protected $need_endurance;
|
||||
protected $need_intelligence;
|
||||
protected $need_wisdom;
|
||||
protected $add_strength;
|
||||
protected $add_dexterity;
|
||||
protected $add_intuition;
|
||||
protected $add_endurance;
|
||||
protected $add_intelligence;
|
||||
protected $add_wisdom;
|
||||
protected $add_accuracy;
|
||||
protected $add_evasion;
|
||||
protected $add_criticals;
|
||||
protected $add_min_physical_damage;
|
||||
protected $add_max_physical_damage;
|
||||
protected $weight;
|
||||
protected $image;
|
||||
public const ITEM_TYPES_ALLOWED_IN_SLOTS = [1,2,3,4,5,6,7,8,9,10,11,12];
|
||||
protected int $item_id;
|
||||
protected string $name = '';
|
||||
protected int $item_type = self::ITEM_TYPE_TRASH;
|
||||
protected int $durability = 0;
|
||||
protected int $need_strength = 0;
|
||||
protected int $need_dexterity = 0;
|
||||
protected int $need_intuition = 0;
|
||||
protected int $need_endurance = 0;
|
||||
protected int $need_intelligence = 0;
|
||||
protected int $need_wisdom = 0;
|
||||
protected int $add_strength = 0;
|
||||
protected int $add_dexterity = 0;
|
||||
protected int $add_intuition = 0;
|
||||
protected int $add_endurance = 0;
|
||||
protected int $add_intelligence = 0;
|
||||
protected int $add_wisdom = 0;
|
||||
protected int $add_accuracy = 0;
|
||||
protected int $add_evasion = 0;
|
||||
protected int $add_criticals = 0;
|
||||
protected int $add_min_physical_damage = 0;
|
||||
protected int $add_max_physical_damage = 0;
|
||||
protected int $weight = 0;
|
||||
protected string $image = '';
|
||||
protected int $item_cost = 0;
|
||||
public const ITEM_TYPES_ALLOWED_IN_SLOTS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
public const ITEM_TYPE_HELMET = 1;
|
||||
public const ITEM_TYPE_ARMOR = 2;
|
||||
public const ITEM_TYPE_LEGS = 3;
|
||||
@ -39,7 +41,7 @@ class Item
|
||||
public const ITEM_TYPE_CONSUMABLE = 20;
|
||||
public const ITEM_TYPE_OTHER = 50;
|
||||
public const ITEM_TYPE_TRASH = 100;
|
||||
private $typename;
|
||||
private string $typename;
|
||||
|
||||
/**
|
||||
* Item constructor.
|
||||
@ -101,7 +103,7 @@ class Item
|
||||
}
|
||||
}
|
||||
|
||||
protected function wrap(int $number):string
|
||||
protected function wrap(int $number): string
|
||||
{
|
||||
if ($number > 0) {
|
||||
return ": <b>" . $number . "</b>";
|
||||
@ -114,11 +116,11 @@ class Item
|
||||
{
|
||||
$needsLines = [
|
||||
"сила" => $this->need_strength,
|
||||
"ловкость" =>$this->need_dexterity,
|
||||
"интуиция" =>$this->need_intuition,
|
||||
"выносливость" =>$this->need_endurance,
|
||||
"интеллект" =>$this->need_intelligence,
|
||||
"мудрость" =>$this->need_wisdom,
|
||||
"ловкость" => $this->need_dexterity,
|
||||
"интуиция" => $this->need_intuition,
|
||||
"выносливость" => $this->need_endurance,
|
||||
"интеллект" => $this->need_intelligence,
|
||||
"мудрость" => $this->need_wisdom,
|
||||
];
|
||||
$addsLines = [
|
||||
"Сила" => $this->add_strength,
|
||||
|
@ -92,12 +92,12 @@ class ShopItem extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public function printImage(): string
|
||||
public function printImage()
|
||||
{
|
||||
if (!$this->image) {
|
||||
$this->image = 'noitem.png';
|
||||
}
|
||||
return "<img src='/i/sh/$this->image' class='item-wrap-normal' alt=''>";
|
||||
echo "<img src='/i/sh/$this->image' class='item-wrap-normal' alt=''>";
|
||||
}
|
||||
|
||||
public static function buyItem($id, User $buyer): string
|
||||
@ -142,15 +142,6 @@ class ShopItem extends Item
|
||||
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();
|
||||
@ -162,7 +153,7 @@ class ShopItem extends Item
|
||||
if ($bankTrade) {
|
||||
$bank = new Bank($seller->getId());
|
||||
$bank->setMoney($bank->getMoney() + $sellingPrice);
|
||||
Bank::setBankMoney($bank->getMoney(), $seller->getId(), 'shopsell');
|
||||
Bank::setBankMoney($bank->getMoney(), $seller->getId(), 'sellShop');
|
||||
} else {
|
||||
$db->execute('update users set money = money - ? where id = ?', [$sellingPrice, $_SESSION['uid']]);
|
||||
}
|
||||
@ -183,7 +174,7 @@ class ShopItem extends Item
|
||||
{
|
||||
if ($this->price) {
|
||||
$arr = range(0, $this->price / 2);
|
||||
return array_sum($arr) / sizeof($arr);
|
||||
return array_sum($arr) / count($arr);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class UserStats extends User
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStat($stat_name, $isMainWindow = 0): string
|
||||
public function getStat($stat_name, int $isMainWindow = 0): string
|
||||
{
|
||||
if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) {
|
||||
return self::ERROR_STAT_UNKNOWN;
|
||||
|
Loading…
Reference in New Issue
Block a user