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