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; } /**