dev-shop #51

Merged
lopar merged 24 commits from dev-shop into master 2022-01-21 15:11:54 +00:00
Showing only changes of commit 9adc63eae8 - Show all commits

View File

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