From 016e5a9ccdae04303b72bd62e6e02ca926829f6d Mon Sep 17 00:00:00 2001 From: "Igor Barkov [iwork]" Date: Tue, 15 Jan 2019 17:56:15 +0200 Subject: [PATCH] 1. finalize ekrshop 2. shop bying fixes 3. item class code clear 4. moved all gifts to separate file 5. removed artefact upgrade --- ashop.php | 291 +++++++++++-------------------------------- classes/Item.php | 58 --------- classes/ShopItem.php | 43 +++++-- functions.php | 4 +- presents.php | 125 +++++++++++++++++++ shop.php | 131 ++++++++++--------- upgrade_items.php | 75 ----------- 7 files changed, 305 insertions(+), 422 deletions(-) create mode 100644 presents.php delete mode 100644 upgrade_items.php diff --git a/ashop.php b/ashop.php index f595848..18d9571 100644 --- a/ashop.php +++ b/ashop.php @@ -1,15 +1,13 @@ query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc(); if ($user['battle'] != 0) { header('location: fbattle.php'); die(); @@ -17,28 +15,31 @@ if ($user['battle'] != 0) { $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc(); -if (isset($_GET['set']) OR isset($_POST['set'])) { +$shopItems = db::c()->query('SELECT `ashop`.*, + `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` - $set = empty($_GET['set']) ?: $_GET['set']; - $set = empty($_POST['set']) ?: $_POST['set']; +FROM `ashop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `cost` > 0 AND `razdel` = ?i ORDER by `nlevel` ASC, `id` ASC', $_GET['otdel']); - $count = isset($_POST['count']) && is_numeric($_POST['count']) ? $_POST['count'] : 0; +$iteminfo = []; +while ($row = $shopItems->fetch_assoc()) { + $iteminfo[] = new ShopItem($row); +} - if ($count < 1) { - $count = 0; - $count_ok = 0; - } else $count_ok = 1; +if (!empty($_GET['buy'])) { + $dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $_GET['buy'])->fetch_assoc(); + $itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $user['id'])->fetch_assoc(); + if (($dress['massa'] + $itemWeight['m']) > (get_meshok())) $status = 'Недостаточно места в рюкзаке.'; + elseif ($bank['ekr'] >= $dress['ecost'] AND ($dress['count'] > 0 OR $dress['count'] == -1)) { - $dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $set)->fetch_assoc(); - if ($count_ok == 0) { - err('Неправильно введено количество.'); - } elseif (($dress['massa'] * $_POST['count'] + $itemWeight['m']) > (get_meshok())) { - err('Недостаточно места в рюкзаке.'); - } elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) { - for ($k = 1; $k <= $_POST['count']; $k++) { - $goden = ''; - if (isset($dress['goden'])) $goden = $dress['goden'] * 24 * 60 * 60 + time(); // Ну вот нахуя? - db::c()->query(' + $goden = ''; + if (isset($dress['goden'])) $goden = $dress['goden'] * 24 * 60 * 60 + time(); // Ну вот нахуя? + db::c()->query(' INSERT INTO `inventory` ( `prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`, @@ -50,35 +51,26 @@ if (isset($_GET['set']) OR isset($_POST['set'])) { ) VALUES (?i,?i,"?s",?i,?i,"?s","?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,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i) ', $dress['id'], $_SESSION['uid'], $dress['name'], $dress['type'], $dress['massa'], $dress['cost'], $dress['img'], $dress['maxdur'], $dress['isrep'], - $dress['gsila'], $dress['glovk'], $dress['ginta'], $dress['gintel'], $dress['ghp'], $dress['gnoj'], $dress['gtopor'], $dress['gdubina'], $dress['gmech'], - $dress['gfire'], $dress['gwater'], $dress['gair'], $dress['gearth'], $dress['glight'], $dress['ggray'], $dress['gdark'], $dress['needident'], - $dress['nsila'], $dress['nlovk'], $dress['ninta'], $dress['nintel'], $dress['nmudra'], $dress['nvinos'], $dress['nnoj'], $dress['ntopor'], $dress['ndubina'], $dress['nmech'], - $dress['nfire'], $dress['nwater'], $dress['nair'], $dress['nearth'], $dress['nlight'], $dress['ngray'], $dress['ndark'], $dress['mfkrit'], $dress['mfakrit'], - $dress['mfuvorot'], $dress['mfauvorot'], $dress['bron1'], $dress['bron3'], $dress['bron2'], $dress['bron4'], $dress['maxu'], $dress['minu'], $dress['magic'], - $dress['nlevel'], $dress['nalign'], $goden, $dress['goden'], $dress['razdel'], $dress['artefact'], $dress['koll']); + $dress['gsila'], $dress['glovk'], $dress['ginta'], $dress['gintel'], $dress['ghp'], $dress['gnoj'], $dress['gtopor'], $dress['gdubina'], $dress['gmech'], + $dress['gfire'], $dress['gwater'], $dress['gair'], $dress['gearth'], $dress['glight'], $dress['ggray'], $dress['gdark'], $dress['needident'], + $dress['nsila'], $dress['nlovk'], $dress['ninta'], $dress['nintel'], $dress['nmudra'], $dress['nvinos'], $dress['nnoj'], $dress['ntopor'], $dress['ndubina'], $dress['nmech'], + $dress['nfire'], $dress['nwater'], $dress['nair'], $dress['nearth'], $dress['nlight'], $dress['ngray'], $dress['ndark'], $dress['mfkrit'], $dress['mfakrit'], + $dress['mfuvorot'], $dress['mfauvorot'], $dress['bron1'], $dress['bron3'], $dress['bron2'], $dress['bron4'], $dress['maxu'], $dress['minu'], $dress['magic'], + $dress['nlevel'], $dress['nalign'], $goden, $dress['goden'], $dress['razdel'], $dress['artefact'], $dress['koll']); + + $inventoryItemId = db::c()->getLastInsertId(); + if ($dress['count'] != -1) db::c()->query('UPDATE `ashop` SET `count` = `count`- 1 WHERE `id` = ?i', $_GET['buy']); + + $deloText = "{$user['login']} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине «Берёзка» за {$dress['ecost']} екр."; + addToDelo($deloText); + + $status = "Вы купили «{$dress['name']}» за {$dress['ecost']} екр."; + db::c()->query('UPDATE `bank` SET `ekr` = `ekr` - ?i WHERE `id` = ?i', $dress['ecost'], $_SESSION['uid']); + // Для обновления данных о деньгах на странице + $bank['ekr'] -= $dress['ecost']; - db::c()->query('UPDATE `ashop` SET `count` = `count`- ?i WHERE `id` = ?i', $_POST['count'], $set); - $invdb = db::c()->query('SELECT `id` FROM `inventory` WHERE `name` = "?s" ORDER BY `id` DESC LIMIT ?i', $dress['name'], $_POST['count']); - if ($_POST['count'] == 1) { - $dressinv = $invdb->fetch_assoc(); - $dressid = "cap" . $dressinv['id']; - $dresscount = " "; - } else { - $dressid = ""; - while ($dressinv = $invdb->fetch_assoc()) { - $dressid .= "cap" . $dressinv['id'] . ","; - } - $dresscount = "(x" . $_POST['count'] . ") "; - } - $allcost = $_POST['count'] * $dress['ecost']; - $deloText = $user['login'] . " купил товар: " . $dress['name'] . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " екр."; - db::c()->query('INSERT INTO `delo` (`author` ,`pers`, `text`, `type`, `date`) VALUES (?i, ?i, "?s", ?i, "?s")', 0, $user['id'], $deloText, 1, time()); - err('Вы купили ' . $_POST['count'] . ' шт. "' . $dress['name'] . '.'); - db::c()->query('UPDATE `bank` SET `ekr` = `ekr` - ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']); - $bank['ekr'] -= $allcost; - } } else { - err('Недостаточно денег или нет вещей в наличии.'); + $status = "Недостаточно денег или нет вещей в наличии."; } } $shopCategory = ''; @@ -146,202 +138,67 @@ if ($_REQUEST['compare'] && !$_REQUEST['common'] && !$_REQUEST['present']) { break; } } - ?> - +

Магазин Берёзка

- ← выйти на Центральную площадь + ← выйти на Центральную площадь +
+

- - - - - - - +
-

-
- - query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc(); - if ($_POST['to_login'] == $user['login']) { - err('Очень щедро - дарить что-то самому себе! ;)'); - } elseif ($to['room'] > 500 && $to['room'] < 561) { - err('Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.'); - } else { - if ($_POST['from'] == 1) { - $from = 'Аноним'; - } elseif ($_POST['from'] == 2 && $user['klan']) { - $from = ' клана ' . $user['klan']; - } else { - $from = $user['login']; - } - - db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['podarok2'], null, $_POST['flower'], $_SESSION['uid']); - $res = db::c()->query('SELECT `id`,`name`,`duration`,`maxdur` FROM `inventory` WHERE `id` = ?i', $_POST['flower'])->fetch_assoc(); - $deloTextSender = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\""; - $deloTextReceiver = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\""; - db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $_SESSION['uid'], $deloTextSender, time()); - db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $to['id'], $deloTextReceiver, time()); - - $telegraphText = "Вам пришёл подарок \"" . $res['name'] . "\" от " . $from . "!"; - db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc(); - - err('Подарок удачно доставлен к ' . $_POST['to_login']); - } - } - ?> - -
- - - - - -
-
- - Вы можете сделать подарок дорогому человеку. Ваш подарок будет - отображаться в информации о персонаже. -
    -
  1. Укажите логин персонажа, которому хотите сделать подарок
    - -
  2. -
  3. -
  4. Выберите, от чьего имени подарок:
    -
    -
    -
    -
  5. Нажмите кнопку Подарить под предметом, который хотите - преподнести в подарок:
    -
- - - query('SELECT `id`,`img` FROM `inventory` WHERE `owner`= ?i - AND `dressed` = 0 - AND ( - `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR - `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" - ) - AND `setsale` = 0 AND `present` = "?s" - ORDER BY `id` DESC', $_SESSION['uid'], '%Букет%', '%Сувенир%', '%Подарок%', '%Валентинка%', '%Открытка%', 'Ель%', '%Медаль%', '%Статуэтка%', null); - while ($row = $data->fetch_assoc()) { - if (!in_array($row['id'], array_keys($_SESSION['flowers']))) { - $row['count'] = 1; - ?> - - - - - - - -
- -
- value="Подарить"> -
- -
- query('SELECT `id`,`img`,`name` FROM `ashop` WHERE `count` > 0 AND `razdel` = "?s" AND `ecost` > 0 ORDER BY `ecost` ASC', $_GET['otdel']); - while ($row = $data->fetch_assoc()) { - ?> -
-
- купить - Купить несколько штук", "")"> -
- -
-
+ + + + + +
+ printImage(); + $ii->printControls('ashop'); ?> + + printInfo(); ?> +
Масса всех ваших вещей:
У вас в наличии: екр.
-
- Улучшение Артефактов
-
- Отделы магазина -
+
Отделы магазина
Оружие:
-
кастеты,ножи
-
топоры
-
дубины,булавы
-
мечи
+
кинжалы
+
топоры
+
дубины
+
мечи
Одежда:
-
шлемы
-
тяжелая броня
-
легкая броня
-
щиты
-
перчатки
-
сапоги
+
шлемы
+
тяжелая броня
+
легкая броня
+
щиты
+
перчатки
+
сапоги
Ювелирные товары:
-
серьги
-
ожерелья
-
кольца
+
серьги
+
ожерелья
+
кольца
Магия:
-
боевые
-
разные
+
боевые
+
разные
Разное:
-
амуниция
-
букеты
+
амуниция
+
букеты
-
diff --git a/classes/Item.php b/classes/Item.php index 54fc8e9..26afae7 100644 --- a/classes/Item.php +++ b/classes/Item.php @@ -98,64 +98,6 @@ abstract class Item } } - // ТА ЛААААДНО?! -// $this->name = $row['name']; -// $this->massa = $row['massa']; -// $this->maxdur = $row['maxdur']; -// $this->img = $row['img']; -// -// $this->type = $row['type']; -// -// $this->nlevel = $row['nlevel']; -// $this->nalign = $row['nalign']; -// $this->nsila = $row['nsila']; -// $this->nlovk = $row['nlovk']; -// $this->ninta = $row['ninta']; -// $this->nvinos = $row['nvinos']; -// $this->nintel = $row['nintel']; -// $this->nmudra = $row['nmudra']; -// $this->nnoj = $row['nnoj']; -// $this->ntopor = $row['ntopor']; -// $this->ndubina = $row['ndubina']; -// $this->nmech = $row['nmech']; -// $this->nfire = $row['nfire']; -// $this->nwater = $row['nwater']; -// $this->nair = $row['nair']; -// $this->nearth = $row['nearth']; -// $this->nlight = $row['nlight']; -// $this->ngray = $row['ngray']; -// $this->ndark = $row['ndark']; -// -// $this->minu = $row['minu']; -// $this->maxu = $row['maxu']; -// -// $this->gsila = $row['gsila']; -// $this->glovk = $row['glovk']; -// $this->ginta = $row['ginta']; -// $this->gintel = $row['gintel']; -// $this->gnoj = $row['gnoj']; -// $this->gtopor = $row['gtopor']; -// $this->gdubina = $row['gdubina']; -// $this->gmech = $row['gmech']; -// $this->gfire = $row['gfire']; -// $this->gwater = $row['gwater']; -// $this->gair = $row['gair']; -// $this->gearth = $row['gearth']; -// $this->glight = $row['glight']; -// $this->ggray = $row['ggray']; -// $this->gdark = $row['gdark']; -// $this->ghp = $row['ghp']; -// -// $this->bron1 = $row['bron1']; -// $this->bron2 = $row['bron2']; -// $this->bron3 = $row['bron3']; -// $this->bron4 = $row['bron4']; -// -// $this->mfkrit = $row['mfkrit']; -// $this->mfakrit = $row['mfakrit']; -// $this->mfuvorot = $row['mfuvorot']; -// $this->mfauvorot = $row['mfauvorot']; - switch ($this->type) { case 1: $this->typename = 'Серьги'; diff --git a/classes/ShopItem.php b/classes/ShopItem.php index 70c917d..633c87a 100644 --- a/classes/ShopItem.php +++ b/classes/ShopItem.php @@ -10,19 +10,46 @@ class ShopItem extends Item parent::printMagic(); } + public function buyItem($owner) + { + if ($owner) { + db::c()->query(' + INSERT INTO `inventory` (`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`, + `ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`, + `needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`, + `nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`, + `bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`, + `artefact`, `koll`) VALUES (?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,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,"?s",?i,?i) + ', $this->id, $owner, $this->name, $this->type, $this->massa, $this->cost, $this->img, $this->maxdur,$this->isrep,$this->gsila,$this->glovk,$this->ginta,$this->gintel, + $this->ghp,$this->gnoj,$this->gtopor,$this->gdubina,$this->gmech,$this->gfire,$this->gwater,$this->gair,$this->gearth,$this->glight,$this->ggray,$this->gdark, + $this->needident,$this->nsila,$this->nlovk,$this->ninta,$this->nintel,$this->nmudra,$this->nvinos, $this->nnoj,$this->ntopor,$this->ndubina,$this->nmech, + $this->nfire,$this->nwater,$this->nair, $this->nearth,$this->nlight,$this->ngray,$this->ndark,$this->mfkrit,$this->mfakrit,$this->mfuvorot,$this->mfauvorot, + $this->bron1,$this->bron2,$this->bron3,$this->bron4,$this->maxu,$this->minu,$this->magic,$this->nlevel,$this->nalign,$this->dategoden,$this->goden,$this->razdel, + $this->artefact, $this->koll); + } + } + /** * Для кнопок управления под картинкой прелмета в зависимости от ситуации. */ - public function printControls($sell = false) + public function printControls($shopType = false) { - if ($sell) { - $btnPrice = "Продать"; - $btnLink = "/shop.php?sell={$this->id}&rnd=".mt_rand(); - $this->maxdur = 0; - } else { - $btnPrice = "Купить за " . intval($this->cost) . " кр."; - $btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand(); + switch ($shopType) { + default: + $btnPrice = "Купить за " . intval($this->cost) . " кр."; + $btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand(); + break; + case 'ashop': + $btnPrice = "Купить за " . intval($this->ecost) . " eкр."; + $btnLink = "/ashop.php?buy={$this->id}&rnd=" . mt_rand(); + break; + case 'sell': + $btnPrice = "Продать"; + $btnLink = "/shop.php?sell={$this->id}&rnd=".mt_rand(); + break; } + echo << diff --git a/functions.php b/functions.php index 5f55091..f2ed1fd 100644 --- a/functions.php +++ b/functions.php @@ -1612,7 +1612,7 @@ function showitem2() * По ходу, главная функция отображения предметов. * * @param array $row - массив значений, передаваймый из запроса к таблице inventory - * @param int $type - тип предмета. Где бы их всех взять? + * @param int $type - тип предмета. Перечислены в /Classes/Item.php * @param bool $returned * @param bool $infOnly * @@ -1688,8 +1688,6 @@ function showitem($row, $type = null, $returned = false, $infOnly = false) $returnHTML .= '
ID: ' . $row['id'] . '
'; if ($row["koll"] > 1) $returnHTML .= " "; $returnHTML .= ""; - } else { - $returnHTML .= "Улучшить"; } } diff --git a/presents.php b/presents.php new file mode 100644 index 0000000..1f58efe --- /dev/null +++ b/presents.php @@ -0,0 +1,125 @@ + + + + + + + + + +

Магазин подарков

+ +query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc(); + if ($_POST['to_login'] == $user['login']) { + err('Очень щедро - дарить что-то самому себе! ;)'); + } elseif ($to['room'] > 500 && $to['room'] < 561) { + err('Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.'); + } else { + if ($_POST['from'] == 1) { + $from = 'Аноним'; + } elseif ($_POST['from'] == 2 && $user['klan']) { + $from = ' клана ' . $user['klan']; + } else { + $from = $user['login']; + } + + db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['podarok2'], null, $_POST['flower'], $_SESSION['uid']); + $res = db::c()->query('SELECT `id`,`name`,`duration`,`maxdur` FROM `inventory` WHERE `id` = ?i', $_POST['flower'])->fetch_assoc(); + $deloTextSender = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\""; + $deloTextReceiver = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\""; + db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $_SESSION['uid'], $deloTextSender, time()); + db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $to['id'], $deloTextReceiver, time()); + + $telegraphText = "Вам пришёл подарок \"" . $res['name'] . "\" от " . $from . "!"; + db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc(); + + err('Подарок удачно доставлен к ' . $_POST['to_login']); + } + } +} +?> + + +
+
+ + Вы можете сделать подарок дорогому человеку. Ваш подарок будет + отображаться в информации о персонаже. +
    +
  1. Укажите логин персонажа, которому хотите сделать подарок
    + +
  2. +
  3. +
  4. Выберите, от чьего имени подарок:
    +
    +
    +
    +
  5. Нажмите кнопку Подарить под предметом, который хотите + преподнести в подарок:
    +
+ + + query('SELECT `id`,`img` FROM `inventory` WHERE `owner`= ?i + AND `dressed` = 0 + AND ( + `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR + `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" + ) + AND `setsale` = 0 AND `present` = "?s" + ORDER BY `id` DESC', $_SESSION['uid'], '%Букет%', '%Сувенир%', '%Подарок%', '%Валентинка%', '%Открытка%', 'Ель%', '%Медаль%', '%Статуэтка%', null); + while ($row = $data->fetch_assoc()) { + if (!in_array($row['id'], array_keys($_SESSION['flowers']))) { + $row['count'] = 1; + ?> + + + + + + + +
+ +
+ value="Подарить"> +
+ +
+ + + + \ No newline at end of file diff --git a/shop.php b/shop.php index 4110c24..f06990a 100644 --- a/shop.php +++ b/shop.php @@ -2,7 +2,7 @@ ob_start(); session_start(); if ($_SESSION['uid'] == null) header("Location: index.php"); -require_once("functions.php"); +require_once 'functions.php'; if ($user['room'] != 22) { header("Location: main.php"); @@ -101,7 +101,10 @@ FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `c `magic`.`img` AS `magic_img`, 0 AS `maxdur` -FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND `tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 AND `owner` = ?i ORDER BY `update` DESC', null, $_SESSION['uid']); +FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE + `dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND + `tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 AND `artefact` = 0 AND `owner` = ?i +ORDER BY `update` DESC', null, $_SESSION['uid']); $iteminfo = []; while ($row = $inventoryItems->fetch_assoc()) { @@ -113,14 +116,14 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 $sellItemId = filter_input(INPUT_GET, 'sell'); if ($sellItemId) { - $dress = db::c()->query('SELECT `id`, `name`, `cost`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc(); + $dress = db::c()->query('SELECT `id`, `name`, `cost`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `artefact` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc(); $kols = ''; if ($dress['koll']) { $dress['cost'] *= $dress['koll']; $kols = " (x{$dress['koll']}) "; } - $allcost = mt_rand(0,$dress['cost']/2); + $allcost = mt_rand(0, $dress['cost'] / 2); db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $dress['id']); db::c()->query('UPDATE `users` SET `money` = `money` + ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']); if ($allcost == 0) $status = "После длительных и изнурительных торгов вы плюнули на всё и просто подарили ваш «{$dress['name']}» торговцу."; @@ -151,6 +154,7 @@ if (!empty($_GET['buy'])) { 'glovk' => $dress['glovk'], 'ginta' => $dress['ginta'], 'gintel' => $dress['gintel'], + 'ghp' => $dress['ghp'], 'gnoj' => $dress['gnoj'], 'gtopor' => $dress['gtopor'], @@ -163,6 +167,7 @@ if (!empty($_GET['buy'])) { 'glight' => $dress['glight'], 'ggray' => $dress['ggray'], 'gdark' => $dress['gdark'], + 'needident' => $dress['needident'], 'nsila' => $dress['nsila'], 'nlovk' => $dress['nlovk'], @@ -174,6 +179,19 @@ if (!empty($_GET['buy'])) { 'ntopor' => $dress['ntopor'], 'ndubina' => $dress['ndubina'], 'nmech' => $dress['nmech'], + + 'nfire' => $dress['nfire'], + 'nwater' => $dress['nwater'], + 'nair' => $dress['nair'], + 'nearth' => $dress['nearth'], + 'nlight' => $dress['nlight'], + 'ngray' => $dress['ngray'], + 'ndark' => $dress['ndark'], + 'mfkrit' => $dress['mfkrit'], + 'mfakrit' => $dress['mfakrit'], + 'mfuvorot' => $dress['mfuvorot'], + 'mfauvorot' => $dress['mfauvorot'], + 'bron1' => $dress['bron1'], 'bron2' => $dress['bron2'], 'bron3' => $dress['bron3'], @@ -187,10 +205,10 @@ if (!empty($_GET['buy'])) { 'goden' => $dress['goden'], 'gmp' => $dress['gmp'], 'artefact' => $dress['artefact'], - 'koll' => $dress['koll'] + 'koll' => $dress['koll'], ]; - 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,?i,?i,?i]', $newItem); + 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,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i]', $newItem); $inventoryItemId = db::c()->getLastInsertId(); if ($dress['count'] != -1) db::c()->query('UPDATE `shop` SET `count` = `count` - 1 WHERE `id` = ?i', $_GET['buy']); $status = "Вы купили «{$dress['name']}» за {$dress['cost']} кр."; @@ -222,75 +240,66 @@ if (!empty($_GET['buy'])) { diff --git a/upgrade_items.php b/upgrade_items.php deleted file mode 100644 index 1bf6886..0000000 --- a/upgrade_items.php +++ /dev/null @@ -1,75 +0,0 @@ -query('SELECT `id`,`name`,`nlevel` FROM `inventory` WHERE `owner` = ?i AND `id`= ?i AND `artefact`=1', $user['id'], $ids)->fetch_assoc(); - if ($cur['id']) { - $up_level = $cur['nlevel'] + 1; - $cur_up = db::c()->query('SELECT * FROM `ashop_up` WHERE `name` = "?s" AND `level_up` = ?i', $cur['name'], $up_level)->fetch_assoc(); - if ($cur_up['id']) { - - //mysql_query("UPDATE `inventory` SET `upgrade`='" . $cur_up['level_up'] . "',`nlevel`='" . $cur_up['level_up'] . "',`minu`='" . $cur_up['minu'] . "',`maxu`='" . $cur_up['maxu'] . "',`gsila`='" . $cur_up['gsila'] . "',`glovk`='" . $cur_up['glovk'] . "',`ginta`='" . $cur_up['ginta'] . "',`gintel`='" . $cur_up['gintel'] . "',`ghp`='" . $cur_up['ghp'] . "',`mfkrit`='" . $cur_up['mfkrit'] . "',`mfakrit`='" . $cur_up['mfakrit'] . "',`mfuvorot`='" . $cur_up['mfuvorot'] . "',`mfauvorot`='" . $cur_up['mfauvorot'] . "',`gnoj`='" . $cur_up['gnoj'] . "',`gtopor`='" . $cur_up['gtopor'] . "',`gdubina`='" . $cur_up['gdubina'] . "',`gmech`='" . $cur_up['gmech'] . "',`bron1`='" . $cur_up['bron1'] . "',`bron2`='" . $cur_up['bron2'] . "',`bron3`='" . $cur_up['bron3'] . "',`bron4`='" . $cur_up['bron4'] . "' WHERE `owner`='" . $user['id'] . "' AND `id`='" . $cur['id'] . "'"); - err('Услуга недоступна!'); - //echo "Артефакт успешно улучшен!"; - - } else { - err('Артефакт достиг максимального уровня!'); - } - } -} - -$itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc(); -$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc(); -$artefactsList = db::c()->query('SELECT * FROM `inventory` WHERE `owner`=?i AND `artefact`=1', $user['id']); -?> - - - - - - - -

Магазин Берёзка

-
Зал улучшения артефактов.
- -
+

+ +
Вы можете продать ваши предметы за сущие копейки.
+ - - - - - - - +
-

- - Вы можете продать ваши предметы за сущие копейки. - -
- - "; - echo ""; - } - } else { - foreach ($iteminfo as $ii) { - echo ""; - echo ""; - } - } - ?> -
"; - $ii->printImage(); - $ii->printControls(true); - echo ""; - $ii->printInfo(); - echo "
"; - $ii->printImage(); - $ii->printControls(); - echo ""; - $ii->printInfo(); - echo "
-
+ "; + echo ""; + } + } else { + foreach ($iteminfo as $ii) { + echo ""; + echo ""; + } + } + ?>
"; + $ii->printImage(); + $ii->printControls('sell'); + echo ""; + $ii->printInfo(); + echo "
"; + $ii->printImage(); + $ii->printControls(); + echo ""; + $ii->printInfo(); + echo "
Масса всех ваших вещей:
У вас в наличии: кр.

+
Отделы магазина
Продать вещи
Оружие:
-
кинжалы
-
топоры
-
дубины
-
мечи
+
кинжалы
+
топоры
+
дубины
+
мечи
Одежда:
-
шлемы
-
тяжелая броня
-
легкая броня
-
щиты
-
перчатки
-
сапоги
+
шлемы
+
тяжелая броня
+
легкая броня
+
щиты
+
перчатки
+
сапоги
Ювелирные товары:
-
серьги
-
ожерелья
-
кольца
+
серьги
+
ожерелья
+
кольца
Магия:
-
боевые
-
разные
+
боевые
+
разные
Разное:
-
амуниция
-
руны
+
амуниция
+
руны
- - - - -
- - fetch_assoc()) { - if ($i == 0) { - $i = 1; - $color = '#C7C7C7'; - } else { - $i = 0; - $color = '#D5D5D5'; - } - showitem($row, 10); - } - ?> -
-
- Масса всех ваших вещей: -
У вас в наличии: екр.
-
- Магазин Берёзка -
-
- -