Из shop уехали все запросы в класс. Теперь он только отображает.
This commit is contained in:
@@ -1,220 +1,75 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Database\DBPDO;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Item;
|
||||
use Battles\Shop;
|
||||
use Battles\ShopItem;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'functions.php';
|
||||
$saleItems = false;
|
||||
$shopCategoryType = $_POST['sale'] ?? '';
|
||||
$shopCategoryTypeNumber = $_GET['otdel'] ?? 0;
|
||||
$status = null;
|
||||
Shop::$current = new Shop(Shop::GENERAL_SHOP);
|
||||
if (!empty($_GET['otdel'])) {
|
||||
if ($_GET['otdel'] !== 'sale') {
|
||||
Shop::$current->categoryType = $_GET['otdel'];
|
||||
} else {
|
||||
Shop::$current->categoryType = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['sellshop'])) {
|
||||
$status = ShopItem::sellItem($_POST['itemId'], User::$current, 1);
|
||||
ShopItem::sellItem($_POST['itemId'], User::$current, 1);
|
||||
}
|
||||
|
||||
if (!empty($_POST['buyshop'])) {
|
||||
$status = ShopItem::buyItem($_POST['itemId'], User::$current);
|
||||
}
|
||||
|
||||
$bank = new Bank(User::$current->getId());
|
||||
|
||||
switch ($shopCategoryTypeNumber) {
|
||||
default:
|
||||
$shopCategoryType = "Все товары";
|
||||
break;
|
||||
case Item::ITEM_TYPE_HELMET:
|
||||
$shopCategoryType = "Шлемы";
|
||||
break;
|
||||
case Item::ITEM_TYPE_ARMOR:
|
||||
$shopCategoryType = "Броня";
|
||||
break;
|
||||
case Item::ITEM_TYPE_LEGS:
|
||||
$shopCategoryType = "Поножи";
|
||||
break;
|
||||
case Item::ITEM_TYPE_BOOTS:
|
||||
$shopCategoryType = "Сапоги";
|
||||
break;
|
||||
case Item::ITEM_TYPE_GLOVES:
|
||||
$shopCategoryType = "Перчатки";
|
||||
break;
|
||||
case Item::ITEM_TYPE_WEAPON:
|
||||
$shopCategoryType = "Оружие";
|
||||
break;
|
||||
case Item::ITEM_TYPE_SHIELD:
|
||||
$shopCategoryType = "Щиты";
|
||||
break;
|
||||
case Item::ITEM_TYPE_BELT:
|
||||
$shopCategoryType = "Пояса";
|
||||
break;
|
||||
case Item::ITEM_TYPE_RING:
|
||||
$shopCategoryType = "Кольца";
|
||||
break;
|
||||
case Item::ITEM_TYPE_AMULET:
|
||||
$shopCategoryType = "Амулеты";
|
||||
break;
|
||||
case Item::ITEM_TYPE_CONSUMABLE:
|
||||
$shopCategoryType = "Расходники";
|
||||
break;
|
||||
case Item::ITEM_TYPE_OTHER:
|
||||
$shopCategoryType = "Разное";
|
||||
break;
|
||||
case 'sale':
|
||||
$shopCategoryType = "Предметы в инвентаре";
|
||||
$saleItems = true;
|
||||
break;
|
||||
}
|
||||
// MUST BE ARRAY!
|
||||
$iteminfo = [];
|
||||
if (!$saleItems) {
|
||||
$shopItems = DBPDO::$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');
|
||||
}
|
||||
} else {
|
||||
$inventoryItems = DBPDO::$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');
|
||||
}
|
||||
ShopItem::buyItem($_POST['itemId'], User::$current);
|
||||
}
|
||||
|
||||
Template::header('Магазин');
|
||||
?>
|
||||
<link href='/css/shop.css' rel='stylesheet'>
|
||||
<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;
|
||||
}
|
||||
|
||||
a.sell {
|
||||
background-color: #cdc;
|
||||
}
|
||||
|
||||
a.alltypes {
|
||||
background-color: #ccd;
|
||||
}
|
||||
|
||||
.status {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
</style>
|
||||
<h1>Государственный магазин</h1>
|
||||
<a href=# onclick=hrefToFrame('city.php?cp')> ← выйти на Центральную площадь</a>
|
||||
<div class="status"><?= $status ?></div>
|
||||
<div class="status"><?= ShopItem::$status ?></div>
|
||||
<table class="shop">
|
||||
<tr>
|
||||
<td>
|
||||
<h3><?= $shopCategoryType ?></h3>
|
||||
<?php if ($saleItems): ?>
|
||||
<h3><?= Shop::$current->getCategoryName() ?></h3>
|
||||
<?php if (Shop::$current->categoryType === -1): ?>
|
||||
<div>Вы можете продать ваши предметы за сущие копейки.</div>
|
||||
<?php endif; ?>
|
||||
<!--Магазин-->
|
||||
<table>
|
||||
<?php
|
||||
foreach ($iteminfo as $ii) {
|
||||
if ($ii->getItemType() != $shopCategoryTypeNumber && $shopCategoryTypeNumber != 'sale') {
|
||||
continue;
|
||||
}
|
||||
echo "<tr><td>";
|
||||
$ii->printImage();
|
||||
$ii->printControls();
|
||||
echo "<td>";
|
||||
$ii->printInfo();
|
||||
}
|
||||
?>
|
||||
<?= Shop::$current->getItemsList() ?>
|
||||
</table>
|
||||
<td>
|
||||
<strong>
|
||||
Масса всех вещей: <?= InventoryItem::getWeightData() ?> <br>
|
||||
Деньги: <?= $user->getMoney() ?> [Б:<?= $bank->getMoney() ?>].
|
||||
</strong>
|
||||
<div>
|
||||
<strong>
|
||||
Масса всех вещей: <?= InventoryItem::getWeightData() ?> <br>
|
||||
Деньги: <?= User::$current->getMoney() ?>.
|
||||
</strong>
|
||||
</div>
|
||||
<hr>
|
||||
<div>Отделы магазина</div>
|
||||
<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" href="?otdel=<?= Item::ITEM_TYPE_WEAPON ?>&rnd=<?= mt_rand() ?>">Оружие</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_HELMET ?>&rnd=<?= mt_rand() ?>">Шлемы</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_ARMOR ?>&rnd=<?= mt_rand() ?>">Броня</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_LEGS ?>&rnd=<?= mt_rand() ?>">Поножи</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_BOOTS ?>&rnd=<?= mt_rand() ?>">Сапоги</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_GLOVES ?>&rnd=<?= mt_rand() ?>">Перчатки</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_SHIELD ?>&rnd=<?= mt_rand() ?>">Щиты</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_BELT ?>&rnd=<?= mt_rand() ?>">Пояса</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_RING ?>&rnd=<?= mt_rand() ?>">Кольца</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_AMULET ?>&rnd=<?= mt_rand() ?>">Амулеты</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_CONSUMABLE ?>&rnd=<?= mt_rand() ?>">Расходники</a>
|
||||
<a class="waretype" href="?otdel=<?= Item::ITEM_TYPE_OTHER ?>&rnd=<?= mt_rand() ?>">Разное</a>
|
||||
<a class="waretype alltypes" href="?rnd=<?= mt_rand() ?>">Все товары</a>
|
||||
<a class="waretype sell" href="?otdel=sale&rnd=<?= mt_rand() ?>">Продать вещи</a>
|
||||
<div id="hint3" class="ahint"></div>
|
||||
<div>
|
||||
<small>Если у вас не хватит денег на покупку, деньги будут автоматически сняты с вашего банковского
|
||||
счёта
|
||||
с вычетом банковской комиссии за услуги.</small>
|
||||
</div>
|
||||
</table>
|
||||
Reference in New Issue
Block a user