648 lines
43 KiB
PHP
648 lines
43 KiB
PHP
<?php
|
||
|
||
use Core\Db;
|
||
use Helper\Conversion;
|
||
use Model\Constant\Stat;
|
||
use User\ItemsModel;
|
||
|
||
class ComissionShop
|
||
{
|
||
private array $info;
|
||
private array $stats;
|
||
private array $is;
|
||
private array $rep;
|
||
/**
|
||
* @var array|string[]
|
||
*/
|
||
private array $align_nm;
|
||
private array $items;
|
||
|
||
public function __construct()
|
||
{
|
||
$this->info = User::start()->info;
|
||
$this->rep = User::start()->rep;
|
||
$this->stats = User::start()->stats;
|
||
$this->is = User::start()->is;
|
||
$this->align_nm = User::start()->align_nm;
|
||
$itemStatNames = new Stat();
|
||
$itemStatNames->getBonus();
|
||
$itemStatNames->getRequirement();
|
||
$this->items['tr'] = $itemStatNames->sysRequirementNames;
|
||
}
|
||
|
||
public function commisionShop($preview = 'full'): void
|
||
{
|
||
global $code;
|
||
$typeOtdel = match ((int)$_GET['otdel']) {
|
||
2 => 19,
|
||
3 => 20,
|
||
4 => 21,
|
||
5 => 22,
|
||
6 => 15,
|
||
7 => 12,
|
||
8 => 4,
|
||
9 => 5,
|
||
10 => 6,
|
||
11 => 1,
|
||
12 => 3,
|
||
13 => 8,
|
||
14 => 14,
|
||
15 => 13,
|
||
16 => 9,
|
||
17 => 10,
|
||
18 => 11,
|
||
19 => 29,
|
||
20 => 30,
|
||
1050 => 1050,
|
||
default => 18,
|
||
};
|
||
if ($typeOtdel != 1050) {
|
||
if ($preview == "full") {
|
||
$cl = mysql_query(
|
||
'SELECT `items_users`.`id`,`items_users`.`item_id`,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`,`items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`,`items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`,`items_users`.`lastUPD`,`items_users`.`timeOver`,`items_users`.`overType`,`items_users`.`secret_id`,`items_users`.`time_create`,`items_users`.`inGroup`,`items_users`.`dn_delete`,`items_users`.`inTransfer`,`items_users`.`post_delivery`,`items_users`.`lbtl_`,`items_users`.`bexp`,`items_users`.`so`,`items_users`.`blvl`,`items_main`.`id`,`items_main`.`name`,`items_main`.`img`,`items_main`.`type`,`items_main`.`inslot`,`items_main`.`2h`,`items_main`.`2too`,`items_main`.`iznosMAXi`,`items_main`.`inRazdel`,`items_main`.`price1`,`items_main`.`price2`,`items_main`.`magic_chance`,`items_main`.`info`,`items_main`.`massa`,`items_main`.`level`,`items_main`.`magic_inci`,`items_main`.`overTypei`,`items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`,`items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`,`items_main`.`lvl_aexp`, count(`items_users`.`id`) as inGroupCount
|
||
FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`)
|
||
WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` = "' . mysql_real_escape_string(
|
||
$typeOtdel
|
||
) . '" and `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" GROUP BY `items_users`.`inGroup`, `items_users`.`uid`,`items_users`.`1price` HAVING `items_users`.inGroup > 0
|
||
UNION ALL SELECT `items_users`.`id`,`items_users`.`item_id`,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`,`items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`,`items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`,`items_users`.`lastUPD`,`items_users`.`timeOver`,`items_users`.`overType`,`items_users`.`secret_id`,`items_users`.`time_create`,`items_users`.`inGroup`,`items_users`.`dn_delete`,`items_users`.`inTransfer`,`items_users`.`post_delivery`,`items_users`.`lbtl_`,`items_users`.`bexp`,`items_users`.`so`,`items_users`.`blvl`,`items_main`.`id`,`items_main`.`name`,`items_main`.`img`,`items_main`.`type`,`items_main`.`inslot`,`items_main`.`2h`,`items_main`.`2too`,`items_main`.`iznosMAXi`,`items_main`.`inRazdel`,`items_main`.`price1`,`items_main`.`price2`,`items_main`.`magic_chance`,`items_main`.`info`,`items_main`.`massa`,`items_main`.`level`,`items_main`.`magic_inci`,`items_main`.`overTypei`,`items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`,`items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`,`items_main`.`lvl_aexp`, count(`items_users`.`id`) as inGroupCount
|
||
FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`)
|
||
WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` = "' . mysql_real_escape_string(
|
||
$typeOtdel
|
||
) . '" and `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" GROUP BY `items_users`.`uid`, `items_users`.`1price` HAVING `items_users`.inGroup = 0
|
||
ORDER BY `1price`, inGroupCount DESC'
|
||
);
|
||
} else {
|
||
$cl = mysql_query(
|
||
'SELECT `items_users`.`id`,`items_users`.`item_id`,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`,`items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`,`items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`,`items_users`.`lastUPD`,`items_users`.`timeOver`,`items_users`.`overType`,`items_users`.`secret_id`,`items_users`.`time_create`,`items_users`.`inGroup`,`items_users`.`dn_delete`,`items_users`.`inTransfer`,`items_users`.`post_delivery`,`items_users`.`lbtl_`,`items_users`.`bexp`,`items_users`.`so`,`items_users`.`blvl`,`items_main`.`id`,`items_main`.`name`,`items_main`.`img`,`items_main`.`type`,`items_main`.`inslot`,`items_main`.`2h`,`items_main`.`2too`,`items_main`.`iznosMAXi`,`items_main`.`inRazdel`,`items_main`.`price1`,`items_main`.`price2`,`items_main`.`magic_chance`,`items_main`.`info`,`items_main`.`massa`,`items_main`.`level`,`items_main`.`magic_inci`,`items_main`.`overTypei`,`items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`,`items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`,`items_main`.`lvl_aexp` FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` = "' . mysql_real_escape_string(
|
||
$typeOtdel
|
||
) . '" GROUP BY `items_users`.`item_id` ORDER BY `items_main`.`id` DESC'
|
||
);
|
||
}
|
||
} else {
|
||
if ($preview == "full") {
|
||
$cl = mysql_query(
|
||
'SELECT
|
||
`items_users`.`id` as id, `items_users`.`id` AS `idu`,`items_users`.`item_id` as item_id,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`,
|
||
`items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`,
|
||
`items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`,
|
||
`items_users`.`lastUPD`,`items_users`.`timeOver`,`items_users`.`overType`,`items_users`.`secret_id`,`items_users`.`time_create`,`items_users`.`inGroup`,`items_users`.`dn_delete`,
|
||
`items_users`.`inTransfer`,`items_users`.`post_delivery`,`items_users`.`lbtl_`,`items_users`.`bexp`,`items_users`.`so`,`items_users`.`blvl`,`items_main`.`id` as item_id,`items_main`.`name`,
|
||
`items_main`.`img`,`items_main`.`type`,`items_main`.`inslot`,`items_main`.`2h`,`items_main`.`2too`,`items_main`.`iznosMAXi`,`items_main`.`inRazdel`,`items_main`.`price1`,
|
||
`items_main`.`price2`,`items_main`.`magic_chance`,`items_main`.`info`,`items_main`.`massa`,`items_main`.`level`,`items_main`.`magic_inci`,`items_main`.`overTypei`,
|
||
`items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`,
|
||
`items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`,
|
||
`items_main`.`lvl_aexp` , count(`items_users`.`id`) as inGroupCount
|
||
FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`)
|
||
WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '"
|
||
AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30"
|
||
GROUP BY `items_users`.`inGroup`, `items_users`.`uid`,`items_users`.`1price` HAVING `items_users`.inGroup > 0
|
||
UNION ALL
|
||
SELECT `items_users`.`id` as id, `items_users`.`id` AS `idu`,`items_users`.`item_id` as item_id,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`,
|
||
`items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`,
|
||
`items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`,
|
||
`items_users`.`lastUPD`,`items_users`.`timeOver`,`items_users`.`overType`,`items_users`.`secret_id`,`items_users`.`time_create`,`items_users`.`inGroup`,`items_users`.`dn_delete`,
|
||
`items_users`.`inTransfer`,`items_users`.`post_delivery`,`items_users`.`lbtl_`,`items_users`.`bexp`,`items_users`.`so`,`items_users`.`blvl`,`items_main`.`id` as item_id,`items_main`.`name`,
|
||
`items_main`.`img`,`items_main`.`type`,`items_main`.`inslot`,`items_main`.`2h`,`items_main`.`2too`,`items_main`.`iznosMAXi`,`items_main`.`inRazdel`,`items_main`.`price1`,
|
||
`items_main`.`price2`,`items_main`.`magic_chance`,`items_main`.`info`,`items_main`.`massa`,`items_main`.`level`,`items_main`.`magic_inci`,`items_main`.`overTypei`,
|
||
`items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`,
|
||
`items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`,
|
||
`items_main`.`lvl_aexp`, count(`items_users`.`id`) as inGroupCount
|
||
FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`)
|
||
WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '"
|
||
AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30"
|
||
GROUP BY `items_users`.`uid`,`items_users`.`1price` HAVING `items_users`.inGroup = 0
|
||
ORDER BY `1price`, inGroupCount DESC'
|
||
);
|
||
} else {
|
||
$cl = mysql_query(
|
||
'select items_users.id, items_users.id as idu,items_users.item_id,items_users.`1price`,items_users.`2price`,items_users.uid,items_users.use_text,items_users.data,items_users.inOdet,items_users.inShop,items_users.`delete`,items_users.iznosNOW,items_users.iznosMAX,items_users.gift,items_users.gtxt1,items_users.gtxt2,items_users.kolvo,items_users.geniration,items_users.magic_inc,items_users.maidin,items_users.lastUPD,items_users.timeOver,items_users.overType,items_users.secret_id,items_users.time_create,items_users.inGroup,items_users.dn_delete,items_users.inTransfer,items_users.post_delivery,items_users.lbtl_,items_users.bexp,items_users.so,items_users.blvl,items_main.id,items_main.name,items_main.img,items_main.type,items_main.inslot,items_main.`2h`,items_main.`2too`,items_main.iznosMAXi,items_main.inRazdel,items_main.price1,items_main.price2,items_main.magic_chance,items_main.info,items_main.massa,items_main.level,items_main.magic_inci,items_main.overTypei,items_main.`group`,items_main.group_max,items_main.geni,items_main.ts,items_main.srok,items_main.class,items_main.class_point,items_main.anti_class,items_main.anti_class_point,items_main.max_text,items_main.useInBattle,items_main.lbtl,items_main.lvl_itm,items_main.lvl_exp,items_main.lvl_aexp from items_users left join items_main on (items_main.id = items_users.item_id) where (( items_users.time_create + items_main.srok) > unix_timestamp() or items_main.srok = "0") and items_users.`delete`="0" and items_users.inOdet="0" and items_users.inShop="30" and items_main.type != "18" and items_main.type != "19" and items_main.type != "20" and items_main.type != "21" and items_main.type != "22" and items_main.type != "15" and items_main.type != "12" and items_main.type != "4" and items_main.type != "5" and items_main.type != "6" and items_main.type != "1" and items_main.type != "3" and items_main.type != "8" and items_main.type != "14" and items_main.type != "13" and items_main.type != "9" and items_main.type != "10" and items_main.type != "11" and items_main.type != "29" and items_main.type != "30" group by items_users.item_id order by items_main.id desc'
|
||
);
|
||
}
|
||
}
|
||
$cr = 'c8c8c8';
|
||
$i = 0;
|
||
$steckCikl = 1;
|
||
while ($pl = mysql_fetch_array($cl)) {
|
||
// количетсво одинаковых предметов в комке
|
||
if ($preview == "preview") {
|
||
$steck = ['--', '--', '--', '--'];
|
||
}
|
||
if ($cr == 'd4d4d4') {
|
||
$cr = 'c8c8c8';
|
||
} else {
|
||
$cr = 'd4d4d4';
|
||
}
|
||
if ($preview == "preview" && ($steck[0] > 1 && $steck[0] > $steckCikl)) {
|
||
++$steckCikl;
|
||
} else {
|
||
$steckCikl = 1;
|
||
$d = mysql_fetch_array(
|
||
mysql_query(
|
||
'SELECT `id`,`items_id`,`data` FROM `items_main_data` WHERE `items_id` = "' . $pl['item_id'] . '" LIMIT 1'
|
||
)
|
||
);
|
||
if ($steck[0] > 1 && $preview == "preview") {
|
||
$po = Helper\Conversion::dataStringToArray($d['data']);
|
||
} else {
|
||
$po = Helper\Conversion::dataStringToArray($pl['data']);
|
||
}
|
||
if ((($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) && $pl['inOdet'] != 14) {
|
||
//Зоны блока +
|
||
$po['zonb']++;
|
||
}
|
||
$is2 = '';
|
||
$is1 = '<img src="//img.new-combats.tech/i/items/' . $pl['img'] . '"><br>';
|
||
if ($preview == "full") {
|
||
$is1 .= '<a href="?otdel=' . ((int)$_GET['otdel']) . '&toRent=3&itemid=' . (int)$_GET['itemid'] . '&buy=' . $pl[0] . '&sd4=' . $this->info['nextAct'] . '&rnd=' . $code . ' " >купить</a> ';
|
||
} elseif ($preview == "preview") {
|
||
$is1 .= '<a href="?otdel=' . ((int)$_GET['otdel']) . '&toRent=3&itemid=' . $pl['item_id'] . ' " >Просмотреть</a> ';
|
||
}
|
||
//название
|
||
|
||
$col = ItemsModel::itemsX($pl[0]);
|
||
if ($col > 1 && $pl['inGroup'] != 0 && $pl['inGroupCount'] > 1) {
|
||
$pl['kolvo'] = $col;
|
||
$pl['name'] .= ' (x' . $col . ')';
|
||
}
|
||
$is2 .= '<a href="/item/' . $pl['item_id'] . '" target="_blank">' . $pl['name'] . '</a> ';
|
||
if ($pl['massa'] > 0 && $preview == "full") {
|
||
$is2 .= '(Масса: ' . round($pl['massa'], 2) . ')';
|
||
if ($pl['gift'] != '') {
|
||
if ($pl['gift'] == 1) {
|
||
$ttl = 'Вы не можете передать этот предмет кому-либо';
|
||
} else {
|
||
$ttl = 'Этот предмет подарил ' . $pl['gift'] . '. Вы не сможете передать этот предмет кому-либо еще';
|
||
}
|
||
$is2 .= ' <img title="' . $ttl . '" src="//img.new-combats.tech/i/podarok.gif">';
|
||
}
|
||
if (isset($po['art'])) {
|
||
$is2 .= ' <img alt="Артефакт" title="Артефакт" src="//img.new-combats.tech/i/artefact.gif">';
|
||
}
|
||
if (isset($po['sudba'])) {
|
||
$is2 .= match ($po['sudba']) {
|
||
'0' => ' <img alt="" title="Этот предмет будет связан общей судьбой с первым, кто наденет его. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">',
|
||
'1' => ' <img alt="" title="Этот предмет будет связан общей судьбой с первым, кто возьмет предмет. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">',
|
||
default => ' <img title="Этот предмет связан общей судьбой с ' . $po['sudba'] . '. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/desteny.gif">',
|
||
};
|
||
}
|
||
}
|
||
//цена
|
||
$is2 .= '<br><strong>Цена: ';
|
||
if ($steck[0] > 1 && $preview == "preview") {
|
||
$is2 .= $steck[3] . '-' . $steck[4] . ' кр.</strong> ';
|
||
} else {
|
||
$is2 .= $pl['1price'] . ' кр.</strong> ';
|
||
}
|
||
if ($pl['pricerep'] > 0) {
|
||
$is2 .= ' <small><strong>(' . round($pl['pricerep'], 2) . ' Воинственности)</strong></small>';
|
||
}
|
||
|
||
//долговечность
|
||
$is2 .= '<br>Долговечность: ';
|
||
if ($preview == "preview") {
|
||
$durability = floor($steck[1]) . '/' . ceil($steck[2]);
|
||
} else {
|
||
if ($pl['iznosMAXi'] == 999999999) {
|
||
$durability = 'неразрушимо';
|
||
} else {
|
||
$durability = floor($pl['iznosNOW']) . '/' . ceil($pl['iznosMAX']);
|
||
}
|
||
}
|
||
|
||
if ($pl['iznosMAX'] > 0 && floor($pl['iznosNOW']) >= (floor($pl['iznosMAX']) - ceil($pl['iznosMAX']) / 100 * 20)) {
|
||
$durability = "<span style='color: brown;'>$durability</span>";
|
||
}
|
||
$is2 .= $durability;
|
||
|
||
//Срок годности предмета
|
||
|
||
if ($po['srok'] > 0) {
|
||
$pl['srok'] = $po['srok'];
|
||
$is2 .= '<br>Срок годности: ';
|
||
}
|
||
if ($pl['srok'] > 0 && $preview != "preview") {
|
||
if ($pl['time_create'] + $pl['srok'] < time()) {
|
||
$is2 .= $this->timeOut($pl['srok']) . ' (испорчен)';
|
||
} else {
|
||
$is2 .= $this->timeOut($pl['srok']) . ' (до ' . date('d.m.Y H:i', $pl['time_create'] + $pl['srok']) . ')';
|
||
}
|
||
} elseif ($pl['srok'] > 0) {
|
||
$is2 .= $this->timeOut($pl['srok']);
|
||
}
|
||
|
||
if ($pl['magic_chance'] > 0) {
|
||
$is2 .= '<br>Вероятность срабатывания: ' . min([$pl['magic_chance'], 100]) . '%';
|
||
}
|
||
|
||
//Продолжительность действия магии:
|
||
if ((int)$pl['magic_inci'] > 0) {
|
||
$efi = mysql_fetch_array(
|
||
mysql_query(
|
||
'SELECT `id2`,`mname`,`type1`,`img`,`mdata`,`actionTime`,`type2`,`type3`,`onlyOne`,`oneType`,`noAce`,`see`,`info`,`overch`,`bp`,`noch` FROM `eff_main` WHERE `id2` = "' . ((int)$pl['magic_inci']) . '" LIMIT 1'
|
||
)
|
||
);
|
||
if (isset($efi['id2']) && $efi['actionTime'] > 0) {
|
||
$is2 .= '<br>Продолжительность действия: ' . $this->timeOut($efi['actionTime']);
|
||
}
|
||
}
|
||
if ($preview == "full" || $preview == "preview") {
|
||
//<strong>Требуется минимальное:</strong>
|
||
$tr = '';
|
||
$t = $this->items['tr'];
|
||
$x = 0;
|
||
while ($x < count($t)) {
|
||
$n = $t[$x];
|
||
if (isset($po['tr_' . $n]) && $po['tr_' . $n] != 0) {
|
||
if ($po['tr_' . $n] > $this->stats[$n]) {
|
||
if ($n == 'rep') {
|
||
$temp = explode('::', $po['tr_' . $n]);
|
||
if ($this->rep['rep' . $temp[1]] < $temp[0]) {
|
||
$tr .= '<font color="red">';
|
||
$notr++;
|
||
}
|
||
unset($temp);
|
||
} elseif ($n != 'align' || floor($this->info['align']) != $po['tr_' . $n]) {
|
||
$tr .= '<font color="red">';
|
||
$notr++;
|
||
}
|
||
}
|
||
$tr .= '<br>• ';
|
||
if ($n == 'rep') {
|
||
$temp = explode('::', $po['tr_' . $n]);
|
||
$tr .= $this->is[$n] . ' ' . ucfirst(
|
||
str_replace('city', ' city', $temp[1])
|
||
) . ': ' . $temp[0];
|
||
unset($temp);
|
||
} elseif ($n != 'align') {
|
||
if ($n == 'sex') {
|
||
if ($po['tr_' . $n] == 1) {
|
||
$tr .= $this->is[$n] . ': Женский';
|
||
} else {
|
||
$tr .= $this->is[$n] . ': Мужской';
|
||
}
|
||
} else {
|
||
$tr .= $this->is[$n] . ': ' . $po['tr_' . $n];
|
||
}
|
||
} else {
|
||
$tr .= $this->is[$n] . ': ' . $this->align_nm[$po['tr_' . $n]];
|
||
}
|
||
if ($po['tr_' . $n] > $this->stats[$n] && ($n != 'align' || floor($this->info['align']) != $po['tr_' . $n])) {
|
||
$tr .= '</font>';
|
||
}
|
||
}
|
||
$x++;
|
||
}
|
||
|
||
if ($tr != '') {
|
||
$is2 .= '<br><strong>Требуется минимальное:</strong>' . $tr;
|
||
}
|
||
//<strong>Действует на:</strong>
|
||
$tr = '';
|
||
$t = $this->items['add'];
|
||
$x = 0;
|
||
while ($x < count($t)) {
|
||
$n = $t[$x];
|
||
if (isset($po['add_' . $n], $this->is[$n])) {
|
||
$z = '+';
|
||
if ($po['add_' . $n] < 0) {
|
||
$z = '';
|
||
}
|
||
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . $po['add_' . $n];
|
||
}
|
||
$x++;
|
||
}
|
||
//действует на (броня)
|
||
$i = 1;
|
||
$bn = [1 => 'головы', 2 => 'корпуса', 3 => 'пояса', 4 => 'ног'];
|
||
while ($i <= 4) {
|
||
if (isset($po['add_mab' . $i])) {
|
||
if ($po['add_mab' . $i] == $po['add_mib' . $i] && $pl['geniration'] == 1) {
|
||
$z = '+';
|
||
if ($po['add_mab' . $i] < 0) {
|
||
$z = '';
|
||
}
|
||
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $z . $po['add_mab' . $i];
|
||
} else {
|
||
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i] . ' (' . $this->bronFx(
|
||
[$po['add_mib' . $i], $po['add_mab' . $i]]
|
||
) . ')';
|
||
}
|
||
}
|
||
$i++;
|
||
}
|
||
if ($tr != '') {
|
||
$is2 .= '<br><strong>Действует на:</strong>' . $tr;
|
||
}
|
||
//<strong>Свойства предмета:</strong>
|
||
$tr = '';
|
||
$t = $this->items['sv'];
|
||
if (isset($po['sv_yron_min'], $po['sv_yron_max'])) {
|
||
$tr .= '<br>• Урон: ' . $po['sv_yron_min'] . ' - ' . $po['sv_yron_max'];
|
||
}
|
||
$x = 0;
|
||
while ($x < count($t)) {
|
||
$n = $t[$x];
|
||
if (isset($po['sv_' . $n])) {
|
||
$z = '+';
|
||
if ($po['sv_' . $n] < 0) {
|
||
$z = '';
|
||
}
|
||
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . $po['sv_' . $n];
|
||
}
|
||
$x++;
|
||
}
|
||
if ($pl['2too'] == 1) {
|
||
$tr .= '<br>• Второе оружие';
|
||
}
|
||
if ($pl['2h'] == 1) {
|
||
$tr .= '<br>• Двуручное оружие';
|
||
}
|
||
if (isset($po['zonb'])) {
|
||
$tr .= '<br>• Зоны блокирования: ';
|
||
if ($po['zonb'] > 0) {
|
||
$x = 1;
|
||
while ($x <= $po['zonb']) {
|
||
$tr .= '+';
|
||
$x++;
|
||
}
|
||
} else {
|
||
$tr .= '—';
|
||
}
|
||
}
|
||
|
||
if ($tr != '') {
|
||
$is2 .= '<br><strong>Свойства предмета:</strong>' . $tr;
|
||
}
|
||
|
||
$tr = '';
|
||
|
||
if (isset($po['imposed']) && $po['imposed'] > 0) {
|
||
if ($po['imposed_lvl'] == 0) {
|
||
$rnc = 'maroon';
|
||
} elseif ($po['imposed_lvl'] == 1) {
|
||
$rnc = '#624542';
|
||
} elseif ($po['imposed_lvl'] == 2) {
|
||
$rnc = '#77090b';
|
||
} elseif ($po['imposed_lvl'] == 3) {
|
||
$rnc = '#d99800';
|
||
} else {
|
||
$rnc = '#282828';
|
||
}
|
||
$po['imposed_name'] = str_replace('Чары ', '', $po['imposed_name']);
|
||
$tr .= '<br>• <font color=' . $rnc . '>Наложены заклятия:</font> ' . $po['imposed_name'] . ' ';
|
||
unset($rnc);
|
||
}
|
||
if ($tr != '') {
|
||
$is2 .= '<br><strong>Улучшения предмета:</strong>';
|
||
$is2 .= $tr;
|
||
}
|
||
|
||
if ($notr == 0) {
|
||
$d[0] = 1;
|
||
if ($pl['magic_inc'] != '') {
|
||
$d[2] = 1;
|
||
}
|
||
}
|
||
if (isset($po['free_stats']) && $po['free_stats'] > 0) {
|
||
$is2 .= '<br><strong>Распределение статов:</strong>';
|
||
$is2 .= '• Возможных распределений: ' . $po['free_stats'];
|
||
}
|
||
if (floor($pl['iznosNOW']) >= ceil($pl['iznosMAX'])) {
|
||
$d[0] = 0;
|
||
$d[2] = 0;
|
||
}
|
||
if (isset($po['complect']) || isset($po['complect2'])) {
|
||
$is2 .= '<br><i>Дополнительная информация:</i>';
|
||
}
|
||
if (isset($po['complect'])) {
|
||
//не отображается
|
||
$com1 = ['name' => 'Неизвестный Комплект', 'x' => 0, 'text' => ''];
|
||
$spc = mysql_query(
|
||
'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect'] . '" ORDER BY `x` LIMIT 20'
|
||
);
|
||
while ($plc = mysql_fetch_array($spc)) {
|
||
$com1['name'] = $plc['name'];
|
||
$com1['text'] .= ' • <font color="green">' . $plc['x'] . '</font>: ';
|
||
//действие комплекта
|
||
$i1c = 0;
|
||
$i2c = 0;
|
||
$i1e = Helper\Conversion::dataStringToArray($plc['data']);
|
||
while ($i1c < count($this->items['add'])) {
|
||
if (isset($i1e[$this->items['add'][$i1c]])) {
|
||
$i3c = $i1e[$this->items['add'][$i1c]];
|
||
if ($i3c > 0) {
|
||
$i3c = '+' . $i3c;
|
||
}
|
||
if ($i2c > 0) {
|
||
$com1['text'] .= ' ' . $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
|
||
} else {
|
||
$com1['text'] .= $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
|
||
}
|
||
$com1['text'] .= '<br>';
|
||
$i2c++;
|
||
}
|
||
$i1c++;
|
||
}
|
||
unset($i1c, $i2c, $i3c);
|
||
$com1['x']++;
|
||
}
|
||
$is2 .= '<br>• Часть комплекта: <strong>' . $com1['name'] . '</strong><br><small>';
|
||
$is2 .= $com1['text'];
|
||
$is2 .= '</small>';
|
||
}
|
||
if (isset($po['complect2'])) {
|
||
//не отображается
|
||
$com1 = ['name' => 'Неизвестный Комплект', 'x' => 0, 'text' => ''];
|
||
$spc = mysql_query(
|
||
'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect2'] . '" ORDER BY `x` ASC LIMIT 20'
|
||
);
|
||
while ($plc = mysql_fetch_array($spc)) {
|
||
$com1['name'] = $plc['name'];
|
||
$com1['text'] .= ' • <font color="green">' . $plc['x'] . '</font>: ';
|
||
//действие комплекта
|
||
$i1c = 0;
|
||
$i2c = 0;
|
||
$i1e = Helper\Conversion::dataStringToArray($plc['data']);
|
||
while ($i1c < count($this->items['add'])) {
|
||
if (isset($i1e[$this->items['add'][$i1c]])) {
|
||
$i3c = $i1e[$this->items['add'][$i1c]];
|
||
if ($i3c > 0) {
|
||
$i3c = '+' . $i3c;
|
||
}
|
||
if ($i2c > 0) {
|
||
$com1['text'] .= ' ' . $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
|
||
} else {
|
||
$com1['text'] .= $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
|
||
}
|
||
$com1['text'] .= '<br>';
|
||
$i2c++;
|
||
}
|
||
$i1c++;
|
||
}
|
||
unset($i1c, $i2c, $i3c);
|
||
$com1['x']++;
|
||
}
|
||
$is2 .= '<br>• Часть комплекта (подгонка): <strong>' . $com1['name'] . '</strong><br><small>';
|
||
$is2 .= $com1['text'];
|
||
$is2 .= '</small>';
|
||
}
|
||
|
||
$is2 .= '<small style="">';
|
||
if (isset($po['gravi'])) {
|
||
$is2 .= '<br>На поверхности выгравирована надпись: <strong>' . $po['gravi'] . '</strong>';
|
||
}
|
||
if ($pl['info'] != '') {
|
||
$is2 .= '<div><strong>Рекомендации:</strong></div><div>' . $pl['info'] . '</div>';
|
||
}
|
||
if ($po['info'] != '') {
|
||
$is2 .= '<div>' . $po['info'] . '</div>';
|
||
}
|
||
if ($pl['max_text'] - $pl['use_text'] > 0) {
|
||
$is2 .= '<div>Количество символов: ' . ($pl['max_text'] - $pl['use_text']) . '</div>';
|
||
}
|
||
if (isset($po['noremont'])) {
|
||
$is2 .= '<div style="color:brown;">Предмет не подлежит ремонту</div>';
|
||
}
|
||
if (isset($po['nosale'])) {
|
||
$is2 .= '<div style="color:brown;">Предмет нельзя продать</div>';
|
||
}
|
||
if (isset($po['nomodif'])) {
|
||
$is2 .= '<div style="color:brown;">Предмет нельзя улучшать</div>';
|
||
}
|
||
if (isset($po['nodelete'])) {
|
||
$is2 .= '<div style="color:brown;">Предмет нельзя выбросить</div>';
|
||
}
|
||
if (isset($po['frompisher']) && $po['frompisher'] > 0) {
|
||
$is2 .= '<div style="color:brown;">Предмет из подземелья</div>';
|
||
}
|
||
if (isset($po['sleep_moroz']) && $po['sleep_moroz'] > 0) {
|
||
$is2 .= '<div style="color:brown;">Предмет не портится во время сна</div>';
|
||
}
|
||
if (isset($po['fromlaba']) && $po['fromlaba'] > 0) {
|
||
$is2 .= '<div style="color:brown;">Предмет из лабиринта</div>';
|
||
}
|
||
if (isset($po['vip_sale']) && $po['vip_sale'] > 0) {
|
||
$is2 .= '<div style="color:brown;">Предмет куплен за 10% от стоимости</div>';
|
||
}
|
||
if ($pl['dn_delete'] > 0) {
|
||
$is2 .= '<div style="color:brown;">Предмет будет удален при выходе из подземелья</div>';
|
||
}
|
||
|
||
$is2 .= '</small>';
|
||
}
|
||
if ($preview == "preview") {
|
||
$kolvoprint = "<small style=\"float:right; color:grey; text-align=right\">Количество: <strong>$steck[0]</strong> шт.</small>";
|
||
}
|
||
echo '<tr style="background-color:#' . $cr . ';"><td width="100" style="padding:7px;" valign="middle" align="center">' . $is1 . '</td><td style="padding:7px;" valign="top">' . $kolvoprint . $is2 . '</td></tr>';
|
||
$i++;
|
||
}
|
||
}
|
||
if ($i == 0) {
|
||
echo '<tr style="background-color:#' . $cr . ';"><td style="padding:7px;" align="center" valign="top">Прилавок магазина пуст</td></tr>';
|
||
}
|
||
}
|
||
|
||
private function timeOut(int|string $seconds): string
|
||
{
|
||
return Conversion::secondsToTimeout($seconds);
|
||
}
|
||
|
||
private function bronFx($br): string
|
||
{
|
||
$r = '';
|
||
if ($br[0] > 0) {
|
||
$r .= $br[0] - 1;
|
||
} else {
|
||
$r .= 0;
|
||
}
|
||
$r .= 'd';
|
||
if ($br[0] > 0) {
|
||
$r .= $br[1] - $br[0];
|
||
} else {
|
||
$r .= 0;
|
||
}
|
||
return $r;
|
||
}
|
||
|
||
public function buyItem(int $iid, User $u): string
|
||
{
|
||
$irow = Db::getRow('select items_users.id, uid, 1price, inGroup, inShop, data, item_id, login, items_main.name, price1
|
||
from items_users
|
||
left join users on users.id = uid
|
||
left join items_main on items_main.id = item_id
|
||
where items_users.id = ? and inShop = 30', [$iid]);
|
||
|
||
$price = $irow['1price'];
|
||
if (!isset($irow['id']) || !isset($iid) || $irow['inShop'] != 30) {
|
||
$r = 'Предмет не найден на прилавке';
|
||
} else {
|
||
if ($price > $u->info['money']) {
|
||
$r = 'У вас недостаточно денег (не хватает ' . ($price - $u->info['money']) . ' кр.)';
|
||
} else {
|
||
$u->addKr(-$price);
|
||
$u->addKr($price, $irow['uid']);
|
||
|
||
$col = ItemsModel::itemsX($iid);
|
||
if ($col > 1) {
|
||
Db::sql('update items_users set uid = ?, inGroup = inGroup + 1000, 1price = ?, lastUPD = unix_timestamp(), inShop = 0
|
||
where inShop = 30 and inOdet = 0 and item_id = ? and uid = ? and inGroup = ? limit ?',
|
||
[$u->info['id'], $irow['price1'], $irow['item_id'], $irow['uid'], $irow['inGroup'], $col]);
|
||
$irow['name'] .= "(x$col)";
|
||
} else {
|
||
Db::sql('update items_users set uid = ?, 1price = ?, lastUPD = unix_timestamp(), inShop = 0
|
||
where id = ? and uid = ? and inOdet = 0',
|
||
[$iid, $irow['uid']]);
|
||
}
|
||
|
||
Delo::add(1, 'comShop', $u->info['id'], "Купил предмет «{$irow['name']}» у игрока {$irow['login']} за $price кр.", $price);
|
||
Delo::add(1, 'comShop', $irow['uid'], "Продал предмет «{$irow['name']}» игроку {$irow['login']} за $price кр.");
|
||
|
||
$r = "Вы купили предмет «{$irow['name']}» у игрока {$irow['login']} за $price кр.<br>Предмет успешно добавлен в инвентарь.";
|
||
}
|
||
}
|
||
return '<div>' . $r . '</div>';
|
||
}
|
||
|
||
public function rent($action, int $iid, int $price): void
|
||
{
|
||
if ($action == "Сдать в магазин" && $price > 0) {
|
||
$this->rentPut($iid, $price);
|
||
} elseif ($action == "Забрать") {
|
||
$this->rentTake($iid);
|
||
}
|
||
}
|
||
|
||
private function rentPut(int $id, int $price): void
|
||
{
|
||
$item = Db::getRow('select id, item_id, data, ingroup, uid from items_users where id = ?', [$id]);
|
||
$data = Conversion::dataStringToArray($item['data']);
|
||
$col = ItemsModel::itemsX($item['id']);
|
||
|
||
if (isset($data['sudba']) || $data['sudba'] != 0 || isset($data['toclan'])) {
|
||
return;
|
||
}
|
||
if (!isset($item['ingroup']) || $item['ingroup'] <= 0 || $col < 2) {
|
||
Db::sql('update items_users set inShop = 30, 1price = ? where id = ? and uid = ? and inOdet = 0', [$price, $id, $item['uid']]);
|
||
return;
|
||
}
|
||
|
||
Db::sql('update items_users set inShop = 30, 1price = ? where item_id = ? and uid = ? and inGroup = ? limit ?', [$price, $item['id'], $item['uid'], $item['ingroup'], (int)$col]);
|
||
}
|
||
|
||
private function rentTake(int $id): void
|
||
{
|
||
$item = Db::getRow('select items_users.*, price1, inGroup from items_users inner join items_main on items_main.id = item_id where items_users.id = ? and inShop = 30 limit 1', [$id]);
|
||
if (!isset($item['inGroup']) || $item['inGroup'] <= 0) {
|
||
Db::sql('update items_users set inShop = 0, 1price = ? where id = ? and inShop = 30', [$item['price1'], $id]);
|
||
return;
|
||
}
|
||
$col = ItemsModel::itemsX($item['id']);
|
||
if ($col > 1) {
|
||
Db::sql('update items_users set inShop = 0, 1price = ? where item_id = ? and uid = ? and inGroup = ? and inShop = 30 limit ?',
|
||
[$item['price1'], $item['item_id'], $item['uid'], $item['ingroup'], (int)$col]);
|
||
} else {
|
||
Db::sql('update items_users set inShop = 0, 1price = ? where id = ? and uid = ? and inOdet = 0', [$item['price1'], $id, $item['uid']]);
|
||
}
|
||
}
|
||
}
|