change appearance to new one
This commit is contained in:
parent
21457ab0a1
commit
c8d297e7bb
86
shop.php
86
shop.php
@ -19,8 +19,9 @@ $saleItems = false;
|
||||
/**
|
||||
* Показать предмет в магазине
|
||||
*
|
||||
* @param $it
|
||||
* @param $it
|
||||
* @param string $from
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function show_shop_items($it, $from = 'shop')
|
||||
@ -169,7 +170,7 @@ function show_shop_items($it, $from = 'shop')
|
||||
} else {
|
||||
$r .= "<span style='color: darkred; font-style: italic;'>Свойства предмета не идентифицированы.</span><br />";
|
||||
}
|
||||
$osob = array(22, 23);
|
||||
$osob = [22, 23];
|
||||
if (in_array($item['type'], $osob)) {
|
||||
$r .= 'Особенности:<br />';
|
||||
if ($item['type'] == 22) {
|
||||
@ -217,19 +218,14 @@ if ($sellItemId && is_numeric($sellItemId)) {
|
||||
|
||||
if (!empty($_GET['buy'])) {
|
||||
|
||||
if (!empty($_GET['count']) AND is_numeric($_GET['count']) AND $_GET['count'] < 1) {
|
||||
$count = 0;
|
||||
$count_ok = 0;
|
||||
} else $count_ok = 1;
|
||||
$count_ok = 1;
|
||||
|
||||
$dress = db::c()->query('SELECT * FROM `shop` WHERE `id`=?i', $set)->fetch_assoc();
|
||||
|
||||
|
||||
if ($count_ok == 0) {
|
||||
err('Неправильно введено количество.');
|
||||
} elseif (($dress['massa'] * $count + $itemWeight['m']) > (get_meshok())) {
|
||||
if (($dress['massa'] + $itemWeight['m']) > (get_meshok())) {
|
||||
err('Недостаточно места в рюкзаке.');
|
||||
} elseif ($count_ok == 1 && ($user['money'] >= ($dress['cost'] * $count)) && (($dress['count'] >= $count) OR $dress['count'] == -1)) {
|
||||
} elseif ($user['money'] >= $dress['cost'] AND ($dress['count'] > 0 OR $dress['count'] == -1)) {
|
||||
|
||||
$newItem = [
|
||||
'prototype' => $dress['id'],
|
||||
@ -287,28 +283,20 @@ if (!empty($_GET['buy'])) {
|
||||
'koll' => $dress['koll']
|
||||
];
|
||||
|
||||
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);
|
||||
if ($dress['count'] != -1) 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();
|
||||
$dressid = "cap" . $dressinv['id'];
|
||||
$dresscount = " ";
|
||||
} else {
|
||||
$dressid = "";
|
||||
while ($dressinv = $invdb->fetch_assoc()) {
|
||||
$dressid .= "cap" . $dressinv['id'] . ",";
|
||||
}
|
||||
$dresscount = "(x" . $count . ") ";
|
||||
}
|
||||
$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());
|
||||
}
|
||||
|
||||
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);
|
||||
if ($dress['count'] != -1) 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);
|
||||
|
||||
$dressinv = $invdb->fetch_assoc();
|
||||
$dressid = "cap" . $dressinv['id'];
|
||||
|
||||
$deloText = "\"" . $user['login'] . "\" купил товар : \"" . $dress['name'] . " id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $dress['cost'] . " кр.";
|
||||
db::c()->query('INSERT INTO `delo` (`pers`, `text`, `type`, `date`) VALUES (?i, "?s", 1, ?i', $user['id'], $deloText, time());
|
||||
|
||||
|
||||
} else {
|
||||
echo "<b style='color: red;'>Недостаточно денег или нет вещей в наличии.</b>";
|
||||
@ -334,9 +322,6 @@ switch ($shopCategoryTypeNumber) {
|
||||
case 13:
|
||||
$shopCategoryType = "Мечи";
|
||||
break;
|
||||
case 14:
|
||||
$shopCategoryType = "Луки и арбалеты";
|
||||
break;
|
||||
case 2:
|
||||
$shopCategoryType = "Сапоги";
|
||||
break;
|
||||
@ -377,6 +362,23 @@ switch ($shopCategoryTypeNumber) {
|
||||
$shopCategoryType = "Руны";
|
||||
break;
|
||||
}
|
||||
|
||||
$shopItems = db::c()->query('SELECT `shop`.*,
|
||||
`magic`.`name` AS `magic_name`,
|
||||
`magic`.`chanse` AS `magic_chanse`,
|
||||
`magic`.`time` AS `magic_time`,
|
||||
`magic`.`file` AS `magic_file`,
|
||||
`magic`.`targeted` AS `magic_targeted`,
|
||||
`magic`.`needcharge` AS `magic_needcharge`,
|
||||
`magic`.`img` AS `magic_img`
|
||||
|
||||
FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `cost` > 0 AND `razdel` = ?i ORDER by `nlevel` ASC, `id` ASC', $shopCategoryTypeNumber);
|
||||
|
||||
$iteminfo =[];
|
||||
while ($row = $shopItems->fetch_assoc()) {
|
||||
$iteminfo[] = new ShopItem($row);
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@ -471,6 +473,16 @@ switch ($shopCategoryTypeNumber) {
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
foreach ($iteminfo as $ii) {
|
||||
echo "<tr><td style='width: 150px; text-align: center;'>";
|
||||
$ii->printImage();
|
||||
$ii->printControls();
|
||||
echo "</td>";
|
||||
echo "<td style='vertical-align: top;'>";
|
||||
$ii->printInfo();
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
$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()) {
|
||||
?>
|
||||
@ -484,11 +496,13 @@ switch ($shopCategoryTypeNumber) {
|
||||
onclick="addCountItems('<?= $row['id'] ?>', '<?= $row['name'] ?>')">
|
||||
</td>
|
||||
<td valign=top>
|
||||
<?= show_shop_items($row['id']) ?>
|
||||
<?= /*show_shop_items($row['id']) */?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
</TABLE>
|
||||
|
Loading…
Reference in New Issue
Block a user