Рефакторинг, очистка, работа над ошибками, связанными с базой, отказ от глобальной переменной $user во многих файлах.
Singleton в некоторых местах вместо решения #42. Новые шаги для решения #16 и #52. Closes #42. Closes #32. Closes #31.
This commit is contained in:
@@ -8,25 +8,25 @@ use Battles\Template;
|
||||
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;
|
||||
Shop::id(Shop::GENERAL_SHOP)->categoryType = Shop::CATEGORY_SALE_ITEMS;
|
||||
}
|
||||
elseif ($_GET['otdel'] === 'market') {
|
||||
Shop::$current->categoryType = Shop::BARTER_SHOP;
|
||||
Shop::id(Shop::GENERAL_SHOP)->categoryType = Shop::BARTER_SHOP;
|
||||
}
|
||||
else {
|
||||
Shop::$current->categoryType = $_GET['otdel'];
|
||||
Shop::id(Shop::GENERAL_SHOP)->categoryType = $_GET['otdel'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['sellshop'])) {
|
||||
ShopItem::sellItem($_POST['itemId'], User::$current, 1);
|
||||
ShopItem::sellItem($_POST['itemId'], User::getInstance(), 1);
|
||||
}
|
||||
|
||||
if (!empty($_POST['buyshop'])) {
|
||||
ShopItem::buyItem($_POST['itemId'], User::$current);
|
||||
ShopItem::buyItem($_POST['itemId'], User::getInstance());
|
||||
}
|
||||
|
||||
if (!empty($_POST['buymarket'])) {
|
||||
@@ -42,20 +42,20 @@ Template::header('Магазин');
|
||||
<div class="status"><?= ShopItem::$status ?></div>
|
||||
<div class="row shop">
|
||||
<div class="left column">
|
||||
<h3><?= Shop::$current->getCategoryName() ?></h3>
|
||||
<h3><?= Shop::id(Shop::GENERAL_SHOP)->getCategoryName() ?></h3>
|
||||
<div>
|
||||
<?php if (Shop::$current->categoryType === -1): ?>
|
||||
<?php if (Shop::id(Shop::GENERAL_SHOP)->categoryType === -1): ?>
|
||||
Вы можете продать ваши предметы за сущие копейки.
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<!--Магазин-->
|
||||
<?= Shop::$current->getItemsList() ?>
|
||||
<?= Shop::id(Shop::GENERAL_SHOP)->getItemsList() ?>
|
||||
</div>
|
||||
<div class="right column">
|
||||
<div>
|
||||
<strong>
|
||||
Масса всех вещей: <?= InventoryItem::getWeightData() ?> <br>
|
||||
Деньги: <?= User::$current->getMoney() ?>.
|
||||
Деньги: <?= User::getInstance()->getMoney() ?>.
|
||||
</strong>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
Reference in New Issue
Block a user