From 415d1983517c9563e3adecde959490259a8cf8f1 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Fri, 21 Jan 2022 18:17:56 +0200 Subject: [PATCH] =?UTF-8?q?#49:=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=B8=D1=81=D1=81=D0=B8=D0=BE=D0=BD=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- city.php | 8 +- classes/Battles/City.php | 1 - classes/Battles/Database/DBPDO.php | 10 ++ classes/Battles/Rooms.php | 1 - classes/Battles/Shop.php | 8 +- classes/Battles/Travel.php | 6 +- classes/battle_new.class.php | 1 - comission.php | 158 ----------------------------- cronjobs/cron_bots_battle.php | 1 - functions.php | 1 - locations/central-square/map.php | 1 - locations/central-square2/map.php | 1 - shop.php | 10 +- 13 files changed, 28 insertions(+), 179 deletions(-) delete mode 100644 comission.php diff --git a/city.php b/city.php index 4daf1c5..91765de 100644 --- a/city.php +++ b/city.php @@ -3,6 +3,7 @@ * Центральная площадь */ +use Battles\Database\DBPDO; use Battles\Template; require_once "functions.php"; @@ -11,7 +12,7 @@ if ($user->getZayavka()) { exit; } -$online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time() - 60)); +$online = DBPDO::$db->fetchColumn('select count(*) from online where real_time >= ?', time()-60); $location = explode('/', filter_input(INPUT_SERVER, 'QUERY_STRING')); switch ($location[0]) { @@ -73,9 +74,6 @@ switch ($location[0]) { case 'level6': Battles\Travel::toRoom(27,$user->getRoom()); break; - case 'level3': - Battles\Travel::toRoom(25,$user->getRoom()); - break; } } elseif ($user->getRoom() == 21) { switch ($location[1]) { @@ -198,7 +196,7 @@ switch ($location[0]) { } Template::header('city'); -echo sprintf('
Сейчас в игре: %s игроков.>
', $online->getNumRows()); +echo sprintf('
Сейчас в игре: %s игроков.>
', $online); if (in_array($user->getRoom(), [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) { /* Улицы: * 20 Центральная diff --git a/classes/Battles/City.php b/classes/Battles/City.php index d5f4b99..ccf785f 100644 --- a/classes/Battles/City.php +++ b/classes/Battles/City.php @@ -10,7 +10,6 @@ class City echo '
background' . self::showBuilding(1, "spring_cap_club", 30, 235, self::$roomNames[1]) . self::showBuilding(2, "spring_cap_shop", 202, 171, self::$roomNames[22]) . - self::showBuilding(3, "spring_cap_kom", 205, 105, self::$roomNames[25]) . self::showBuilding(4, "spring_cap_rem", 202, 290, self::$roomNames[23]) . self::showBuilding(6, "spring_cap_po4ta", 180, 540, self::$roomNames[27]) . self::showBuilding(7, "cap_arr_right", 260, 710, self::$roomNames[21]) . diff --git a/classes/Battles/Database/DBPDO.php b/classes/Battles/Database/DBPDO.php index 5ce447f..0038989 100644 --- a/classes/Battles/Database/DBPDO.php +++ b/classes/Battles/Database/DBPDO.php @@ -141,4 +141,14 @@ class DBPDO { return $this->pdo->lastInsertId(); } + + function fetchColumn($query, $values = null) { + if (is_null($values)) { + $values = []; + } elseif (!is_array($values)) { + $values = [$values]; + } + $stmt = $this->execute($query, $values); + return $stmt->fetchColumn(); + } } \ No newline at end of file diff --git a/classes/Battles/Rooms.php b/classes/Battles/Rooms.php index 9864a26..469d06a 100644 --- a/classes/Battles/Rooms.php +++ b/classes/Battles/Rooms.php @@ -13,7 +13,6 @@ trait Rooms 22 => "Магазин", 23 => "Ремонтная мастерская", 24 => "Памятник Архангелу", - 25 => "Комиссионный магазин", 26 => "Большая парковая улица", 27 => "Почта", 29 => "Банк", diff --git a/classes/Battles/Shop.php b/classes/Battles/Shop.php index 1d22902..ebe8b74 100644 --- a/classes/Battles/Shop.php +++ b/classes/Battles/Shop.php @@ -42,8 +42,12 @@ class Shop $stmt = DBPDO::$db->ofetchall('select * from inventory where on_sale = 0 and dressed_slot = 0 and durability > 0 and owner_id = ?', User::$current->getId()); $iteminfo = []; + $operationType = 'sellshop'; + if ($this->categoryType === self::BARTER_SHOP) { + $operationType = 'setmarket'; + } foreach ($stmt as $item) { - $iteminfo[] = new ShopItem($item, 'sellshop'); + $iteminfo[] = new ShopItem($item, $operationType); } return $this->strFromArr($iteminfo); } @@ -81,6 +85,6 @@ class Shop public function getItemsList(): string { - return $this->categoryType !== self::CATEGORY_SALE_ITEMS ? $this->showGoods() : $this->showUserSellItems(); + return $this->categoryType !== self::CATEGORY_SALE_ITEMS || $this->categoryType !== self::BARTER_SHOP ? $this->showGoods() : $this->showUserSellItems(); } } \ No newline at end of file diff --git a/classes/Battles/Travel.php b/classes/Battles/Travel.php index 4d148a8..a741633 100644 --- a/classes/Battles/Travel.php +++ b/classes/Battles/Travel.php @@ -16,7 +16,6 @@ class Travel 21 => 'city.php', 22 => 'shop.php', 23 => 'repair.php', - 25 => 'comission.php', 26 => 'city.php', 27 => 'post.php', 29 => 'bank.php', @@ -97,7 +96,6 @@ class Travel /* * 1 location: main.php?goto=arena * 2 Room 22 shop.php - * 3 Room 25 comission.php * 4 Room 23 repair.php * 6 Room 27 posr.php * 7 Room 21 [STREET] @@ -105,8 +103,8 @@ class Travel * 13 location: quest_room.php * 222 Room 2702 [STREET] */ - $room[20] = [1, 21, 22, 23, 25, 26, 27, 2702]; - $room[1] = $room[22] = $room[23] = $room[25] = $room[27] = [20]; + $room[20] = [1, 21, 22, 23, 26, 27, 2702]; + $room[1] = $room[22] = $room[23] = $room[27] = [20]; /* * 3 Room 2111 [STREET] * 4 Room 20 [STREET] diff --git a/classes/battle_new.class.php b/classes/battle_new.class.php index bec76a5..64d55b9 100644 --- a/classes/battle_new.class.php +++ b/classes/battle_new.class.php @@ -474,7 +474,6 @@ class fbattle 'Жизнь вне нашего клуба - это пустая трата кислорода!!!', 'Жми! Дави! Кусай! Царапай!', 'За такие бои надо в хаос отправлять!', - 'Знаете откуда в комиссионном магазине столько вещей? Это я после ваших гулянок собираю и сдаю туда. Иногда вместе с частями тела, застрявшими в них.', 'Здесь люди так близки друг к другу. Просто иначе ударить нельзя.', 'И пролитая кровь еще пульсирует...', 'Инвалидов развелось...', diff --git a/comission.php b/comission.php deleted file mode 100644 index 82f9606..0000000 --- a/comission.php +++ /dev/null @@ -1,158 +0,0 @@ - ['min_range' => 1]]); -$putItemId = (int)filter_input(INPUT_POST, 'putId', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); -$returningItemId = (int)filter_input(INPUT_GET, 'back', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); -$byingItemId = (int)filter_input(INPUT_GET, 'set', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); - -if ($putItemId) { - $query = 'select name from inventory where dressed_slot = 0 and owner_id = ? and item_id = ?'; - DBPDO::INIT()->ofetch($query, [$_SESSION['uid'], $putItemId]); - $dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`cost` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $putItemId, $_SESSION['uid'])->fetch_assoc(); - if (empty($putItemCost)) { - $putItemCost = $dress['cost']; - } - $commission = ceil($putItemCost / 10); # 10% от суммы с округлением вверх. - if ($user->getMoney() > $commission) { - - if (db::c()->getAffectedRows()) { - $deloText = "{$user->getLogin()} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. "; - GameLogs::addUserLog($user->getId(), $deloText); - db::c()->query('UPDATE `inventory` SET `setsale` = ?i WHERE `id` = ?i', $putItemCost, $putItemId); - db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $commission, $_SESSION['uid']); - $status = "Вы сдали в магазин «{$dress['name']}» за {$putItemCost} кр. Вычтено за услуги магазина: {$commission} кр."; - } else { - $status = "Предмет не найден в инвентаре!"; - } - } else { - $status = "У вас не хватает " . $commission - $user->getMoney() . " кр. чтобы оплатить комиссию!"; - } -} - -if ($returningItemId) { - $dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i AND `owner` = ?i', $returningItemId, $_SESSION['uid'])->fetch_assoc(); - if (db::c()->getAffectedRows()) { - $deloText = "{$user->getLogin()} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки."; - GameLogs::addUserLog($user->getId(), $deloText); - db::c()->query('UPDATE `inventory` SET `setsale` = 0 WHERE `id` = ?i', $returningItemId); - $status = "Вы забрали из магазина ваш «{$dress['name']}»."; - } else { - $status = "Предмет не найден на полках магазина!"; - } -} - -if ($byingItemId) { - $dress = db::c()->query('SELECT `name`,`owner`,`duration`,`maxdur`,`setsale` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i', $byingItemId)->fetch_assoc(); - $seller = db::c()->query('SELECT `login` FROM `users` WHERE `id` =?i', $dress['owner'])->fetch_assoc(); - - if ($dress['setsale']) { - if ($user->getMoney() >= $dress['setsale']) { - db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $user->getId(), $byingItemId); - db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $user->getId()); - db::c()->query('UPDATE `users` set `money` = `money` + ?i WHERE `id` = ?i', $dress['setsale'], $dress['owner']); - $status = "Вы купили «{$dress['name']}» за {$dress['setsale']} кр."; - $deloText = "{$user->getLogin()} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр."; - GameLogs::addUserLog($user->getId(), $deloText); - $deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user->getLogin()} за {$dress['setsale']} кр."; - GameLogs::addUserLog($dress['owner'], $deloText); - $user->setMoney($user->getMoney() - $dress['setsale']); - telegraph($dress['owner'], "Предмет «{$dress['name']}» продан на рынке за {$dress['setsale']} кр."); - } else { - $status = "Недостаточно средств!"; - } - } else { - $status = "Предмет не найден на полках магазина!"; - } -} - -$classPrintControlName = "marketbuy"; - -if ($get === 'sale') { - $search = $_SESSION['uid']; - $query = 'select * from inventory where on_sale = 0 and dressed_slot = 0 and present is null and owner_id = ? order by name'; - $classPrintControlName = "marketput"; -} elseif ($get === 'unsale') { - $search = $_SESSION['uid']; - $query = 'select * from inventory where on_sale > 0 and dressed_slot = 0 and owner_id = ? order by name'; - $classPrintControlName = "marketgetback"; -} else if (!empty($_POST['search'])) { - $search = "%{$_POST['search']}%"; - $query = 'select * from inventory where on_sale > 0 and dressed_slot = 0 and name like ? order by item_id'; -} else { - $query = 'select * from inventory where on_sale > 0 and dressed_slot = 0 order by name'; -} - -if (isset($search)) { - $data = DBPDO::INIT()->ofetchAll($query, $search); - unset($search); -} else { - $data = DBPDO::INIT()->ofetchAll($query); -} - -$iteminfo = []; -foreach ($data as $itemObject) { - $iteminfo[] = new ShopItem($itemObject, 'buymarket'); -} - -Template::header('Рынок'); -?> - -

Рынок

- ← выйти на Центральную площадь -
- - -
- - - -
- - Выставить товар на продажу. -
Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет. - - Забрать свой товар. - - Список товаров.
-
- -
- -
- - "; - echo ""; - } - ?> -
"; - $ii->printImage(); - $ii->printControls($classPrintControlName); - echo ""; - $ii->printInfo(); - echo "
-
-
-
- Масса всех ваших вещей: -
У вас в наличии: кр.
-
-
- -
- -
- -
- -
-
\ No newline at end of file diff --git a/cronjobs/cron_bots_battle.php b/cronjobs/cron_bots_battle.php index d1b376d..074dc4e 100644 --- a/cronjobs/cron_bots_battle.php +++ b/cronjobs/cron_bots_battle.php @@ -1772,7 +1772,6 @@ class fbattle 'Жизнь вне нашего клуба - это пустая трата кислорода!!!', 'Жми! Дави! Кусай! Царапай!', 'За такие бои надо в хаос отправлять!', - 'Знаете откуда в комиссионном магазине столько вещей? Это я после ваших гулянок собираю и сдаю туда. Иногда вместе с частями тела, застрявшими в них.', 'Здесь люди так близки друг к другу. Просто иначе ударить нельзя.', 'И пролитая кровь еще пульсирует...', 'Инвалидов развелось...', diff --git a/functions.php b/functions.php index c41c0b4..2ec6cd4 100644 --- a/functions.php +++ b/functions.php @@ -34,7 +34,6 @@ $fbattleCheckFiles = [ 'c_park.php', 'city.php', 'clan_castle.php', - 'comission.php', 'enter_cave.php', 'library.php', 'atk.php', diff --git a/locations/central-square/map.php b/locations/central-square/map.php index 889f9be..666d2b3 100644 --- a/locations/central-square/map.php +++ b/locations/central-square/map.php @@ -23,7 +23,6 @@ $imgPath = '/locations/central-square/img/'.$now->getTimeOfDay();
-
diff --git a/locations/central-square2/map.php b/locations/central-square2/map.php index df60fd7..ed4aa63 100644 --- a/locations/central-square2/map.php +++ b/locations/central-square2/map.php @@ -23,7 +23,6 @@ $imgPath = '/locations/central-square/img/'.$now->getTimeOfDay();
-
diff --git a/shop.php b/shop.php index 71bb3c6..10e4e4f 100644 --- a/shop.php +++ b/shop.php @@ -10,11 +10,15 @@ use Battles\User; require_once 'functions.php'; Shop::$current = new Shop(Shop::GENERAL_SHOP); if (!empty($_GET['otdel'])) { - if ($_GET['otdel'] !== 'sale') { - Shop::$current->categoryType = $_GET['otdel']; - } else { + if ($_GET['otdel'] === 'sale') { Shop::$current->categoryType = Shop::CATEGORY_SALE_ITEMS; } + elseif ($_GET['otdel'] === 'market') { + Shop::$current->categoryType = Shop::BARTER_SHOP; + } + else { + Shop::$current->categoryType = $_GET['otdel']; + } } if (!empty($_POST['sellshop'])) {