Зимние правки. MVC/

Signed-off-by: lopar <lopar.4ever@gmail.com>
This commit is contained in:
lopar
2022-08-09 22:57:43 +03:00
parent 0f62ee20e7
commit b9b4c01cf0
104 changed files with 2254 additions and 2086 deletions
+6 -14
View File
@@ -1,13 +1,11 @@
<?php
use Battles\Bank;
use Battles\Database\Db;
use Battles\GameLogs;
use Battles\InventoryItem;
use Battles\Template;
use Battles\User;
require_once("functions.php");
require_once 'functions.php';
const GRAV_LIMIT = 32;
const GRAV_COST = 30;
const REPAIR_STATUS = [
@@ -27,11 +25,9 @@ $gravirovka_query = null;
// Гравировка 30 кред. Максимум 32 символа.
if ($gravirovkaText && $itemId) {
if (User::getInstance()->getMoney() >= GRAV_COST) {
if (User::getInstance()->money()->spend(GRAV_COST)) {
if (iconv_strlen($gravirovkaText) <= GRAV_LIMIT) {
Db::getInstance()->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, User::getInstance()->getId(), $itemId]);
User::getInstance()->setMoney(User::getInstance()->getMoney() - GRAV_COST);
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
$status = REPAIR_STATUS['OK_GRAV_ADDED'];
} else {
$status = REPAIR_STATUS['ERROR_SIZE_LIMIT'];
@@ -42,10 +38,8 @@ if ($gravirovkaText && $itemId) {
}
// Снять гравировку.
if ($gravirovkaRemove) {
if (User::getInstance()->getMoney() >= GRAV_COST) {
if (User::getInstance()->money()->spend(GRAV_COST)) {
Db::getInstance()->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [User::getInstance()->getId(), $itemId]);
User::getInstance()->setMoney(User::getInstance()->getMoney() - GRAV_COST);
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
$status = REPAIR_STATUS['OK_GRAV_REMOVED'];
} else {
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
@@ -55,11 +49,9 @@ if ($gravirovkaRemove) {
// Пока что лимит ремонта поставлен на 25. Дальше можно обыграть.
if ($action == 'repair' && $itemId) {
$q = Db::getInstance()->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId);
if (User::getInstance()->getMoney() > ceil($q->duration / 2)) {
Db::getInstance()->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [User::getInstance()->getId(), $itemId]);
User::getInstance()->setMoney(User::getInstance()->getMoney() - ceil($q->duration / 2));
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
GameLogs::addUserLog(User::getInstance()->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.');
if (User::getInstance()->money()->spend(ceil($q->durability / 2))) {
Db::getInstance()->execute('UPDATE inventory SET durability = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND item_id = ?', [User::getInstance()->getId(), $itemId]);
GameLogs::addUserLog(User::getInstance()->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->durability / 2) . ' кр.');
$status = REPAIR_STATUS['OK_REPAIRED'];
} else {
$status = REPAIR_STATUS['ERROR_NO_MONEY'];