Удаление зоомагазина, книжного магазина, аукциона, арены, алтаря крови, турнирного магазина. #54
This commit is contained in:
@@ -9,38 +9,39 @@ use User;
|
||||
|
||||
class Shop
|
||||
{
|
||||
private int $shopId;
|
||||
private array $wares;
|
||||
private int $otdel;
|
||||
private int $itemId;
|
||||
private $buyer;
|
||||
private const ITEM_GENERATION_CURRENT = 2;
|
||||
public const MAIN = 1;
|
||||
public const BEREZKA = 2;
|
||||
public const CRYSTALS = 1050; //магазин самоцветов
|
||||
public const REFERALS = 27; //магазин рефералов
|
||||
public const TEMPLE = 14; // храм?!
|
||||
public const IZLOM = 10; // излом?!
|
||||
public const LABORATORY = 45; //лаборатория?!?!
|
||||
public const ARTEFACTS = 777;
|
||||
public const BOOKS = 7;
|
||||
public const KNIGHTS_MAIN = 400; // общий рыцарский
|
||||
public const DUNGEON_BEZDNA = 801; // бездна
|
||||
public const DUNGEON_PTP = 802; // пещера тысячи проклятий
|
||||
public const DUNGEON_CATACOMBS = 803; // катакомбы
|
||||
public const DUNGEON_MISTY = 804; // пещера мглы
|
||||
public const FLOWER = 6;
|
||||
public const MUSHROOMS = 17; // магазин грибоеда??
|
||||
public const RULF_HRUNT = 33; // магазин рульфа хрунта, а ты что такое?
|
||||
public const LUKA = 5; // каморка Луки
|
||||
public const BLOOD_ALTAR = 11; //алтарь крови
|
||||
public const ANVIL = 700; // наковальня
|
||||
public const NEWBIE = 106; // магазин новичка
|
||||
public const SHOP_2 = 609; // неизвестный магазин
|
||||
public const SHOP_KAT = 44; // неизвестный магазин
|
||||
public const SHOP_PRIZ = 404; // неизвестный магазин
|
||||
public const TAVERN = 9;
|
||||
public const ANIMALS = 8;
|
||||
public const CRYSTALS = 1050;
|
||||
public const REFERALS = 27;
|
||||
public const TEMPLE = 14;
|
||||
public const IZLOM = 10;
|
||||
public const LABORATORY = 45;
|
||||
public const ARTEFACTS = 777; //магазин самоцветов
|
||||
public const KNIGHTS_MAIN = 400; //магазин рефералов
|
||||
public const DUNGEON_BEZDNA = 801; // храм?!
|
||||
public const DUNGEON_PTP = 802; // излом?!
|
||||
public const DUNGEON_CATACOMBS = 803; //лаборатория?!?!
|
||||
public const DUNGEON_MISTY = 804;
|
||||
//public const BOOKS = 7;
|
||||
public const MUSHROOMS = 17; // общий рыцарский
|
||||
public const RULF_HRUNT = 33; // бездна
|
||||
public const LUKA = 5; // пещера тысячи проклятий
|
||||
public const ANVIL = 700; // катакомбы
|
||||
public const NEWBIE = 106; // пещера мглы
|
||||
//public const FLOWER = 6;
|
||||
public const SHOP_2 = 609; // магазин грибоеда??
|
||||
public const SHOP_KAT = 44; // магазин рульфа хрунта, а ты что такое?
|
||||
public const SHOP_PRIZ = 404; // каморка Луки
|
||||
//public const BLOOD_ALTAR = 11; //алтарь крови
|
||||
public const TAVERN = 9; // наковальня
|
||||
public const ANIMALS = 8; // магазин новичка
|
||||
private int $shopId; // неизвестный магазин
|
||||
private array $wares; // неизвестный магазин
|
||||
private int $otdel; // неизвестный магазин
|
||||
private int $itemId;
|
||||
private $buyer;
|
||||
|
||||
public function __construct(int $shopId)
|
||||
{
|
||||
$this->otdel = intval($_GET['otdel']);
|
||||
@@ -103,105 +104,6 @@ class Shop
|
||||
|
||||
}
|
||||
|
||||
private function changeItemPositionByInt(int $modificator)
|
||||
{
|
||||
Db::sql('update items_shop set pos = pos + ? where sid = ? and r = ? and item_id = ? and kolvo > 0',
|
||||
[$modificator, $this->shopId, $this->otdel, $this->itemId]);
|
||||
}
|
||||
|
||||
private function itemUp()
|
||||
{
|
||||
$this->changeItemPositionByInt(-1);
|
||||
}
|
||||
|
||||
private function itemDown()
|
||||
{
|
||||
$this->changeItemPositionByInt(1);
|
||||
}
|
||||
|
||||
private function calculateMinimalPrice($basePrice, $shopPrice, $needItems)
|
||||
{
|
||||
if ($shopPrice < 0.01 && !$needItems) {
|
||||
$shopPrice = $basePrice;
|
||||
}
|
||||
if ($shopPrice < 0) {
|
||||
$shopPrice = 0;
|
||||
}
|
||||
return $shopPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Если в первом параметре передаётся false, строка во втором параметре красится в красный цвет.
|
||||
* @param bool $check
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
private function printColoredValue(bool $check, $value): string
|
||||
{
|
||||
$color = $check ? 'inherit' : 'red';
|
||||
return sprintf('<span style="color:%s;">%s</span>', $color, $value);
|
||||
}
|
||||
|
||||
private function align($needAlign, $needAlignBs): string
|
||||
{
|
||||
if ($needAlignBs == '1') {
|
||||
$align = '1.75';
|
||||
} elseif ($needAlignBs == '3') {
|
||||
$align = '3.01';
|
||||
} elseif (!empty($needAlign) && empty($needAlignBs)) {
|
||||
$align = $needAlign;
|
||||
}
|
||||
|
||||
return !empty($align) ?
|
||||
'<img src="' . Config::img() . '/i/align/align' . $align . '.gif" alt="Требуется склонность">' : '';
|
||||
}
|
||||
|
||||
private function destiny($d): string
|
||||
{
|
||||
if (empty($d)) {
|
||||
return '';
|
||||
}
|
||||
if ($d == 0) {
|
||||
$str = 'первым, кто наденет его';
|
||||
} elseif ($d == 1) {
|
||||
$str = 'первым, кто возьмёт его';
|
||||
} else {
|
||||
$str = $d;
|
||||
}
|
||||
return '<img
|
||||
title="Этот предмет будет связан общей судьбой с ' . $str . '. Никто другой не сможет его использовать."
|
||||
src="' . Config::img() . '/i/destiny0.gif"
|
||||
alt="Общая судьба">';
|
||||
}
|
||||
|
||||
private function needItems(string $items): string
|
||||
{
|
||||
if (!$items || Config::get('noitembuy')) {
|
||||
return '';
|
||||
}
|
||||
$result = '';
|
||||
$trn = true;
|
||||
|
||||
$itemsArray = explode(',', $items);
|
||||
foreach ($itemsArray as $keyvalue) {
|
||||
list($key, $value) = explode('=', $keyvalue);
|
||||
if (!empty($key) && !empty($value)) {
|
||||
$neededItemName = Db::getValue('select name from items_main where id = ?', [$key]);
|
||||
if ($neededItemName) {
|
||||
$neededItemsInInventoryCount = Db::getValue(
|
||||
'select count(*) from items_users where item_id = ? and inShop = 0 and inOdet = 0 and `delete` in (0,1000) and uid = ?',
|
||||
[$key, $this->buyer->getId()]);
|
||||
if ($neededItemsInInventoryCount < (int)$value) {
|
||||
$trn = false;
|
||||
}
|
||||
$result .= '[<strong>' . $neededItemName . '</strong>] x' . $value . ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->printColoredValue($trn, '<br>Требует предмет: ' . rtrim($result, ', ') . ' ') . '<br>';
|
||||
}
|
||||
|
||||
public function printWares(string $plu = '')
|
||||
{
|
||||
if ($this->buyer->isAdmin()) {
|
||||
@@ -643,4 +545,103 @@ class Shop
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
private function itemUp()
|
||||
{
|
||||
$this->changeItemPositionByInt(-1);
|
||||
}
|
||||
|
||||
private function changeItemPositionByInt(int $modificator)
|
||||
{
|
||||
Db::sql('update items_shop set pos = pos + ? where sid = ? and r = ? and item_id = ? and kolvo > 0',
|
||||
[$modificator, $this->shopId, $this->otdel, $this->itemId]);
|
||||
}
|
||||
|
||||
private function itemDown()
|
||||
{
|
||||
$this->changeItemPositionByInt(1);
|
||||
}
|
||||
|
||||
private function calculateMinimalPrice($basePrice, $shopPrice, $needItems)
|
||||
{
|
||||
if ($shopPrice < 0.01 && !$needItems) {
|
||||
$shopPrice = $basePrice;
|
||||
}
|
||||
if ($shopPrice < 0) {
|
||||
$shopPrice = 0;
|
||||
}
|
||||
return $shopPrice;
|
||||
}
|
||||
|
||||
private function align($needAlign, $needAlignBs): string
|
||||
{
|
||||
if ($needAlignBs == '1') {
|
||||
$align = '1.75';
|
||||
} elseif ($needAlignBs == '3') {
|
||||
$align = '3.01';
|
||||
} elseif (!empty($needAlign) && empty($needAlignBs)) {
|
||||
$align = $needAlign;
|
||||
}
|
||||
|
||||
return !empty($align) ?
|
||||
'<img src="' . Config::img() . '/i/align/align' . $align . '.gif" alt="Требуется склонность">' : '';
|
||||
}
|
||||
|
||||
private function destiny($d): string
|
||||
{
|
||||
if (empty($d)) {
|
||||
return '';
|
||||
}
|
||||
if ($d == 0) {
|
||||
$str = 'первым, кто наденет его';
|
||||
} elseif ($d == 1) {
|
||||
$str = 'первым, кто возьмёт его';
|
||||
} else {
|
||||
$str = $d;
|
||||
}
|
||||
return '<img
|
||||
title="Этот предмет будет связан общей судьбой с ' . $str . '. Никто другой не сможет его использовать."
|
||||
src="' . Config::img() . '/i/destiny0.gif"
|
||||
alt="Общая судьба">';
|
||||
}
|
||||
|
||||
/**
|
||||
* Если в первом параметре передаётся false, строка во втором параметре красится в красный цвет.
|
||||
* @param bool $check
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
private function printColoredValue(bool $check, $value): string
|
||||
{
|
||||
$color = $check ? 'inherit' : 'red';
|
||||
return sprintf('<span style="color:%s;">%s</span>', $color, $value);
|
||||
}
|
||||
|
||||
private function needItems(string $items): string
|
||||
{
|
||||
if (!$items || Config::get('noitembuy')) {
|
||||
return '';
|
||||
}
|
||||
$result = '';
|
||||
$trn = true;
|
||||
|
||||
$itemsArray = explode(',', $items);
|
||||
foreach ($itemsArray as $keyvalue) {
|
||||
[$key, $value] = explode('=', $keyvalue);
|
||||
if (!empty($key) && !empty($value)) {
|
||||
$neededItemName = Db::getValue('select name from items_main where id = ?', [$key]);
|
||||
if ($neededItemName) {
|
||||
$neededItemsInInventoryCount = Db::getValue(
|
||||
'select count(*) from items_users where item_id = ? and inShop = 0 and inOdet = 0 and `delete` in (0,1000) and uid = ?',
|
||||
[$key, $this->buyer->getId()]);
|
||||
if ($neededItemsInInventoryCount < (int)$value) {
|
||||
$trn = false;
|
||||
}
|
||||
$result .= '[<strong>' . $neededItemName . '</strong>] x' . $value . ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->printColoredValue($trn, '<br>Требует предмет: ' . rtrim($result, ', ') . ' ') . '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user