diff --git a/shop.php b/shop.php
index f77b644..c86fad4 100644
--- a/shop.php
+++ b/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 .= "Свойства предмета не идентифицированы.
";
}
- $osob = array(22, 23);
+ $osob = [22, 23];
if (in_array($item['type'], $osob)) {
$r .= 'Особенности:
';
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 "Вы купили {$count} шт. \"{$dress['name']}\".";
- $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 "Вы купили {$count} шт. \"{$dress['name']}\".";
+ $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 "Недостаточно денег или нет вещей в наличии.";
@@ -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);
+}
+
?>
@@ -471,6 +473,16 @@ switch ($shopCategoryTypeNumber) {