battles/classes/ShopItem.php

77 lines
4.0 KiB
PHP
Raw Normal View History

2019-01-11 20:26:10 +00:00
<?php
class ShopItem extends Item
{
public function printInfo()
{
parent::printBaseInfo();
parent::printRequirements();
parent::printBonuses();
}
public function buyItem($owner)
{
if ($owner) {
db::c()->query('
INSERT INTO `inventory` (`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`,
`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,
`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,
`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,
`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,
`artefact`, `koll`) VALUES (?i,?i,"?s",?i,?i,?i,"?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,
?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,"?s",?i,?i)
2019-02-15 12:16:40 +00:00
', $this->id, $owner, $this->name, $this->type, $this->massa, $this->cost, $this->img, $this->maxdur, $this->isrep, $this->gsila, $this->glovk, $this->ginta, $this->gintel,
$this->ghp, $this->gnoj, $this->gtopor, $this->gdubina, $this->gmech, $this->gfire, $this->gwater, $this->gair, $this->gearth, $this->glight, $this->ggray, $this->gdark,
$this->needident, $this->nsila, $this->nlovk, $this->ninta, $this->nintel, $this->nmudra, $this->nvinos, $this->nnoj, $this->ntopor, $this->ndubina, $this->nmech,
$this->nfire, $this->nwater, $this->nair, $this->nearth, $this->nlight, $this->ngray, $this->ndark, $this->mfkrit, $this->mfakrit, $this->mfuvorot, $this->mfauvorot,
$this->bron1, $this->bron2, $this->bron3, $this->bron4, $this->maxu, $this->minu, $this->magic, $this->nlevel, $this->nalign, $this->dategoden, $this->goden, $this->razdel,
$this->artefact, $this->koll);
}
}
2019-01-11 20:26:10 +00:00
/**
* Для кнопок управления под картинкой прелмета в зависимости от ситуации.
*/
public function printControls($shopType = false)
2019-01-11 20:26:10 +00:00
{
2019-02-15 15:00:01 +00:00
if ($shopType === 'marketput') {
echo <<<BTN
<form method="post">
2019-02-15 15:25:53 +00:00
<input placeholder="{$this->cost}" name="cost">
2019-02-15 15:00:01 +00:00
<input type="hidden" name="putId" value="{$this->id}">
<br><input type="submit" name="putToMarket" value="ать в магазин">
</form>
BTN;
2019-02-15 15:00:01 +00:00
} else {
switch ($shopType) {
default:
$btnValue = "Купить за " . intval($this->cost) . " кр.";
$btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand();
break;
case 'ashop':
$btnValue = "Купить за " . intval($this->ecost) . "р.";
$btnLink = "/ashop.php?buy={$this->id}&rnd=" . mt_rand();
break;
case 'sell':
$btnValue = "Продать";
$btnLink = "/shop.php?sell={$this->id}&rnd=" . mt_rand();
break;
case 'marketgetback':
$btnValue = "Снять с продажи";
$btnLink = "?back={$this->id}&rnd=" . mt_rand();
break;
2019-02-15 16:39:47 +00:00
case 'marketbuy':
2019-02-15 17:02:03 +00:00
$btnValue = "Купить за " . intval($this->setsale) . " кр.";
2019-02-15 15:00:01 +00:00
$btnLink = "?otdel={$this->otdel}&set={$this->id}&rnd=" . mt_rand();
break;
}
echo <<<BTN
2019-01-16 20:20:47 +00:00
<p><input type="button" style="background: darkgrey; border: 1px solid grey; border-radius: 2px;" value="{$btnValue}"
2019-01-14 16:42:45 +00:00
onclick="location='{$btnLink}'">
2019-01-11 20:26:10 +00:00
BTN;
2019-02-15 15:00:01 +00:00
if ($this->count > 0) echo "<br><small>В наличии: {$this->count} штук</small>";
}
2019-01-11 20:26:10 +00:00
}
}