From 9adc63eae8c47f97eea083dcefd2cc3aec60182c Mon Sep 17 00:00:00 2001 From: lopar Date: Mon, 23 Aug 2021 00:50:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D1=91=20=D0=BB=D0=BE=D0=BC=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D1=8C,=20=D0=B5=D1=81=D0=BB=D0=B8=20=D1=86?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=3D=201.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/ShopItem.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/Battles/ShopItem.php b/classes/Battles/ShopItem.php index 34250b3..253793f 100644 --- a/classes/Battles/ShopItem.php +++ b/classes/Battles/ShopItem.php @@ -156,7 +156,7 @@ class ShopItem extends Item $item = $db->ofetch('select * from inventory where item_id = ?', $id); $sellingItemName = $item->name; // Продажа за цену от нуля до половины стоимости. - $sellingPrice = mt_rand(0, $item->price / 2); + $sellingPrice = $item->price > 1 ? mt_rand(0, $item->price / 2) : mt_rand(0, 1); $db->execute('delete from inventory where item_id = ?', $id); if ($bankTrade) { $bank = new Bank($seller->getId()); @@ -180,11 +180,12 @@ class ShopItem extends Item */ private function getSellPriceMean(): ?int { - if ($this->price) { + if ($this->price > 1) { $arr = range(0, $this->price / 2); return array_sum($arr) / count($arr); + } else { + return $this->price == 1 ? 1 : null; } - return null; } /**