battles/shop.php

562 lines
30 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
ob_start();
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
require_once("functions.php");
2018-01-28 16:40:49 +00:00
2018-06-22 23:00:48 +00:00
if ($user['room'] != 22) {
header("Location: main.php");
die();
2018-01-28 16:40:49 +00:00
}
2018-06-22 23:00:48 +00:00
if ($user['battle'] != 0) {
header('location: fbattle.php');
die();
2018-01-28 16:40:49 +00:00
}
$sellItemId = filter_input(INPUT_GET, 'sellitem');
$saleItems = false;
2018-01-28 16:40:49 +00:00
/**
* Показать предмет в магазине
*
* @param $it
* @param string $from
* @return string
*/
function show_shop_items($it, $from = 'shop')
{
global $user;
$r = '';
$item = db::c()->query('SELECT * FROM ?f WHERE `id` = ?i', $from, $it);
if ($item->getNumRows()) {
$item = $item->fetch_assoc();
if (!empty($item['magic'])) $magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $item['magic'])->fetch_assoc();
if (!empty($item['includemagic'])) {
$incmagic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $item['includemagic'])->fetch_assoc();
$incmagic['name'] = $item['includemagicname'];
$incmagic['cur'] = $item['includemagicdex'];
$incmagic['max'] = $item['includemagicmax'];
if (empty($magic)) {
$magic['chanse'] = $incmagic['chanse'];
$magic['time'] = $incmagic['time'];
$magic['targeted'] = $incmagic['targeted'];
}
}
$r .= $item['name'];
$r .= " (Масса: {$item['massa']})";
if (!empty($item['nalign']))
$r .= " <img src=i/align_{$item['nalign']}.gif class='tooltip' title='Этот предмет могут использовать только игроки с определённой склонностью.'> ";
if (!empty($item['artefact']))
$r .= " <img src=i/artefact{$item['artefact']}.gif class='tooltip' title='Артефакт!'>";
2018-12-13 00:46:48 +00:00
$r .= "<br><b>Цена: {$item['cost']} кр.</b>";
if ($item['count']) {
2018-12-13 00:46:48 +00:00
$r .= "<br><small>(количество: {$item['count']})</small>";
}
$r .= "<br />Долговечность: {$item['maxdur']}";
$r .= "<br />";
if (!$item['needident']) {
$r .= ((!empty($magic['chanse'])) ? "Вероятность срабатывания: " . $magic['chanse'] . "%<br />" : "") . "
" . ((!empty($magic['time'])) ? "Продолжительность действия магии: " . $magic['time'] . " мин.<br />" : "") . "
" . (($item['goden']) ? "Срок годности: {$item['goden']} дн. " . ((!$item['count']) ? "(до " . date("Y.m.d H:i", $item['dategoden']) . ")" : "") . "<br />" : "") . "
" . (($item['nsila'] || $item['nlovk'] || $item['ninta'] || $item['nvinos'] || $item['nlevel'] || $item['nintel'] || $item['nmudra'] || $item['nnoj'] || $item['ntopor'] || $item['ndubina'] || $item['nmech'] || $item['nfire'] || $item['nwater'] || $item['nair'] || $item['nearth'] || $item['nearth'] || $item['nlight'] || $item['ngray'] || $item['ndark']) ? "<b>Требуется минимальное:</b><br />" : "") . "
" . (($item['nsila'] > 0) ? " " . (($item['nsila'] > $user['sila']) ? "<font color=red>" : "") . "Сила: {$item['nsila']}</font><br />" : "") . "
" . (($item['nlovk'] > 0) ? " " . (($item['nlovk'] > $user['lovk']) ? "<font color=red>" : "") . "Ловкость: {$item['nlovk']}</font><br />" : "") . "
" . (($item['ninta'] > 0) ? " " . (($item['ninta'] > $user['inta']) ? "<font color=red>" : "") . "Интуиция: {$item['ninta']}</font><br />" : "") . "
" . (($item['nvinos'] > 0) ? " " . (($item['nvinos'] > $user['vinos']) ? "<font color=red>" : "") . "Выносливость: {$item['nvinos']}</font><br />" : "") . "
" . (($item['nlevel'] > 0) ? " " . (($item['nlevel'] > $user['level']) ? "<font color=red>" : "") . "Уровень: {$item['nlevel']}</font><br />" : "") . "
" . (($item['nintel'] > 0) ? " " . (($item['nintel'] > $user['intel']) ? "<font color=red>" : "") . "Интеллект: {$item['nintel']}</font><br />" : "") . "
" . (($item['nnoj'] > 0) ? " " . (($item['nnoj'] > $user['noj']) ? "<font color=red>" : "") . "Мастерство владения ножами и кастетами: {$item['nnoj']}</font><br />" : "") . "
" . (($item['ntopor'] > 0) ? " " . (($item['ntopor'] > $user['topor']) ? "<font color=red>" : "") . "Мастерство владения топорами и секирами: {$item['ntopor']}</font><br />" : "") . "
" . (($item['ndubina'] > 0) ? " " . (($item['ndubina'] > $user['dubina']) ? "<font color=red>" : "") . "Мастерство владения дубинами и булавами: {$item['ndubina']}</font><br />" : "") . "
" . (($item['nmech'] > 0) ? " " . (($item['nmech'] > $user['mec']) ? "<font color=red>" : "") . "Мастерство владения мечами: {$item['nmech']}</font><br />" : "") . "
" . (($item['nfire'] > 0) ? " " . (($item['nfire'] > $user['mfire']) ? "<font color=red>" : "") . "Мастерство владения стихией Огня: {$item['nfire']}</font><br />" : "") . "
" . (($item['nwater'] > 0) ? " " . (($item['nwater'] > $user['mwater']) ? "<font color=red>" : "") . "Мастерство владения стихией Воды: {$item['nwater']}</font><br />" : "") . "
" . (($item['nair'] > 0) ? " " . (($item['nair'] > $user['mair']) ? "<font color=red>" : "") . "Мастерство владения стихией Воздуха: {$item['nair']}</font><br />" : "") . "
" . (($item['nearth'] > 0) ? " " . (($item['nearth'] > $user['mearth']) ? "<font color=red>" : "") . "Мастерство владения стихией Земли: {$item['nearth']}</font><br />" : "") . "
" . (($item['nlight'] > 0) ? " " . (($item['nlight'] > $user['mlight']) ? "<font color=red>" : "") . "Мастерство владения магией Света: {$item['nlight']}</font><br />" : "") . "
" . (($item['ngray'] > 0) ? " " . (($item['ngray'] > $user['mgray']) ? "<font color=red>" : "") . "Мастерство владения серой магией: {$item['ngray']}</font><br />" : "") . "
" . (($item['ndark'] > 0) ? " " . (($item['ndark'] > $user['mdark']) ? "<font color=red>" : "") . "Мастерство владения магией Тьмы: {$item['ndark']}</font><br />" : "") . "
" . (($item['gsila'] || $item['mfkrit'] || $item['mfakrit'] || $item['mfuvorot'] || $item['mfauvorot'] || $item['glovk'] || $item['ghp'] || $item['ginta'] || $item['gintel'] || $item['gnoj'] || $item['gtopor'] || $item['gdubina'] || $item['gmech'] || $item['gfire'] || $item['gwater'] || $item['gair'] || $item['gearth'] || $item['gearth'] || $item['glight'] || $item['ggray'] || $item['gdark'] || $item['minu'] || $item['maxu'] || $item['bron1'] || $item['bron2'] || $item['bron3'] || $item['bron4']) ? "<b>Действует на:</b><br />" : "") . "
" . (($item['minu']) ? " Минимальное наносимое повреждение: +{$item['minu']}<br />" : "") . "
" . (($item['maxu']) ? " Максимальное наносимое повреждение: +{$item['maxu']}<br />" : "");
if ($item['gsila']) {
$r .= "• Сила: +" . $item['gsila'];
$r .= "<br />";
}
if ($item['glovk']) {
$r .= "• Ловкость: " . plusorminus($item['glovk']);
$r .= "<br />";
}
if ($item['ginta']) {
$r .= "• Интуиция: " . plusorminus($item['ginta']);
$r .= "<br />";
}
if ($item['gintel']) {
$r .= "• Интеллект: " . plusorminus($item['gintel']);
$r .= "<br />";
}
$r .= (($item['ghp']) ? "• Уровень жизни: " . plusorminus($item['ghp']) . "<br />" : "");
if ($item['mfkrit'] > 0) {
$r .= "• Мф. критических ударов: " . plusorminus($item['mfkrit']) . "%";
$r .= "<br />";
}
if ($item['mfakrit'] > 0) {
$r .= "• Мф. против крит. ударов: " . plusorminus($item['mfakrit']) . "%";
$r .= "<br />";
}
if ($item['mfuvorot'] > 0) {
$r .= "• Мф. увертливости: " . plusorminus($item['mfuvorot']) . "%";
$r .= "<br />";
}
if ($item['mfauvorot'] > 0) {
$r .= "• Мф. против увертлив.: " . plusorminus($item['mfauvorot']) . "%";
$r .= "<br />";
}
$r .= (($item['gnoj']) ? "• Мастерство владения ножами и кастетами: +{$item['gnoj']}<br />" : "") . "
" . (($item['gtopor']) ? " Мастерство владения топорами и секирами: +{$item['gtopor']}<br />" : "") . "
" . (($item['gdubina']) ? " Мастерство владения дубинами и булавами: +{$item['gdubina']}<br />" : "") . "
" . (($item['gmech']) ? " Мастерство владения мечами: +{$item['gmech']}<br />" : "") . "
" . (($item['gfire']) ? " Мастерство владения стихией Огня: +{$item['gfire']}<br />" : "") . "
" . (($item['gwater']) ? " Мастерство владения стихией Воды: +{$item['gwater']}<br />" : "") . "
" . (($item['gair']) ? " Мастерство владения стихией Воздуха: +{$item['gair']}<br />" : "") . "
" . (($item['gearth']) ? " Мастерство владения стихией Земли: +{$item['gearth']}<br />" : "") . "
" . (($item['glight']) ? " Мастерство владения магией Света: +{$item['glight']}<br />" : "") . "
" . (($item['ggray']) ? " Мастерство владения серой магией: +{$item['ggray']}<br />" : "") . "
" . (($item['gdark']) ? " Мастерство владения магией Тьмы: +{$item['gdark']}<br />" : "");
if ($item['bron1'] > 0) {
$r .= "• Броня головы: " . $item['bron1'];
$r .= "<br />";
}
if ($item['bron2'] > 0) {
$r .= "• Броня корпуса: " . $item['bron2'];
$r .= "<br />";
}
if ($item['bron3'] > 0) {
$r .= "• Броня пояса: " . $item['bron3'];
$r .= "<br />";
}
if ($item['bron4'] > 0) {
$r .= "• Броня ног: " . $item['bron4'];
$r .= "<br />";
}
$r .= ((!empty($magic['name']) && $item['type'] != 50) ? "<span style='color: darkred;'>Наложены заклятия:</span> " . $magic['name'] . "<br />" : "") . "
" . ((!empty($incmagic['max'])) ? " Встроено заклятие <img src=\"i/magic/" . $incmagic['img'] . "\" /> " . $incmagic['cur'] . " шт. <br />" : "") . "
" . ((!$item['isrep']) ? "<small><span style='color: darkred;'>Предмет не подлежит ремонту</span></small><br />" : "");
} else {
$r .= "<span style='color: darkred; font-style: italic;'>Свойства предмета не идентифицированы.</span><br />";
}
$osob = array(22, 23);
if (in_array($item['type'], $osob)) {
$r .= 'Особенности:<br />';
if ($item['type'] == 22) {
$r .= '• может одеваться под броню<br />';
} elseif ($item['type'] == 23) {
$r .= '• может одеваться на броню<br />';
}
}
$r .= "<br></td></TR>";
} else {
$r = 'Предмет не найден : {' . $it . '}';
}
return $r;
}
2018-06-23 17:02:30 +00:00
if ($sellItemId && is_numeric($sellItemId)) {
$dress = db::c()->query('SELECT `id`, `name`, `cost`, `type`, `duration`, `maxdur`, `goden`, `dategoden`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc();
2018-06-22 23:00:48 +00:00
$price = $dress['cost'] * 1;
$kols = '';
if ($dress['koll']) {
$price *= $dress['koll'];
2018-06-22 23:00:48 +00:00
$kols = '(x' . $dress['koll'] . ')';
2018-01-28 16:40:49 +00:00
}
2018-06-22 23:00:48 +00:00
destructitem($dress['id']);
if ($dress['type'] == 12) {
$allcost = round($price * (1 - $dress['duration'] / $dress['maxdur']), 2);
} else {
$allcost = round($price - $dress['duration'] * ($dress['cost'] / ($dress['maxdur'] * 10)), 2);
2018-01-28 16:40:49 +00:00
}
2018-06-22 23:00:48 +00:00
if ($dress['goden'] != 0) {
$goden_max = $dress['goden'] * 24 * 60;
$goden_left = ($dress['dategoden'] - time()) / 60;
$per = $goden_left / $goden_max;
$allcost = round(($allcost * $per), 2);
}
$user['money'] += $allcost;
$deloText = "\"" . $user['login'] . "\" продал в магазин товар : \"" . $dress['name'] . "\" $kols id:(cap" . $dress['id'] . ") [" . $dress['duration'] . "/" . $dress['maxdur'] . "] за " . $allcost . " кр. ";
db::c()->query('UPDATE `users` SET `money` = ?i WHERE `id` = ?i', $user['money'], $user['id']);
db::c()->query('INSERT INTO `delo` (`pers`, `text`, `type`, `date`) VALUES (?i, "?s", 1, ?i)', $user['id'], $deloText, time());
echo "<b style='color: red;'>Вы продали \"{$dress['name']}\" $kols за " . $allcost . " кр.</b>";
2018-01-28 16:40:49 +00:00
}
if (isset($_GET['set']) OR isset($_POST['set'])) {
$set = empty($_GET['set']) ?: $_GET['set'];
$set = empty($_POST['set']) ?: $_POST['set'];
2018-01-28 16:40:49 +00:00
$count = isset($_GET['count']) && is_numeric($_GET['count']) ? $_GET['count'] : 0;
$count = isset($_POST['count']) && is_numeric($_POST['count']) ? $_POST['count'] : 0;
if ($count < 1) {
$count = 0;
2018-06-22 23:00:48 +00:00
$count_ok = 0;
} else $count_ok = 1;
$dress = db::c()->query('SELECT * FROM `shop` WHERE `id`=?i', $set)->fetch_assoc();
// db::c()->query('
// INSERT INTO `inventory` (
// name, maxdur, cost, img, goden, dategoden, massa, prototype, owner,
// nlevel, nsila, nlovk, ninta, nvinos, nintel, nmudra,
// nnoj, ntopor, ndubina, nmech, nalign, nfire, nwater, nair, nearth, nlight, ngray, ndark,
// minu, maxu,
// gsila, glovk, ginta, gintel, ghp, gfire, gwater, gair, gearth, glight, ggray, gdark,
// mfkrit, mfakrit, mfuvorot, mfauvorot,
// gnoj, gtopor, gdubina, gmech,
// bron1, bron2, bron3, bron4, magic, needident,
// gmp, gmeshok, artefact, encicl, koll)
// SELECT
// name, maxdur, cost, img, goden, dategoden, massa, id, ?i,
// nlevel, nsila, nlovk, ninta, nvinos, nintel, nmudra,
// nnoj, ntopor, ndubina, nmech, nalign, nfire, nwater, nair, nearth, nlight, ngray, ndark,
// minu, maxu,
// gsila, glovk, ginta, gintel, ghp, gfire, gwater, gair, gearth, glight, ggray, gdark,
// mfkrit, mfakrit, mfuvorot, mfauvorot,
// gnoj, gtopor, gdubina, gmech,
// bron1, bron2, bron3, bron4, magic, needident,
// gmp, gmeshok, artefact, encicl, koll
// FROM shop WHERE id = inventory.prototype;
//
// ', $user['id']);
2018-06-22 23:00:48 +00:00
if ($count_ok == 0) {
err('Неправильно введено количество.');
} elseif (($dress['massa'] * $count + $itemWeight['m']) > (get_meshok())) {
err('Недостаточно места в рюкзаке.');
} elseif ($count_ok == 1 && ($user['money'] >= ($dress['cost'] * $count)) && ($dress['count'] >= $count)) {
2018-06-22 23:00:48 +00:00
$newItem = [
'prototype' => $dress['id'],
'owner' => $user['id'],
'name' => $dress['name'], //s
'type' => $dress['type'],
'massa' => $dress['massa'],
'cost' => $dress['cost'],
'img' => $dress['img'], //s
'maxdur' => $dress['maxdur'],
'isrep' => $dress['isrep'],
'gsila' => $dress['gsila'],
'glovk' => $dress['glovk'],
'ginta' => $dress['ginta'],
'gintel' => $dress['gintel'],
'ghp' => $dress['ghp'],
'gnoj' => $dress['gnoj'],
'gtopor' => $dress['gtopor'],
'gdubina' => $dress['gdubina'],
'gmech' => $dress['gmech'],
'gfire' => $dress['gfire'],
'gwater' => $dress['gwater'],
'gair' => $dress['gair'],
'gearth' => $dress['gearth'],
'glight' => $dress['glight'],
'ggray' => $dress['ggray'],
'gdark' => $dress['gdark'],
'needident' => $dress['needident'],
'nsila' => $dress['nsila'],
'nlovk' => $dress['nlovk'],
'ninta' => $dress['ninta'],
'nintel' => $dress['nintel'],
'nmudra' => $dress['nmudra'],
'nvinos' => $dress['nvinos'],
'nnoj' => $dress['nnoj'],
'ntopor' => $dress['ntopor'],
'ndubina' => $dress['ndubina'],
'nmech' => $dress['nmech'],
'bron1' => $dress['bron1'],
'bron2' => $dress['bron2'],
'bron3' => $dress['bron3'],
'bron4' => $dress['bron4'],
'minu' => $dress['minu'],
'maxu' => $dress['maxu'],
'magic' => $dress['magic'],
'nlevel' => $dress['nlevel'],
'nalign' => $dress['nalign'],
'dategoden' => $dress['dategoden'],
'goden' => $dress['goden'],
'otdel' => $dress['otdel'],//s
'gmp' => $dress['gmp'],
'gmeshok' => $dress['gmeshok'],
'encicl' => $dress['encicl'],//s
'artefact' => $dress['artefact'],
'koll' => $dress['koll']
];
2018-06-22 23:00:48 +00:00
for ($k = 1; $k <= $_GET['count']; $k++) {
db::c()->query('INSERT INTO `inventory` SET ?A[?i,?i,"?s",?i,?i,?i,"?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,"?s",?i,?i,"?s",?i,?i]', $newItem);
db::c()->query('UPDATE `shop` SET `count` = `count` - ?i WHERE `id` =?i', $count, $set);
echo "<b style='color: red'>Вы купили {$count} шт. \"{$dress['name']}\".</b>";
$user['money'] -= $count * $dress['cost'];
db::c()->query('UPDATE `users` set `money` = ?i WHERE `id` = ?i', $user['money'], $user['id']);
$invdb = db::c()->query('SELECT `id` FROM `inventory` WHERE `name` = "?s" ORDER BY `id` DESC LIMIT ?i', $dress['name'], $count);
if ($count == 1) {
$dressinv = $invdb->fetch_assoc();
2018-06-22 23:00:48 +00:00
$dressid = "cap" . $dressinv['id'];
$dresscount = " ";
} else {
$dressid = "";
while ($dressinv = $invdb->fetch_assoc()) {
2018-06-22 23:00:48 +00:00
$dressid .= "cap" . $dressinv['id'] . ",";
}
$dresscount = "(x" . $count . ") ";
2018-06-22 23:00:48 +00:00
}
$allcost = $count * $dress['cost'];
$deloText = "\"" . $user['login'] . "\" купил товар : \"" . $dress['name'] . "\" " . $dresscount . " id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " кр.";
db::c()->query('INSERT INTO `delo` (`pers`, `text`, `type`, `date`) VALUES (?i, "?s", 1, ?i', $user['id'], $deloText, time());
2018-06-22 23:00:48 +00:00
}
2018-06-22 23:00:48 +00:00
} else {
echo "<b style='color: red;'>Недостаточно денег или нет вещей в наличии.</b>";
2018-01-28 16:40:49 +00:00
}
}
2018-06-22 23:00:48 +00:00
$itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc();
$shopCategoryType = empty($_POST['sale']) ?: $_POST['sale'];
$shopCategoryTypeNumber = empty($_GET['otdel']) ?: $_GET['otdel'];
switch ($shopCategoryTypeNumber) {
default:
$shopCategoryType = "Предметы в инвентаре";
$saleItems = true;
break;
case 1:
$shopCategoryType = "Кастеты и ножи";
break;
case 11:
$shopCategoryType = "Топоры";
break;
case 12:
$shopCategoryType = "Дубины и булавы";
break;
case 13:
$shopCategoryType = "Мечи";
break;
case 14:
$shopCategoryType = "Луки и арбалеты";
break;
case 2:
$shopCategoryType = "Сапоги";
break;
case 21:
$shopCategoryType = "Перчатки";
break;
case 22:
$shopCategoryType = "Легкая броня";
break;
case 23:
$shopCategoryType = "Тяжелая броня";
break;
case 24:
$shopCategoryType = "Шлемы";
break;
case 3:
$shopCategoryType = "Щиты";
break;
case 4:
$shopCategoryType = "Серьги";
break;
case 41:
$shopCategoryType = "Ожерелья";
break;
case 42:
$shopCategoryType = "Кольца";
break;
case 5:
$shopCategoryType = "Заклинания: нейтральные";
break;
case 51:
$shopCategoryType = "Заклинания: боевые и защитные";
break;
case 6:
$shopCategoryType = "Амуниция";
break;
case 52:
$shopCategoryType = "Руны";
break;
}
2018-01-28 16:40:49 +00:00
?>
2018-06-22 23:00:48 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet"/>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.simplemodal.js"></script>
<script src="js/jquery.ui.js?100"></script>
<script src="js/mi.js"></script>
<link rel="stylesheet" href="css/bkstyle.css?101"/>
<link rel="stylesheet" href="css/mi.css"/>
<style>
.row {
font-family: Tahoma, sans-serif;
font-size: 13px;
}
</style>
<script>
function addCountItems(name, txt) {
new miDialog({title: 'Купить неск. штук'}, {byu: 1}, function () {
document.location = '/shop.php?' + $.param(this.data);
},
$('<div style="text-align: center;"><b>' + txt + '</b></div>').append(miDialog._oneInput({
name: 'count',
onkeyup: 'return proverka(this);',
onchange: 'return proverka(this);'
}), miDialog._hiddenInput({name: 'set', value: name})), {width: 250});
}
function proverka(input) {
input.value = input.value.replace(/[^\d]/g, '');
}
function leave() {
top.frames['main'].location = 'city.php?cp'
}
</script>
</head>
<body>
<h1>Государственный магазин</h1>
<a href=# onclick=leave()> ← выйти на Центральную площадь</a>
<TABLE width=100% cellspacing="0" cellpadding="4">
2018-06-22 23:00:48 +00:00
<TR>
<TD valign=top align=left>
<!--Магазин-->
<TABLE border=0 width=100% cellspacing="0" cellpadding="0" bgcolor="#A5A5A5">
<TR>
<TD align=center>
<h3><?= $shopCategoryType ?></h3>
<?php if ($saleItems): ?>
Вы можете продать ваши предметы за 10% от стоимости.
<?php endif; ?>
2018-06-22 23:00:48 +00:00
</TD>
</TR>
<TR>
<TD>
<TABLE class="zebra" WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
2018-06-22 23:00:48 +00:00
<?php
if ($saleItems == true) {
// Выбираем всё потому что эту выборку потом использует showitem();
$data = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND `tradesale` = 0 AND `podzem` = 0 ORDER BY `update` DESC', $user['id'], null);
while ($row = $data->fetch_assoc()) {
2018-06-22 23:00:48 +00:00
$row['count'] = 1;
$price = $row['cost'] * 0.1;
if ($row['koll']) {
$price *= $row['koll'];
2018-06-22 23:00:48 +00:00
}
if ($row['type'] == 12) {
$allcost = round($price * (1 - $row['duration'] / $row['maxdur']), 2);
} else {
$allcost = round($price - $row['duration'] * ($row['cost'] / ($row['maxdur'] * 10)), 2);
}
if ($row['goden'] != 0) {
$goden_max = $row['goden'] * 24 * 60;
$goden_left = ($row['dategoden'] - time()) / 60;
$per = $goden_left / $goden_max;
$allcost = round(($allcost * $per), 2);
}
?>
<tr>
<td align=center style='width: 150px;'>
<img src="i/sh/<?= $row['img'] ?>" border=0>
<br><a href="shop.php?sellitem=<?= $row['id'] ?>&sid=&sale=1">продать
за <?= $allcost ?></a>
</td>
<td valign=top class="row">
<?php showitem($row); ?>
</td>
</tr>
2018-06-22 23:00:48 +00:00
<?php
}
} else {
2018-06-23 17:54:07 +00:00
$data = db::c()->query('SELECT `id`, `img`, `name` FROM `shop` WHERE `count` > 0 AND `razdel` = ?i ORDER by `nlevel` ASC, `id` ASC', $shopCategoryTypeNumber);
while ($row = $data->fetch_assoc()) {
2018-06-22 23:00:48 +00:00
?>
<tr>
<td align=center style='width: 150px;'>
<img src="i/sh/<?= $row['img'] ?>" border=0>
<br>
<a href="shop.php?otdel=<?= $_GET['otdel'] ?>&set=<?= $row['id'] ?>&rnd=<?= mt_rand() ?>">купить</a>
<IMG SRC="i/up.gif" WIDTH=11 HEIGHT=11 BORDER=0 ALT="Купить несколько штук"
style="cursor:hand"
onclick="addCountItems('<?= $row['id'] ?>', '<?= $row['name'] ?>')">
</td>
<td valign=top>
<?= show_shop_items($row['id']) ?>
</td>
</tr>
2018-06-22 23:00:48 +00:00
<?php
}
}
?>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
<TD valign=top width=280>
<B>Масса всех ваших вещей: <?= getItemsMassaInfo() ?>
<BR>У вас в наличии: <span style="color: darkgreen;"><?= $user['money'] ?></span> кр.</B>
2018-06-22 23:00:48 +00:00
<hr>
<a href="shop.php?otdel=sale&rnd=<?= mt_rand() ?>">Продать вещи</a>
2018-06-22 23:00:48 +00:00
<dl>
<dt><b>Оружие:</b></dt>
<dd><a href="shop.php?otdel=1&rnd=<?= mt_rand() ?>">кастеты,ножи</a></dd>
<dd><a href="shop.php?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="shop.php?otdel=12&rnd=<?= mt_rand() ?>">дубины,булавы</a></dd>
<dd><a href="shop.php?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dt><b>Одежда:</b></dt>
<dd><a href="shop.php?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="shop.php?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="shop.php?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="shop.php?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="shop.php?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="shop.php?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dt><b>Ювелирные товары:</b></dt>
<dd><a href="shop.php?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="shop.php?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="shop.php?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dt><b>Магия:</b></dt>
<dd><a href="shop.php?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="shop.php?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dt><b>Разное:</b></dt>
<dd><a href="shop.php?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="shop.php?otdel=52&rnd=<?= mt_rand() ?>">руны</a></dd>
2018-06-22 23:00:48 +00:00
</dl>
<div id="hint3" class="ahint"></div>
</TD>
</TR>
2018-01-28 16:40:49 +00:00
</TABLE>
</BODY>
</HTML>