battles/shop.php

84 lines
3.8 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
use Battles\InventoryItem;
use Battles\Item;
use Battles\Shop;
use Battles\ShopItem;
use Battles\Template;
2021-08-26 16:15:47 +00:00
use Battles\User;
require_once 'functions.php';
Shop::$current = new Shop(Shop::GENERAL_SHOP);
if (!empty($_GET['otdel'])) {
if ($_GET['otdel'] === 'sale') {
Shop::$current->categoryType = Shop::CATEGORY_SALE_ITEMS;
}
elseif ($_GET['otdel'] === 'market') {
Shop::$current->categoryType = Shop::BARTER_SHOP;
}
else {
Shop::$current->categoryType = $_GET['otdel'];
}
}
if (!empty($_POST['sellshop'])) {
ShopItem::sellItem($_POST['itemId'], User::$current, 1);
}
if (!empty($_POST['buyshop'])) {
ShopItem::buyItem($_POST['itemId'], User::$current);
2018-01-28 16:40:49 +00:00
}
if (!empty($_POST['buymarket'])) {
ShopItem::$status = 'попытка купить с рук предмет id: ' . $_POST['itemId'];
}
Template::header('Магазин');
2018-01-28 16:40:49 +00:00
?>
<link href='/css/shop.css' rel='stylesheet'>
<script src="js/main.js"></script>
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>
<div class="status"><?= ShopItem::$status ?></div>
<div class="row shop">
<div class="left column">
<h3><?= Shop::$current->getCategoryName() ?></h3>
<div>
<?php if (Shop::$current->categoryType === -1): ?>
Вы можете продать ваши предметы за сущие копейки.
<?php endif; ?>
</div>
<!--Магазин-->
<?= Shop::$current->getItemsList() ?>
</div>
<div class="right column">
<div>
<strong>
Масса всех вещей: <?= InventoryItem::getWeightData() ?> <br>
Деньги: <?= User::$current->getMoney() ?>.
</strong>
</div>
<hr>
<div>Отделы магазина</div>
<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>
</div>
</div>