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