Частичный ремонт это несерьёзно.

This commit is contained in:
Igor Barkov [iwork] 2018-12-12 15:26:18 +02:00
parent a775c808d9
commit 7c636c0e3f
1 changed files with 24 additions and 76 deletions

View File

@ -18,80 +18,33 @@ if (input::post('set') && input::post('count') && ($user['money'] >= 30)) {
db::c()->query('UPDATE `users` SET `money` = `money` - 30 WHERE `id` = ?i', $_SESSION['uid']);
}
// Снять гравировку
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']) {
switch ($_GET['sid']) {
case 1:
$row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `type` < 12 AND `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '" . (int)$_GET['rep'] . "' LIMIT 1"));
if ($row['duration'] > 0) {
$onecost = 0.1;
if ($onecost <= $user['money']) {
if (mysql_query("UPDATE `inventory` SET `duration` = `duration`-1 WHERE `id` = '" . (int)$_GET['rep'] . "' LIMIT 1")) {
$err = "<font color=red><b>Произведен ремонт предмета \"{$row['name']}\" за " . round($onecost, 2) . " кр. </b></font>";
$user['money'] -= round($onecost, 2);
mysql_query("UPDATE `users` SET `money` = '" . $user['money'] . "' WHERE `id` = {$user['id']} LIMIT 1");
$newduration = $row['duration'] - 1;
mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '{$user['id']}', 'Отремонтирован предмет \"" . $row['name'] . "\" id:(cap" . $row['id'] . ") [" . $newduration . "/" . $row['maxdur'] . "] у \"" . $user['login'] . "\" за " . round($onecost, 2) . " кр. ',1,'" . time() . "')");
if (rand(1, 10) == 1) {
$err .= "<font color=red><b>К сожалению максимальная долговечность предмета из-за ремонта уменьшилась.</b></font>";
mysql_query("UPDATE `inventory` SET `maxdur` = `maxdur`-1 WHERE `id` = '" . (int)$_GET['rep'] . "' LIMIT 1");
}
}
} else {
$err = "<font color=red><b>Недостаточно денег.</b></font>";
$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=$row['cost']/($row['maxdur']*10);
//if($onecost < 0.1) {$onecost=0.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']}");
}
}
break;
case 10:
$row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '{$_GET['rep']}' LIMIT 1;"));
if ($row['duration'] >= 10) {
//$onecost=$row['cost']/($row['maxdur']*10);
//if($onecost < 0.1) {$onecost=0.1;}
$onecost = 0.1;
if (($onecost * 10) <= $user['money']) {
if (mysql_query("UPDATE `inventory` SET `duration` = `duration`-10 WHERE `id` = {$_GET['rep']}")) {
$err = "<font color=red><b>Произведен ремонт предмета \"{$row['name']}\" за " . (round($onecost, 2) * 10) . " кр. </b></font>";
mysql_query("UPDATE `users` set `money` = `money`- '" . (round($onecost, 2) * 10) . "' WHERE id = {$user['id']}");
$newduration = $row['duration'] - 10;
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','Отремонтирован предмет \"" . $row['name'] . "\" id:(cap" . $row['id'] . ") [" . $newduration . "/" . $row['maxdur'] . "] у \"" . $user['login'] . "\" за " . (round($onecost, 2) * 10) . " кр. ',1,'" . time() . "');");
$user['money'] = $user['money'] - (round($onecost, 2) * 10);
if (rand(1, 7) == 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>";
}
}
break;
case 'full':
$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=$row['cost']/($row['maxdur']*10);
//if($onecost < 0.1) {$onecost=0.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>";
}
}
break;
} else {
$err = "<font color=red><b>Недостаточно денег.</b></font>";
}
}
}
?>
@ -109,7 +62,7 @@ if ($_GET['sid'] && $_GET['rep']) {
<span class="wrap">Кредиты<span class="num"><?= $user['money'] ?></span></span>
<span class="wrap">Масса вещей<span class="num"><?= getItemsMassaInfo() ?></span></span>
<?php if (isset($status)): ?>
<span class="wrap"><?= $status ?></span>
<span class="wrap"><?= $status ?></span>
<?php endif; ?>
</div>
<TABLE width=100%>
@ -166,16 +119,11 @@ if ($_GET['sid'] && $_GET['rep']) {
<TD align=center><IMG SRC="i/sh/<?= $row['img'] ?>">
<BR>
<small>
<? if ($row['duration'] > 0) { ?><A HREF="?rep=<?= $row['id'] ?>&sid=1">Ремонт 1 ед.
за <?= round($onecost, 2) ?> кр.</A><BR><? } else {
<? if ($row['duration'] > 0) { ?>
<A HREF="?rep=<?= $row['id'] ?>&sid=full">Ремонт
за <?= round(($row['duration'] * $onecost), 2) ?> кр.</A><BR><? } else {
echo "не нуждается в ремонте";
} ?>
<? if ($row['duration'] >= 10) { ?><A HREF="?rep=<?= $row['id'] ?>&sid=10">Ремонт 10
ед. за <?= round(($onecost * 10), 2) ?> кр.</A><BR><?
} ?>
<? if ($row['duration'] > 1) { ?><A HREF="?rep=<?= $row['id'] ?>&sid=full">Полный
ремонт за <?= round(($row['duration'] * $onecost), 2) ?> кр.</A><?
} ?>
</small>
</TD>
<?php