Зачем-то инкапсуляция...

This commit is contained in:
Igor Barkov (iwork)
2021-02-01 18:42:52 +02:00
parent 8d0bce6299
commit 7dd6368b84
23 changed files with 867 additions and 236 deletions
+15 -15
View File
@@ -29,11 +29,11 @@ $gravirovka_query = null;
// Гравировка 30 кред. Максимум 32 символа.
if ($gravirovkaText && $itemId) {
if ($user->money >= GRAV_COST) {
if ($user->getMoney() >= GRAV_COST) {
if (iconv_strlen($gravirovkaText) <= GRAV_LIMIT) {
$db->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, $user->id, $itemId]);
$user->money -= GRAV_COST;
Bank::setWalletMoney($user->money, $user->id);
$db->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, $user->getId(), $itemId]);
$user->setMoney($user->getMoney() - GRAV_COST);
Bank::setWalletMoney($user->getMoney(), $user->getId());
$status = REPAIR_STATUS['OK_GRAV_ADDED'];
} else {
$status = REPAIR_STATUS['ERROR_SIZE_LIMIT'];
@@ -44,10 +44,10 @@ if ($gravirovkaText && $itemId) {
}
// Снять гравировку.
if ($gravirovkaRemove) {
if ($user->money >= GRAV_COST) {
$db->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->id, $itemId]);
$user->money -= GRAV_COST;
Bank::setWalletMoney($user->money, $user->id);
if ($user->getMoney() >= GRAV_COST) {
$db->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]);
$user->setMoney($user->getMoney() - GRAV_COST);
Bank::setWalletMoney($user->getMoney(), $user->getId());
$status = REPAIR_STATUS['OK_GRAV_REMOVED'];
} else {
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
@@ -57,21 +57,21 @@ if ($gravirovkaRemove) {
// Пока что лимит ремонта поставлен на 25. Дальше можно обыграть.
if ($action == 'repair' && $itemId) {
$q = $db->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId);
if ($user->money > ceil($q->duration / 2)) {
$db->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->id, $itemId]);
$user->money -= ceil($q->duration / 2);
Bank::setWalletMoney($user->money, $user->id);
GameLogs::addUserLog($user->id, 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.');
if ($user->getMoney() > ceil($q->duration / 2)) {
$db->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]);
$user->setMoney($user->getMoney() - ceil($q->duration / 2));
Bank::setWalletMoney($user->getMoney(), $user->getId());
GameLogs::addUserLog($user->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.');
$status = REPAIR_STATUS['OK_REPAIRED'];
} else {
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
}
}
if ($goto == 'remont') {
$remont_query = $db->ofetchAll('SELECT item_id, name, image, durability FROM inventory WHERE item_type < 12 AND dressed_slot = 0 AND on_sale = 0 AND durability < 25 AND owner_id = ? ORDER BY name', $user->id);
$remont_query = $db->ofetchAll('SELECT item_id, name, image, durability FROM inventory WHERE item_type < 12 AND dressed_slot = 0 AND on_sale = 0 AND durability < 25 AND owner_id = ? ORDER BY name', $user->getId());
}
if ($goto == 'gravirovka') {
$gravirovka_query = $db->ofetchAll('SELECT item_id, name, image, text FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND item_type = 3 AND name NOT LIKE "%Букет%" AND on_sale = 0 OR text IS NOT NULL AND owner_id = ? AND dressed_slot = 0 AND on_sale = 0 ORDER BY name', [$user->id, $user->id]);
$gravirovka_query = $db->ofetchAll('SELECT item_id, name, image, text FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND item_type = 3 AND name NOT LIKE "%Букет%" AND on_sale = 0 OR text IS NOT NULL AND owner_id = ? AND dressed_slot = 0 AND on_sale = 0 ORDER BY name', [$user->getId(), $user->getId()]);
}
Template::header('Кузня');
?>