new selling price generation algorytm

This commit is contained in:
lopar
2019-01-14 22:28:47 +02:00
parent c6f86632ef
commit 0bd9308d01
2 changed files with 63 additions and 55 deletions
+8 -3
View File
@@ -20,10 +20,15 @@ class ShopItem extends Item
/**
* Для кнопок управления под картинкой прелмета в зависимости от ситуации.
*/
public function printControls()
public function printControls($sell = false)
{
$btnPrice = "Купить за " . intval($this->cost) . " кр.";
$btnLink = "/shop.php?buy={$this->id}&rnd=".mt_rand();
if ($sell) {
$btnPrice = "Продать";
$btnLink = "/shop.php?sell={$this->id}&rnd=".mt_rand();
} else {
$btnPrice = "Купить за " . intval($this->cost) . " кр.";
$btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand();
}
echo <<<BTN
<p><input type="button" style="background: darkgrey; border: 1px solid grey; border-radius: 2px;" value="{$btnPrice}"
onclick="location='{$btnLink}'">