Рабочий ремонт.

This commit is contained in:
Igor Barkov [iwork] 2018-12-12 18:09:39 +02:00
parent 61bb18dfb9
commit f51e166604
2 changed files with 20 additions and 27 deletions

View File

@ -2866,7 +2866,6 @@ function SolveExp($at_id, $def_id, $damage)
* @param int $user_id - ID пользователя которому добавляется запись.
* @param int $type - тип записи: (1)обычная, (2)модераторская.
* @return bool
* @throws \Krugozor\Database\Mysql\Exception
*/
function addToDelo($message, $user_id = 0, $type = 1)
{
@ -2880,7 +2879,6 @@ function addToDelo($message, $user_id = 0, $type = 1)
* @param $name - техническое имя параметра, как в базе.
* @param null $param - выбор что повышать.
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
function addOnePoint($name, $param = null)
{

View File

@ -12,7 +12,7 @@ if ($user['battle'] != 0) {
die();
}
// Гравировка
// Гравировка 30 кред.
if (input::post('set') && input::post('count') && ($user['money'] >= 30)) {
if (db::c()->query('UPDATE `inventory` SET `text` = "?s" WHERE `dressed` = 0 AND `setsale` = 0 AND `owner` = ?i AND `id` = ?i', input::post('count'), $_SESSION['uid'], input::post('set')))
db::c()->query('UPDATE `users` SET `money` = `money` - 30 WHERE `id` = ?i', $_SESSION['uid']);
@ -23,27 +23,15 @@ if ($_GET['rep'] && ($_GET['sid'] == 2)) {
mysql_query("UPDATE `inventory` SET `text` = '' WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '" . (int)$_GET['rep'] . "' LIMIT 1");
}
// Ремонт
if ($_GET['sid'] && $_GET['rep']) {
$row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '{$_GET['rep']}' AND `setsale`=0 LIMIT 1;"));
$full = $row['duration'];
if ($row['duration'] > 1) {
$onecost = 0.1;
if (round($onecost * $full) <= $user['money']) {
if (mysql_query("UPDATE `inventory` SET `duration` = '0' WHERE `id` = {$_GET['rep']}")) {
$err = "<font color=red><b>Произведен ремонт предмета \"{$row['name']}\" за " . (round($onecost, 2) * $full) . " кр. </b></font>";
mysql_query("UPDATE `users` set `money` = `money`- '" . (round($onecost, 2) * $full) . "' WHERE id = {$user['id']}");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','Отремонтирован предмет \"" . $row['name'] . "\" id:(cap" . $row['id'] . ") [0/" . $row['maxdur'] . "] у \"" . $user['login'] . "\" за " . (round($onecost, 2) * $full) . " кр. ',1,'" . time() . "');");
$user['money'] = $user['money'] - (round($onecost, 2) * $full);
if (rand(1, 5) == 1) {
$err .= "<font color=red><b>К сожалению максимальная долговечность предмета из-за ремонта уменьшилась.</b></font>";
mysql_query("UPDATE `inventory` SET `maxdur` = `maxdur`-1 WHERE `id` = {$_GET['rep']}");
}
}
} else {
$err = "<font color=red><b>Недостаточно денег.</b></font>";
}
}
// Ремонт 0,5 кред за единицу.
if (input::post('action') == 'repair') {
$q = db::c()->query('SELECT `name`, `duration` FROM `inventory` WHERE id = ?i', input::post('itemId'))->fetch_assoc();
if (ceil($q['duration'] / 2) < $user['money']) {
db::c()->query('UPDATE `inventory` SET `maxdur` = `maxdur` - 1, `duration` = 0 WHERE `id` = ?i AND `owner` = ?i', input::post('itemId'), $_SESSION['uid']);
db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', ceil($q['duration'] / 2), $_SESSION['uid']);
addToDelo('Отремонтирован предмет «' . $q['name'] . '» id:(' . input::post('itemId') . ') за ' . ceil($q['duration'] / 2) . ' кр.');
$status = 'Предмет отремонтирован!';
} else $status = 'Недостаточно денег!';
}
// Перезарядка магии
@ -308,7 +296,8 @@ if (input::post('goto') == 'gravirovka') {
<input type="hidden" name="goto" value="remont">
<input type="submit" value="Войти">
</form>
<span class="wrap">Починка поврежденных предметов.</span>
<span class="wrap">Починка поврежденных предметов. Починка дело непростое: в процессе ремонта состояние предмета
уменьшится на единицу!</span>
</div>
<div class="appblock">
<span class="legend">Зал гравировки</span>
@ -355,10 +344,16 @@ if (input::post('goto') == 'gravirovka') {
while ($row = $remont_query->fetch_assoc()): ?>
<div class="appblock">
<span class="legend"><?= $row['name'] ?></span>
<span class="wrap">Состояние предмета<span class="num"><?= $row['duration'] ?>/<?= $row['maxdur'] ?></span></span>
<span class="wrap">Стоимость ремонта<span class="num"><?= ceil($row['duration'] / 2) ?></span></span>
<div style="text-align: center">
[<?= $row['duration'] ?>/<?= $row['maxdur'] ?>]
<br><img src="i/sh/<?= $row['img'] ?>">
<br><a href="?rep=<?= $row['id'] ?>&sid=full">Ремонт за <?= $row['duration'] ?> кр.</a>
<br><a href="?rep=<?= $row['id'] ?>&sid=full">Ремонт</a>
<form method="post">
<input type="hidden" name="itemId" value="<?= $row['id'] ?>">
<input type="hidden" name="action" value="repair">
<input type="submit" value="Ремонт">
</form>
</div>
</div>
<?php endwhile; endif; ?>