2018-01-28 16:40:49 +00:00
|
|
|
|
<?php
|
2021-01-27 15:19:05 +00:00
|
|
|
|
|
2021-08-20 17:40:06 +00:00
|
|
|
|
use Battles\Bank;
|
|
|
|
|
use Battles\Item;
|
2021-01-27 15:19:05 +00:00
|
|
|
|
use Battles\ShopItem;
|
|
|
|
|
use Battles\Template;
|
|
|
|
|
|
2018-01-28 16:40:49 +00:00
|
|
|
|
ob_start();
|
|
|
|
|
session_start();
|
2019-01-15 15:56:15 +00:00
|
|
|
|
require_once 'functions.php';
|
2018-06-23 18:08:07 +00:00
|
|
|
|
$saleItems = false;
|
2020-09-29 22:39:06 +00:00
|
|
|
|
$shopCategoryType = $_POST['sale'] ?? '';
|
|
|
|
|
$shopCategoryTypeNumber = $_GET['otdel'] ?? 0;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$status = null;
|
|
|
|
|
|
|
|
|
|
if (!empty($_POST['sellshop'])) {
|
|
|
|
|
$status = ShopItem::sellItem($_POST['itemId'], $user, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($_POST['buyshop'])) {
|
|
|
|
|
$status = ShopItem::buyItem($_POST['itemId'], $user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$bank = new Bank($user->getId());
|
|
|
|
|
|
2019-01-14 20:37:35 +00:00
|
|
|
|
switch ($shopCategoryTypeNumber) {
|
|
|
|
|
default:
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$shopCategoryType = "Все товары";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_HELMET:
|
|
|
|
|
$shopCategoryType = "Шлемы";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_ARMOR:
|
|
|
|
|
$shopCategoryType = "Броня";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_LEGS:
|
|
|
|
|
$shopCategoryType = "Поножи";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_BOOTS:
|
2019-01-14 20:37:35 +00:00
|
|
|
|
$shopCategoryType = "Сапоги";
|
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_GLOVES:
|
2019-01-14 20:37:35 +00:00
|
|
|
|
$shopCategoryType = "Перчатки";
|
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_WEAPON:
|
|
|
|
|
$shopCategoryType = "Оружие";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_SHIELD:
|
2019-01-14 20:37:35 +00:00
|
|
|
|
$shopCategoryType = "Щиты";
|
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_BELT:
|
|
|
|
|
$shopCategoryType = "Пояса";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_RING:
|
2019-01-14 20:37:35 +00:00
|
|
|
|
$shopCategoryType = "Кольца";
|
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_AMULET:
|
|
|
|
|
$shopCategoryType = "Амулеты";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_CONSUMABLE:
|
|
|
|
|
$shopCategoryType = "Расходники";
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
case Item::ITEM_TYPE_OTHER:
|
|
|
|
|
$shopCategoryType = "Разное";
|
|
|
|
|
break;
|
|
|
|
|
case 'sale':
|
|
|
|
|
$shopCategoryType = "Предметы в инвентаре";
|
|
|
|
|
$saleItems = true;
|
2019-01-14 20:37:35 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-08-20 17:40:06 +00:00
|
|
|
|
// MUST BE ARRAY!
|
|
|
|
|
$iteminfo = [];
|
2020-09-30 19:12:34 +00:00
|
|
|
|
if (!$saleItems) {
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$shopItems = $db->ofetchAll("select * from items inner join trade_offers on id = shop_item_id where shop_id = 1 and shop_item_quantity !=0");
|
|
|
|
|
foreach ($shopItems as $shopItemObject) {
|
|
|
|
|
$iteminfo[] = new ShopItem($shopItemObject, 'buyshop');
|
2018-01-28 16:40:49 +00:00
|
|
|
|
}
|
2019-01-14 20:28:47 +00:00
|
|
|
|
} else {
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$inventoryItems = $db->ofetchall("select * from inventory where on_sale = 0 and dressed_slot = 0 and durability > 0 and owner_id = ?", $user->getId());
|
|
|
|
|
foreach ($inventoryItems as $inventoryItemObject) {
|
|
|
|
|
$iteminfo[] = new ShopItem($inventoryItemObject, 'sellshop');
|
2018-01-28 16:40:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 15:19:05 +00:00
|
|
|
|
Template::header('Магазин');
|
2018-01-28 16:40:49 +00:00
|
|
|
|
?>
|
2021-08-20 17:40:06 +00:00
|
|
|
|
<script src="js/main.js"></script>
|
|
|
|
|
<style>
|
|
|
|
|
a.waretype {
|
|
|
|
|
margin: 2px 16px;
|
|
|
|
|
padding: 6px;
|
|
|
|
|
border: 1px silver solid;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
background-color: #ccc;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2021-08-22 18:58:28 +00:00
|
|
|
|
|
2021-08-20 17:40:06 +00:00
|
|
|
|
a.sell {
|
|
|
|
|
background-color: #cdc;
|
|
|
|
|
}
|
2021-08-22 18:58:28 +00:00
|
|
|
|
|
2021-08-20 17:40:06 +00:00
|
|
|
|
a.alltypes {
|
|
|
|
|
background-color: #ccd;
|
|
|
|
|
}
|
2021-08-22 18:58:28 +00:00
|
|
|
|
|
2021-08-20 17:40:06 +00:00
|
|
|
|
.status {
|
2021-08-22 18:58:28 +00:00
|
|
|
|
color: darkgreen;
|
|
|
|
|
background: #afa;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop {
|
|
|
|
|
width: 100%;
|
|
|
|
|
border-collapse: collapse;
|
|
|
|
|
border-spacing: 0;
|
|
|
|
|
padding: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop > tbody > tr > td {
|
|
|
|
|
vertical-align: top;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop > tbody > tr > td:nth-child(1) {
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop > tbody > tr > td:nth-child(2) {
|
|
|
|
|
width: 280px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop table {
|
|
|
|
|
width: 100%;
|
|
|
|
|
border-collapse: separate;
|
|
|
|
|
border-spacing: 1px;
|
|
|
|
|
padding: 2px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop table tr {
|
|
|
|
|
background-color: #C7C7C7;
|
2021-08-20 17:40:06 +00:00
|
|
|
|
}
|
2021-08-22 18:58:28 +00:00
|
|
|
|
|
|
|
|
|
table.shop table td {
|
|
|
|
|
padding: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop table tr:nth-child(even) {
|
|
|
|
|
background-color: #D5D5D5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop table td:nth-child(1) {
|
|
|
|
|
width: 150px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop table td:nth-child(2) {
|
|
|
|
|
vertical-align: top;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h3 + div {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table.shop strong span:last-child {
|
|
|
|
|
color: darkgreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hr + div {
|
|
|
|
|
text-align: center;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-20 17:40:06 +00:00
|
|
|
|
</style>
|
2018-06-22 23:00:48 +00:00
|
|
|
|
<h1>Государственный магазин</h1>
|
2019-01-15 19:34:35 +00:00
|
|
|
|
<a href=# onclick=hrefToFrame('city.php?cp')> ← выйти на Центральную площадь</a>
|
2021-08-20 17:40:06 +00:00
|
|
|
|
<div class="status"><?= $status ?></div>
|
2021-08-22 18:58:28 +00:00
|
|
|
|
<table class="shop">
|
2021-08-20 17:40:06 +00:00
|
|
|
|
<tr>
|
2021-08-22 18:58:28 +00:00
|
|
|
|
<td>
|
2019-01-15 15:56:15 +00:00
|
|
|
|
<h3><?= $shopCategoryType ?></h3>
|
|
|
|
|
<?php if ($saleItems): ?>
|
2021-08-22 18:58:28 +00:00
|
|
|
|
<div>Вы можете продать ваши предметы за сущие копейки.</div>
|
2019-01-15 15:56:15 +00:00
|
|
|
|
<?php endif; ?>
|
2018-06-22 23:00:48 +00:00
|
|
|
|
<!--Магазин-->
|
2021-08-22 18:58:28 +00:00
|
|
|
|
<table>
|
2019-01-15 15:56:15 +00:00
|
|
|
|
<?php
|
2021-08-20 17:40:06 +00:00
|
|
|
|
foreach ($iteminfo as $ii) {
|
|
|
|
|
if ($ii->getItemType() != $shopCategoryTypeNumber && $shopCategoryTypeNumber != 'sale') {
|
|
|
|
|
continue;
|
2019-01-15 15:56:15 +00:00
|
|
|
|
}
|
2021-08-22 18:58:28 +00:00
|
|
|
|
echo "<tr><td>";
|
|
|
|
|
$ii->printImage();
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$ii->printControls();
|
2021-08-22 18:58:28 +00:00
|
|
|
|
echo "<td>";
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$ii->printInfo();
|
2019-01-15 15:56:15 +00:00
|
|
|
|
}
|
|
|
|
|
?>
|
2021-08-20 17:40:06 +00:00
|
|
|
|
</table>
|
2021-08-22 18:58:28 +00:00
|
|
|
|
<td>
|
2021-08-20 17:40:06 +00:00
|
|
|
|
<strong>
|
2021-08-22 20:43:42 +00:00
|
|
|
|
Масса всех вещей: <?= getItemsMassaInfo() ?> <br>
|
|
|
|
|
Деньги: <?= $user->getMoney() ?> [Б:<?= $bank->getMoney() ?>].
|
2021-08-20 17:40:06 +00:00
|
|
|
|
</strong>
|
2018-06-22 23:00:48 +00:00
|
|
|
|
<hr>
|
2021-08-22 18:58:28 +00:00
|
|
|
|
<div>Отделы магазина</div>
|
2021-08-20 17:40:06 +00:00
|
|
|
|
<a class="waretype" href="?otdel=6&rnd=<?= mt_rand() ?>">Оружие</a>
|
|
|
|
|
<a class="waretype" href="?otdel=1&rnd=<?= mt_rand() ?>">Шлемы</a>
|
|
|
|
|
<a class="waretype" href="?otdel=2&rnd=<?= mt_rand() ?>">Броня</a>
|
|
|
|
|
<a class="waretype" href="?otdel=3&rnd=<?= mt_rand() ?>">Поножи</a>
|
|
|
|
|
<a class="waretype" href="?otdel=4&rnd=<?= mt_rand() ?>">Сапоги</a>
|
|
|
|
|
<a class="waretype" href="?otdel=5&rnd=<?= mt_rand() ?>">Перчатки</a>
|
|
|
|
|
<a class="waretype" href="?otdel=7&rnd=<?= mt_rand() ?>">Щиты</a>
|
|
|
|
|
<a class="waretype" href="?otdel=8&rnd=<?= mt_rand() ?>">Пояса</a>
|
|
|
|
|
<a class="waretype" href="?otdel=9&rnd=<?= mt_rand() ?>">Кольца</a>
|
|
|
|
|
<a class="waretype" href="?otdel=10&rnd=<?= mt_rand() ?>">Амулеты</a>
|
|
|
|
|
<a class="waretype" href="?otdel=20&rnd=<?= mt_rand() ?>">Расходники</a>
|
|
|
|
|
<a class="waretype" href="?otdel=50&rnd=<?= mt_rand() ?>">Разное</a>
|
|
|
|
|
<a class="waretype alltypes" href="?rnd=<?= mt_rand() ?>">Все товары</a>
|
|
|
|
|
<a class="waretype sell" href="?otdel=sale&rnd=<?= mt_rand() ?>">Продать вещи</a>
|
2018-06-22 23:00:48 +00:00
|
|
|
|
<div id="hint3" class="ahint"></div>
|
2021-08-20 17:40:06 +00:00
|
|
|
|
</table>
|