'Гравировка добавлена!', 'OK_GRAV_REMOVED' => 'Гравировка удалена!', 'OK_REPAIRED' => 'Предмет отремонтирован!', 'ERROR_SIZE_LIMIT' => 'Превышен лимит в ' . GRAV_LIMIT . ' символа!', 'ERROR_NO_MONEY' => 'Недостаточно денег!', ]); $gravirovkaText = $_POST['gravirovka_text'] ?? null; $itemId = $_POST['itemId'] ?? null; $gravirovkaRemove = $_POST['gravirovka_remove'] ?? null; $action = $_POST['action'] ?? null; $goto = $_POST['goto'] ?? null; $remont_query = null; $gravirovka_query = null; // Гравировка 30 кред. Максимум 32 символа. if ($gravirovkaText && $itemId) { 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->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']; } } else { $status = REPAIR_STATUS['ERROR_NO_MONEY']; } } // Снять гравировку. if ($gravirovkaRemove) { 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']; } } // Ремонт 0,5 кред за единицу. // Пока что лимит ремонта поставлен на 25. Дальше можно обыграть. if ($action == 'repair' && $itemId) { $q = $db->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId); 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->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->getId(), $user->getId()]); } Template::header('Кузня'); ?>