Compare commits

..

2 Commits

18 changed files with 1010 additions and 1111 deletions

View File

@ -0,0 +1,62 @@
<?php
namespace Battle;
use Core\Config;
use Helper\Conversion;
use User;
class BattleHTML
{
/**
* Генерирует HTML, который будет вставляться в javascript в файлах refresh{X}.php
*
* @return string
*/
public static function printMagicScrolls(): string
{
$sv = array_fill(1, 12, '<img class="nopriemuse" title="Пустой слот магия" src="' . Config::img() . '/i/items/w/w101.gif" alt="">');
foreach (User::start()->stats['items'] as $stat) {
if (!in_array($stat['inslot'], [40, 51])) {
continue;
}
if (empty($stat['useInBattle']) || $stat['btl_zd'] > 0 || $stat['iznosNOW'] >= $stat['iznosMAX'] || empty($stat['magic_inci'])) {
$vl = 'class="nopriemuse"';
} else {
$po = Conversion::dataStringToArray($stat['data']);
if ($po['useOnLogin'] == 1) {
$jsvars = "'{$stat['name']}','{$stat['id']}','{$stat['img']}',1,1,'','{$stat['useInBattle']}'";
} else {
$jsvars = "'{$stat['name']}','{$stat['id']}','{$stat['img']}',1,2";
}
$vl = 'style="cursor:pointer" onclick="top.useMagicBattle(' . $jsvars . ')"';
}
$iznos = "Долговечность: {$stat['iznosNOW']} / {$stat['iznosMAX']}";
$img = Config::img() . '/i/items/' . $stat['img'];
$sv[$stat['inOdet'] - 39] = '<img ' . $vl . ' title="' . $iznos . '" src="' . $img . '" alt="">';
}
return <<<HTML
<table style="border: 0; border-collapse: collapse; border-spacing: 0;">
<tr>
<td>$sv[1]</td>
<td>$sv[2]</td>
<td>$sv[3]</td>
<td>$sv[4]</td>
<td>$sv[5]</td>
<td>$sv[6]</td>
<td>$sv[7]</td>
<td>$sv[8]</td>
<td>$sv[9]</td>
<td>$sv[10]</td>
<td>$sv[11]</td>
<td>$sv[12]</td>
</tr>
</table>
HTML;
//Если сломается, применить str_replace('"', '\"', $r);
}
}

View File

@ -32,8 +32,11 @@ class Fighter
private int $firedefence; private int $firedefence;
private int $earthdefence; private int $earthdefence;
private int $armor; private int $armor;
public function __construct(private readonly int $id, private readonly int $team) { private int $team;
$u = User::start($id);
public function __construct(private readonly int $id)
{
$u = User::start($id, true);
$this->obraz = $u->info['sex'] . DIRECTORY_SEPARATOR . $u->info['obraz']; $this->obraz = $u->info['sex'] . DIRECTORY_SEPARATOR . $u->info['obraz'];
$this->login = $u->info['login']; $this->login = $u->info['login'];
$this->level = $u->info['level']; $this->level = $u->info['level'];
@ -41,8 +44,8 @@ class Fighter
$this->mana = $u->stats['mpNow']; $this->mana = $u->stats['mpNow'];
$this->maxlife = $u->stats['hpAll']; $this->maxlife = $u->stats['hpAll'];
$this->maxmana = $u->stats['mpAll']; $this->maxmana = $u->stats['mpAll'];
$this->damage = 100500; $this->damage = mt_rand(0, 100);
$this->armor = 35; $this->armor = mt_rand(0, 5);
$this->damageMultiplier = $u->stats['m10']; $this->damageMultiplier = $u->stats['m10'];
$this->critChance = $u->stats['m1']; $this->critChance = $u->stats['m1'];
$this->critMultiplier = $u->stats['m3']; $this->critMultiplier = $u->stats['m3'];
@ -58,37 +61,49 @@ class Fighter
$this->waterdefence = $u->stats['zm3']; $this->waterdefence = $u->stats['zm3'];
$this->firedefence = $u->stats['zm1']; $this->firedefence = $u->stats['zm1'];
$this->earthdefence = $u->stats['zm4']; $this->earthdefence = $u->stats['zm4'];
$this->team = $u->info['team'];
unset($u); unset($u);
} }
public function get(): object
{
return (object)[
'damage' => $this->damage,
'armor' => $this->armor + $this->defence,
'health' => $this->life,
'name' => $this->login,
'crit' => $this->critChance,
'evade' => $this->evadeChance,
];
}
public function __toString(): string public function __toString(): string
{ {
$dmg = Math::addPercent($this->damage, $this->damageMultiplier); $dmg = Math::addPercent($this->damage, $this->damageMultiplier);
return <<<RETURN return <<<RETURN
$this->login [$this->level] id:$this->id <br> $this->login [$this->level] <a href="/info/$this->id" target="_blank">id:$this->id</a> <br>
Здоровье: $this->life / $this->maxlife <br> Здоровье: $this->life / $this->maxlife <br>
Мана: $this->mana / $this->maxmana <br> Мана: $this->mana / $this->maxmana <br><hr>
<img src="https://img.new-combats.tech/i/obraz/$this->obraz" alt=""><br> <!-- <img src="https://img.new-combats.tech/i/obraz/$this->obraz" alt=""><br>-->
Урон: $this->damage + $this->damageMultiplier% = $dmg <br> Урон: $this->damage + $this->damageMultiplier% = $dmg <br>
Броня: $this->armor <br> Броня: $this->armor <br><hr>
Крит: $this->critChance% <br> Крит: $this->critChance% <br>
Антикрит $this->anticritChance% <br> Антикрит $this->anticritChance% <br>
Мощность крита $this->critMultiplier% <br> Мощность крита $this->critMultiplier% <br>
Уровот $this->evadeChance% <br> Уровот $this->evadeChance% <br>
Антиуворот $this->antievadeChance% <br> Антиуворот $this->antievadeChance% <br>
Контрудар $this->counterstrikeChance% <br> Контрудар $this->counterstrikeChance% <br>
Парирование $this->parryChance% <br> <!-- Парирование $this->parryChance% <br>-->
Блок щитом $this->shieldblockChance% <br> <!-- Блок щитом $this->shieldblockChance% <br>-->
Игнор брони $this->ignoreArmorChance% <br> <!-- Игнор брони $this->ignoreArmorChance% <br>-->
Защита от урона $this->defence <br> Защита от урона $this->defence <br>
Зашита от огня $this->firedefence <br> Зашита от огня $this->firedefence <br>
Защита от воды $this->waterdefence <br> Защита от воды $this->waterdefence <br>
Защита от воздуха $this->airdefence <br> Защита от воздуха $this->airdefence <br>
Защита от земли $this->earthdefence <br><br> Защита от земли $this->earthdefence <br><hr>
Сражается за команду: $this->team Сражается за команду: $this->team
RETURN; RETURN;
} }
} }

View File

@ -10,29 +10,103 @@ use User\ItemsModel;
class ItemStorage class ItemStorage
{ {
private string $error = '';
public function put(int $itemId, int $clanId): string private string $error = '';
private int $clanId;
private int $userId;
private string $userLogin;
public function __construct()
{ {
$user = User::start()->info; $userinfo = User::start()->info;
$item = ItemsModel::getOwnedItemById($itemId, $user['id']); $this->userId = $userinfo['id'];
$clanName = Db::getValue('select name from clan where id = ?', [$clanId]) ?? ''; $this->clanId = $userinfo['clan'];
$this->userLogin = $userinfo['login'];
}
public function take(int $itemId): string
{
$item = Db::getRows('select items_users.id, name, data from items_users inner join items_main on item_id = items_main.id where uid = ? and items_users.id = ?', ["-21$this->clanId", $itemId]);
if (!isset($item['id'])) {
return 'Предмет не найден.<br>' . $itemId;
}
$data = Conversion::dataStringToArray($item['data']);
$cls = isset($data['toclan']) ? explode('#', $data['toclan'])[1] : 0;
$col = ItemsModel::itemsX($itemId);
Db::sql('update items_users set lastUPD = unix_timestamp(), uid = ? where id = ?', [$this->userId, $itemId]);
Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,5,?,unix_timestamp(),?,?)', [$this->clanId, $this->userLogin, "{$item['name']} (x$col) Id:$itemId Хозяин: $cls", $this->userId]);
return "Вы успешно взяли предмет «{$item['name']}» из хранилища.";
}
public function remove(int $type): void
{
$storedItems = Db::getRows('select items_users.id, uid, name, data, inOdet from items_users inner join items_main on item_id = items_main.id where uid = ? or data like ?', ["-21$this->clanId", "%toclan=$this->clanId#%"]);
foreach ($storedItems as $storedItem) {
$data = Conversion::dataStringToArray($storedItem['data']);
$cls = isset($data['toclan']) ? explode('#', $data['toclan'])[1] : 0;
$col = ItemsModel::itemsX($storedItem['id']);
if ($cls == $this->userId) {
if ($storedItem['uid'] != $this->userId && $storedItem['inOdet'] != 0) {
Db::sql('update items_users set inOdet = 0 where id = ?', [$storedItem['id']]);
}
unset($data['toclan']);
$storedItem['data'] = Conversion::arrayToDataString($data);
Db::sql('update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?', [$this->userId, $storedItem['data'], $storedItem['id']]);
Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,?,?,unix_timestamp(),?,?)', [$this->clanId, $type, $this->userLogin, "{$storedItem['name']} (x$col) Id:{$storedItem['id']}", $this->userId]);
} elseif ($storedItem['uid'] == $this->userId) {
Db::sql('update items_users set lastUPD = unix_timestamp(), uid = ? where id = ?', ["-21$this->clanId", $storedItem['id']]);
Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,9,?,unix_timestamp(),?,?)', [$this->clanId, $this->userLogin, "{$storedItem['name']} (x$col) Id:{$storedItem['id']}", $this->userId]);
}
}
}
public function backToOwner(int $itemId): string
{
$item = ItemsModel::getOwnedItemById($itemId, $this->userId, true);
if (empty($item)) {
return 'Предмет не найден.';
}
$ownerIsNotReal = !Db::getValue('select count(id) from stats where id = ? and (bot = 0 or clone = 0)', [$item['uid']]);
if ($ownerIsNotReal) {
return 'Вы не можете изьять данный предмет, он не принадлежит клану.';
}
$iw = $item['inOdet'] > 0 ? 'inOdet = 0' : '';
$col = ItemsModel::itemsX($itemId);
Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,6,?,unix_timestamp(),?,?)', [$this->clanId, $this->userLogin, "{$item['name']} (x$col) Id:$itemId У персонажа: {$item['uid']}", $this->userId]);
Db::sql("update items_users set lastUPD = unix_timestamp(), $iw, uid = ? where id = ?", ["-21$this->clanId", $itemId]);
return "Вы успешно изъяли предмет «{$item['name']}»";
}
public function put(int $itemId): string
{
$item = ItemsModel::getOwnedItemById($itemId, $this->userId);
$clanName = Db::getValue('select name from clan where id = ?', [$this->clanId]) ?? '';
if (empty($clanName)) { if (empty($clanName)) {
return 'Клан не найден.'; return 'Клан не найден.';
} }
if (!$this->isGoodForStorage($item, $user['clan'])) { if (!$this->isGoodForStorage($item)) {
return $this->error; return $this->error;
} }
$col = User::start()->itemsX(($itemId)); $col = ItemsModel::itemsX($itemId);
$idata = Conversion::dataStringToArray($item['data']); $idata = Conversion::dataStringToArray($item['data']);
if (!isset($idata['toclan'])) { if (!isset($idata['toclan'])) {
$idata['toclan'] = $user['clan'] . '#' . $user['id']; $idata['toclan'] = $this->clanId . '#' . $this->userId;
$item['data'] = Conversion::arrayToDataString($idata); $item['data'] = Conversion::arrayToDataString($idata);
Delo::add( Delo::add(
2, 2,
'System.transfer.clan', 'System.transfer.clan',
$user['id'], $this->userId,
'&quot;System.transfer.MONEY&quot;: Предмет &quot;' . $item['name'] . '&quot; (#id : "' . $itemId . '") (x' . $col . ') был пожертвован клану &quot;' . $clanName . '&quot; (' . $clanId . ').', '&quot;System.transfer.MONEY&quot;: Предмет &quot;' . $item['name'] . '&quot; (#id : "' . $itemId . '") (x' . $col . ') был пожертвован клану &quot;' . $clanName . '&quot; (' . $this->clanId . ').',
); );
$sendType = 4; $sendType = 4;
} else { } else {
@ -40,17 +114,17 @@ class ItemStorage
} }
Db::sql( Db::sql(
'insert into clan_operations (clan, time, type, text, val, uid) values (?,unix_timestamp(),?,?,?,?)', 'insert into clan_operations (clan, time, type, text, val, uid) values (?,unix_timestamp(),?,?,?,?)',
[$clanId, $sendType, $user['login'], $item['name'] . ("x$col Ид: [$itemId]"), $user['id']] [$this->clanId, $sendType, $this->userLogin, $item['name'] . ("x$col Ид: [$itemId]"), $this->userId]
); );
Db::sql( Db::sql(
'update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?', 'update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?',
['-21' . $user['clan'], $item['data'], $itemId] ['-21' . $this->clanId, $item['data'], $itemId]
); );
return 'Вы передали предмет &quot;' . $item['name'] . '&quot; клану.'; return 'Вы передали предмет &quot;' . $item['name'] . '&quot; клану.';
} }
private function isGoodForStorage(array $item, $userClanId): bool private function isGoodForStorage(array $item): bool
{ {
if (empty($item['inslot']) || !empty($item['gift'])) { if (empty($item['inslot']) || !empty($item['gift'])) {
$this->error = 'Предмет не найден.'; $this->error = 'Предмет не найден.';
@ -64,118 +138,9 @@ class ItemStorage
) { ) {
$this->error = 'Предмет не подходит.'; $this->error = 'Предмет не подходит.';
} }
if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $userClanId) { if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $this->clanId) {
$this->error = 'Предмет уже принадлежит клану.'; $this->error = 'Предмет уже принадлежит клану.';
} }
return empty($this->error); return empty($this->error);
} }
public function ungive_itm_cl($id, $user, $cl): string
{
$itm_ = mysql_fetch_array(
mysql_query(
'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` >= 0 AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1'
)
);
$res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1'));
$user_itm = mysql_fetch_array(
mysql_query('SELECT `id`,`bot`,`clone` FROM `stats` WHERE `id` = "' . $itm_['uid'] . '" LIMIT 1')
);
if ($user_itm['bot'] > 0 || $user_itm['clone'] > 0 || !isset($user_itm['id'])) {
$r = '<font color="#FF0000"><strong>Вы не можете изьять данный предмет, он не принадлежит клану</strong></font><br />';
} elseif (isset($itm_['id'])) {
if ($itm_['inOdet'] != 0) {
$o = ', `inOdet` = 0';
} else {
$o = '';
}
$r = '<font color="#FF0000"><strong>Вы успешно изъяли предмет &quot;' . $itm_['name'] . '&quot;</strong></font><br />';
$col = $this->itemsX(((int)$id));
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")'
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1'
);
} else {
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />';
}
return $r;
}
public function take_itm_cl($id, $user, $cl): string
{
$itm_ = mysql_fetch_array(
mysql_query(
'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` = "-21' . $user['clan'] . '" AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1'
)
);
$res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1'));
if (isset($itm_['id'])) {
$po = Conversion::dataStringToArray($itm_['data']);
if (isset($po['toclan'])) {
$cls = explode('#', $po['toclan']);
$cls = $cls[1];
}
$col = $this->itemsX(((int)$id));
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")'
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1'
);
$r = '<font color="#FF0000"><strong>Вы успешно взяли предмет &quot;' . $itm_['name'] . '&quot; из хранилища</strong></font><br />';
} else {
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />' . $id;
}
return $r;
}
public function rem_itm_cl($user, $cl, $type)
{
$itms = mysql_query(
'SELECT * FROM `items_users` WHERE (`uid` = "-21' . $user['clan'] . '" OR `data` LIKE "%toclan=' . $user['clan'] . '#%")'
);
while ($pl = mysql_fetch_array($itms)) {
$po = Conversion::dataStringToArray($pl['data']);
if (isset($po['toclan'])) {
$cls = explode('#', $po['toclan']);
$cls = $cls[1];
}
if ($cls == $user['id']) {
if ($pl['uid'] != $user['id']) {
if ($pl['inOdet'] != 0) {
mysql_query('UPDATE `items_users` SET `inOdet` = 0 WHERE `id` = "' . $pl['id'] . '"');
}
}
unset($po['toclan']);
$pl['data'] = Conversion::arrayToDataString($po);
$col = $this->itemsX(((int)$pl['id']));
$it_n = mysql_fetch_array(
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"'
);
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
);
} elseif ($pl['uid'] == $user['id']) {
$col = $this->itemsX(((int)$pl['id']));
$it_n = mysql_fetch_array(
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"'
);
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
);
}
}
}
} }

View File

@ -2,10 +2,35 @@
use Core\Db; use Core\Db;
use Helper\Conversion; use Helper\Conversion;
use Model\Constant\Stat;
use User\ItemsModel;
class ComissionShop class ComissionShop
{ {
public function commisionShop($preview = 'full') 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; global $code;
$typeOtdel = match ((int)$_GET['otdel']) { $typeOtdel = match ((int)$_GET['otdel']) {
@ -44,7 +69,7 @@ FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.
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( 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 $typeOtdel
) . '" and `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" GROUP BY `items_users`.`uid`, `items_users`.`1price` HAVING `items_users`.inGroup = 0 ) . '" and `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" GROUP BY `items_users`.`uid`, `items_users`.`1price` HAVING `items_users`.inGroup = 0
ORDER BY `1price`ASC , inGroupCount DESC' ORDER BY `1price`, inGroupCount DESC'
); );
} else { } else {
$cl = mysql_query( $cl = mysql_query(
@ -86,11 +111,11 @@ FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`
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'] . '" 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" 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 GROUP BY `items_users`.`uid`,`items_users`.`1price` HAVING `items_users`.inGroup = 0
ORDER BY `1price`ASC , inGroupCount DESC' ORDER BY `1price`, inGroupCount DESC'
); );
} else { } else {
$cl = mysql_query( $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' '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'
); );
} }
} }
@ -121,12 +146,10 @@ ORDER BY `1price`ASC , inGroupCount DESC'
} else { } else {
$po = Helper\Conversion::dataStringToArray($pl['data']); $po = Helper\Conversion::dataStringToArray($pl['data']);
} }
if (($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) { if ((($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) && $pl['inOdet'] != 14) {
//Зоны блока + //Зоны блока +
if ($pl['inOdet'] != 14) {
$po['zonb']++; $po['zonb']++;
} }
}
$is2 = ''; $is2 = '';
$is1 = '<img src="//img.new-combats.tech/i/items/' . $pl['img'] . '"><br>'; $is1 = '<img src="//img.new-combats.tech/i/items/' . $pl['img'] . '"><br>';
if ($preview == "full") { if ($preview == "full") {
@ -136,7 +159,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
} }
//название //название
$col = $this->itemsX($pl[0]); $col = ItemsModel::itemsX($pl[0]);
if ($col > 1 && $pl['inGroup'] != 0 && $pl['inGroupCount'] > 1) { if ($col > 1 && $pl['inGroup'] != 0 && $pl['inGroupCount'] > 1) {
$pl['kolvo'] = $col; $pl['kolvo'] = $col;
$pl['name'] .= ' (x' . $col . ')'; $pl['name'] .= ' (x' . $col . ')';
@ -145,7 +168,6 @@ ORDER BY `1price`ASC , inGroupCount DESC'
if ($pl['massa'] > 0 && $preview == "full") { if ($pl['massa'] > 0 && $preview == "full") {
$is2 .= '(Масса: ' . round($pl['massa'], 2) . ')'; $is2 .= '(Масса: ' . round($pl['massa'], 2) . ')';
if ($pl['gift'] != '') { if ($pl['gift'] != '') {
$ttl = '';
if ($pl['gift'] == 1) { if ($pl['gift'] == 1) {
$ttl = 'Вы не можете передать этот предмет кому-либо'; $ttl = 'Вы не можете передать этот предмет кому-либо';
} else { } else {
@ -154,16 +176,14 @@ ORDER BY `1price`ASC , inGroupCount DESC'
$is2 .= ' <img title="' . $ttl . '" src="//img.new-combats.tech/i/podarok.gif">'; $is2 .= ' <img title="' . $ttl . '" src="//img.new-combats.tech/i/podarok.gif">';
} }
if (isset($po['art'])) { if (isset($po['art'])) {
$is2 .= ' <img title="Артефакт" src="//img.new-combats.tech/i/artefact.gif">'; $is2 .= ' <img alt="Артефакт" title="Артефакт" src="//img.new-combats.tech/i/artefact.gif">';
} }
if (isset($po['sudba'])) { if (isset($po['sudba'])) {
if ($po['sudba'] == '0') { $is2 .= match ($po['sudba']) {
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто наденет его. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">'; '0' => ' <img alt="" title="Этот предмет будет связан общей судьбой с первым, кто наденет его. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">',
} elseif ($po['sudba'] == '1') { '1' => ' <img alt="" title="Этот предмет будет связан общей судьбой с первым, кто возьмет предмет. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">',
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто возьмет предмет. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">'; default => ' <img title="Этот предмет связан общей судьбой с ' . $po['sudba'] . '. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/desteny.gif">',
} else { };
$is2 .= ' <img title="Этот предмет связан общей судьбой с ' . $po['sudba'] . '. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/desteny.gif">';
}
} }
} }
//цена //цена
@ -178,41 +198,38 @@ ORDER BY `1price`ASC , inGroupCount DESC'
} }
//долговечность //долговечность
if ($pl['iznosMAX'] > 0) { $is2 .= '<br>Долговечность: ';
$izcol = '';
if (floor($pl['iznosNOW']) >= (floor($pl['iznosMAX']) - ceil($pl['iznosMAX']) / 100 * 20)) {
$izcol = 'brown';
}
}
if ($preview == "preview") { if ($preview == "preview") {
$is2 .= '<br>Долговечность: <font color="' . $izcol . '">' . floor($steck[1]) . '/' . ceil( $durability = floor($steck[1]) . '/' . ceil($steck[2]);
$steck[2]
) . '</font>';
} else { } else {
if ($pl['iznosMAXi'] == 999999999) { if ($pl['iznosMAXi'] == 999999999) {
$is2 .= '<br>Долговечность: <font color="brown">неразрушимо</font>'; $durability = 'неразрушимо';
} else { } else {
$is2 .= '<br>Долговечность: <font color="' . $izcol . '">' . floor( $durability = floor($pl['iznosNOW']) . '/' . ceil($pl['iznosMAX']);
$pl['iznosNOW']
) . '/' . ceil($pl['iznosMAX']) . '</font>';
} }
} }
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) { if ($po['srok'] > 0) {
$pl['srok'] = $po['srok']; $pl['srok'] = $po['srok'];
$is2 .= '<br>Срок годности: ';
} }
if ($pl['srok'] > 0 and $preview != "preview") { if ($pl['srok'] > 0 && $preview != "preview") {
if ($pl['time_create'] + $pl['srok'] < time()) { if ($pl['time_create'] + $pl['srok'] < time()) {
$is2 .= '<br>Срок годности: ' . $this->timeOut($pl['srok']) . ' (испорчен)'; $is2 .= $this->timeOut($pl['srok']) . ' (испорчен)';
} else { } else {
$is2 .= '<br>Срок годности: ' . $this->timeOut($pl['srok']) . ' (до ' . date( $is2 .= $this->timeOut($pl['srok']) . ' (до ' . date('d.m.Y H:i', $pl['time_create'] + $pl['srok']) . ')';
'd.m.Y H:i', $pl['time_create'] + $pl['srok']
) . ')';
} }
} elseif ($pl['srok'] > 0) { } elseif ($pl['srok'] > 0) {
$is2 .= '<br>Срок годности: ' . $this->timeOut($pl['srok']); $is2 .= $this->timeOut($pl['srok']);
} }
if ($pl['magic_chance'] > 0) { if ($pl['magic_chance'] > 0) {
$is2 .= '<br>Вероятность срабатывания: ' . min([$pl['magic_chance'], 100]) . '%'; $is2 .= '<br>Вероятность срабатывания: ' . min([$pl['magic_chance'], 100]) . '%';
} }
@ -269,12 +286,10 @@ ORDER BY `1price`ASC , inGroupCount DESC'
} else { } else {
$tr .= $this->is[$n] . ': ' . $this->align_nm[$po['tr_' . $n]]; $tr .= $this->is[$n] . ': ' . $this->align_nm[$po['tr_' . $n]];
} }
if ($po['tr_' . $n] > $this->stats[$n]) { if ($po['tr_' . $n] > $this->stats[$n] && ($n != 'align' || floor($this->info['align']) != $po['tr_' . $n])) {
if ($n != 'align' || floor($this->info['align']) != $po['tr_' . $n]) {
$tr .= '</font>'; $tr .= '</font>';
} }
} }
}
$x++; $x++;
} }
@ -292,7 +307,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
if ($po['add_' . $n] < 0) { if ($po['add_' . $n] < 0) {
$z = ''; $z = '';
} }
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . '' . $po['add_' . $n]; $tr .= '<br>• ' . $this->is[$n] . ': ' . $z . $po['add_' . $n];
} }
$x++; $x++;
} }
@ -306,7 +321,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
if ($po['add_mab' . $i] < 0) { if ($po['add_mab' . $i] < 0) {
$z = ''; $z = '';
} }
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $z . '' . $po['add_mab' . $i]; $tr .= '<br>• Броня ' . $bn[$i] . ': ' . $z . $po['add_mab' . $i];
} else { } else {
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i] . ' (' . $this->bronFx( $tr .= '<br>• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i] . ' (' . $this->bronFx(
[$po['add_mib' . $i], $po['add_mab' . $i]] [$po['add_mib' . $i], $po['add_mab' . $i]]
@ -332,7 +347,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
if ($po['sv_' . $n] < 0) { if ($po['sv_' . $n] < 0) {
$z = ''; $z = '';
} }
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . '' . $po['sv_' . $n]; $tr .= '<br>• ' . $this->is[$n] . ': ' . $z . $po['sv_' . $n];
} }
$x++; $x++;
} }
@ -390,7 +405,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
} }
if (isset($po['free_stats']) && $po['free_stats'] > 0) { if (isset($po['free_stats']) && $po['free_stats'] > 0) {
$is2 .= '<br><strong>Распределение статов:</strong>'; $is2 .= '<br><strong>Распределение статов:</strong>';
$is2 .= '&bull; Возможных распределений: ' . $po['free_stats'] . ''; $is2 .= '&bull; Возможных распределений: ' . $po['free_stats'];
} }
if (floor($pl['iznosNOW']) >= ceil($pl['iznosMAX'])) { if (floor($pl['iznosNOW']) >= ceil($pl['iznosMAX'])) {
$d[0] = 0; $d[0] = 0;
@ -403,7 +418,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
//не отображается //не отображается
$com1 = ['name' => 'Неизвестный Комплект', 'x' => 0, 'text' => '']; $com1 = ['name' => 'Неизвестный Комплект', 'x' => 0, 'text' => ''];
$spc = mysql_query( $spc = mysql_query(
'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect'] . '" ORDER BY `x` ASC LIMIT 20' 'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect'] . '" ORDER BY `x` LIMIT 20'
); );
while ($plc = mysql_fetch_array($spc)) { while ($plc = mysql_fetch_array($spc)) {
$com1['name'] = $plc['name']; $com1['name'] = $plc['name'];
@ -512,13 +527,11 @@ ORDER BY `1price`ASC , inGroupCount DESC'
if ($pl['dn_delete'] > 0) { if ($pl['dn_delete'] > 0) {
$is2 .= '<div style="color:brown;">Предмет будет удален при выходе из подземелья</div>'; $is2 .= '<div style="color:brown;">Предмет будет удален при выходе из подземелья</div>';
} }
if (isset($po['zazuby']) && $po['zazuby'] > 0) {
$is2 .= '<div style="color:brown;">Предмет куплен за зубы</div>';
}
$is2 .= '</small>'; $is2 .= '</small>';
} }
if ($preview == "preview") { if ($preview == "preview") {
$kolvoprint = "<small style=\"float:right; color:grey;\" align=\"right\">Количество: <strong>$steck[0]</strong> шт.</small>"; $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>'; 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++; $i++;
@ -529,6 +542,28 @@ ORDER BY `1price`ASC , inGroupCount DESC'
} }
} }
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 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 $irow = Db::getRow('select items_users.id, uid, 1price, inGroup, inShop, data, item_id, login, items_main.name, price1
@ -547,7 +582,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
$u->addKr(-$price); $u->addKr(-$price);
$u->addKr($price, $irow['uid']); $u->addKr($price, $irow['uid']);
$col = $u->itemsX($iid); $col = ItemsModel::itemsX($iid);
if ($col > 1) { if ($col > 1) {
Db::sql('update items_users set uid = ?, inGroup = inGroup + 1000, 1price = ?, lastUPD = unix_timestamp(), inShop = 0 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 ?', where inShop = 30 and inOdet = 0 and item_id = ? and uid = ? and inGroup = ? limit ?',
@ -568,56 +603,45 @@ ORDER BY `1price`ASC , inGroupCount DESC'
return '<div>' . $r . '</div>'; return '<div>' . $r . '</div>';
} }
public function rent($action, int $iid, int $price, User $u) public function rent($action, int $iid, int $price): void
{ {
if ($action == "Сдать в магазин" && $price > 0) { if ($action == "Сдать в магазин" && $price > 0) {
$ChImtem = mysql_fetch_array( $this->rentPut($iid, $price);
mysql_query(
'SELECT `id`, `item_id`, `data`, `inGroup`, `uid` FROM `items_users` WHERE `id` = ' . $iid . ' LIMIT 1'
)
);
$ChSudba = Conversion::dataStringToArray($ChImtem['data']);
if (!isset($ChSudba['sudba']) && $ChSudba['sudba'] == 0 && $ChSudba['sudba'] != 1 && !isset($ChSudba['toclan'])) {
if (isset($ChImtem['inGroup']) && $ChImtem['inGroup'] > 0) {
$col = $u->itemsX($ChImtem['id']);
if ($col > 1) {
mysql_query(
'UPDATE `items_users` SET `inShop` = 30, `1price` = ' . $price . ' WHERE `item_id`="' . $ChImtem['item_id'] . '" AND `uid`="' . $ChImtem['uid'] . '" AND `inGroup` = "' . $ChImtem['inGroup'] . '" LIMIT ' . $col . ''
);
} else {
mysql_query(
'UPDATE `items_users` SET `inShop` = 30, `1price` = ' . $price . ' WHERE `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" '
);
}
} else {
mysql_query(
'UPDATE `items_users` set `inShop` = 30, `1price` = ' . $price . ' where `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" '
);
}
}
} elseif ($action == "Забрать") { } elseif ($action == "Забрать") {
$i = mysql_fetch_array( $this->rentTake($iid);
mysql_query( }
'SELECT `im`.`price1`, }
`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`id` = "' . $iid . '" AND `iu`.`inShop` = "30" AND `iu`.`delete` = "0" LIMIT 1'
) private function rentPut(int $id, int $price): void
); {
if (isset($i['inGroup']) and $i['inGroup'] > 0) { $item = Db::getRow('select id, item_id, data, ingroup, uid from items_users where id = ?', [$id]);
$col = $u->itemsX($i['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) { if ($col > 1) {
mysql_query( Db::sql('update items_users set inShop = 0, 1price = ? where item_id = ? and uid = ? and inGroup = ? and inShop = 30 limit ?',
'UPDATE `items_users` SET `inShop` = 0, `1price` = ' . $i['price1'] . ' WHERE `item_id`="' . $i['item_id'] . '" AND `inShop` = "30" AND `uid`="' . $i['uid'] . '" AND `inGroup` = "' . $i['inGroup'] . '" LIMIT ' . $col . '' [$item['price1'], $item['item_id'], $item['uid'], $item['ingroup'], (int)$col]);
);
} else { } else {
mysql_query( Db::sql('update items_users set inShop = 0, 1price = ? where id = ? and uid = ? and inOdet = 0', [$item['price1'], $id, $item['uid']]);
'UPDATE `items_users` SET `inShop` = 0, `1price` = ' . $i['price1'] . ' WHERE `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" '
);
}
} else {
mysql_query(
'UPDATE `items_users` SET `inShop` = 0, `1price` = "' . $i['price1'] . '" WHERE `id` = "' . $iid . '" and `inShop` = "30" LIMIT 1'
);
}
} }
} }
} }

View File

@ -40,7 +40,7 @@ class Magic
if (isset($itm['id'])) { if (isset($itm['id'])) {
//Группа предметов //Группа предметов
if ($itm['group'] == 1 && $u->itemsX($itm['id']) > 1) { if ($itm['group'] == 1 && ItemsModel::itemsX($itm['id']) > 1) {
//вытаскиваем предмет из группы //вытаскиваем предмет из группы
$u->unstack($itm['id'], 1); $u->unstack($itm['id'], 1);
} }

View File

@ -27,7 +27,7 @@ class ActionModel
[ [
$user['id'], $user['id'],
$time, $time,
$user['city'], '',
$user['room'], $user['room'],
$vars, $vars,
UserIp::get(), UserIp::get(),
@ -84,11 +84,6 @@ class ActionModel
return (int)Db::getValue($sql, $binds); return (int)Db::getValue($sql, $binds);
} }
public function getByVals(string $vals)
{
return Db::getRow('select * from actions where uid = ? and vals = ?', [$this->uid, $vals]);
}
public function getLastByVals(string $vals) public function getLastByVals(string $vals)
{ {
return Db::getRow( return Db::getRow(
@ -115,16 +110,6 @@ class ActionModel
Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]); Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]);
} }
public function getDailyQuest(): array
{
$filter = [
"uid = $this->uid",
"vars = 'day_quest'",
];
return self::get($filter);
}
public function getFinishedDailyQuestTasks(int $timeout): array public function getFinishedDailyQuestTasks(int $timeout): array
{ {
$arr = []; $arr = [];

View File

@ -978,10 +978,14 @@ class User
/** Singletone. /** Singletone.
* @param int $uid * @param int $uid
* @param bool $createInstance
* @return User * @return User
*/ */
public static function start(int $uid = 0): User public static function start(int $uid = 0, bool $createInstance = false): User
{ {
if ($createInstance) {
return new self($uid);
}
if (!isset(self::$flag_one)) { if (!isset(self::$flag_one)) {
self::$flag_one = new self($uid); self::$flag_one = new self($uid);
} }
@ -1034,9 +1038,9 @@ class User
'8' => 'Поучаствовать в Башне Смерти', '8' => 'Поучаствовать в Башне Смерти',
]; ];
if (!isset($test['id'])) { if (!isset($test['id'])) {
$n = "<a href='main.php?getq=1'><b style='color:green'>Получить задание</b></a>"; $n = "<a href='/main.php?getq=1'><b style='color:green'>Получить задание</b></a>";
} else { } else {
$n = "<a href='main.php?putq=1'><b style='color:green'>Сдать задание</b></a>"; $n = "<a href='/main.php?putq=1'><b style='color:green'>Сдать задание</b></a>";
$n = $n . "<br><b style='color:green'>" . $q[$test['vals']] . "</b>"; $n = $n . "<br><b style='color:green'>" . $q[$test['vals']] . "</b>";
} }
return $n; return $n;
@ -1760,28 +1764,6 @@ class User
Db::sql('update users set money = money + ? where id = ?', [$amount, $uid]); Db::sql('update users set money = money + ? where id = ?', [$amount, $uid]);
} }
public 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;
}
/*
* $iid Уникальный id прдемета и одновремено флаг что
* покупка из комка.
*/
public function price($vl): string public function price($vl): string
{ {
if ($vl == round($vl)) { if ($vl == round($vl)) {
@ -1941,23 +1923,13 @@ class User
$this->error = 'Предмет не найден в рюкзаке'; $this->error = 'Предмет не найден в рюкзаке';
return; return;
} }
if ($itm['inGroup'] > 0 && $this->itemsX($id) > 1) { if ($itm['inGroup'] > 0 && ItemsModel::itemsX($id) > 1) {
Db::sql('update items_users set inshop = 1 where inshop != 30 and uid = ? and item_id = ? and ingroup = ?', [$this->info['id'], $itm['item_id'], $itm['inGroup']]); Db::sql('update items_users set inshop = 1 where inshop != 30 and uid = ? and item_id = ? and ingroup = ?', [$this->info['id'], $itm['item_id'], $itm['inGroup']]);
} else { } else {
Db::sql('update items_users set inshop = 1 where inshop != 30 and uid = ? and id = ? and inodet = 0', [$this->info['id'], $id]); Db::sql('update items_users set inshop = 1 where inshop != 30 and uid = ? and id = ? and inodet = 0', [$this->info['id'], $id]);
} }
} }
public function itemsX(int $id, $uid = null, $item_id = null): bool|int
{
//fixme какая-то дичь тут.
$item = Db::getRow('select uid, item_id, ingroup, inshop from items_users where id = ?', [$id]);
return Db::getValue(
'select count(id) from items_users where inshop = ? and item_id = ? and uid = ? and ingroup = ?',
[$item['inShop'], $item['item_id'], $item['uid'], $item['ingroup']]
);
}
public function obj_takeItem($id): void public function obj_takeItem($id): void
{ {
$itm = Db::getRow('select id, ingroup from items_users where id = ? and uid = ? and inodet = 0 and inshop = 0'); $itm = Db::getRow('select id, ingroup from items_users where id = ? and uid = ? and inodet = 0 and inshop = 0');
@ -1968,7 +1940,7 @@ class User
$this->error = 'Предмет не найден в сундуке'; $this->error = 'Предмет не найден в сундуке';
return; return;
} }
if ($itm['inGroup'] > 0 && $this->itemsX($id) > 1) { if ($itm['inGroup'] > 0 && ItemsModel::itemsX($id) > 1) {
Db::sql('update items_users set inshop = 0 where inshop != 30 and uid = ? and (id = ? or ingroup = ?) and inodet = 0', [$this->info['id'], $id, $itm['inGroup']]); Db::sql('update items_users set inshop = 0 where inshop != 30 and uid = ? and (id = ? or ingroup = ?) and inodet = 0', [$this->info['id'], $id, $itm['inGroup']]);
} else { } else {
Db::sql('update items_users set inshop = 0 where inshop != 30 and uid = ? and id = ? and inodet = 0', [$this->info['id'], $id]); Db::sql('update items_users set inshop = 0 where inshop != 30 and uid = ? and id = ? and inodet = 0', [$this->info['id'], $id]);
@ -2026,9 +1998,10 @@ class User
//Сверяем требования предмета для его использования //Сверяем требования предмета для его использования
public function runeItem($id, $name = 0, $ruid = 0): void public function runeItem(): void
{ {
if ($id == null) { $name = 0;
$ruid = 0;
if ($ruid < 1 && isset($_GET['use_rune'])) { if ($ruid < 1 && isset($_GET['use_rune'])) {
$ruid = $_GET['use_rune']; $ruid = $_GET['use_rune'];
echo " echo "
@ -2048,7 +2021,6 @@ class User
) )
); );
$it_type = 0;
if (isset($_GET['item_rune'])) { if (isset($_GET['item_rune'])) {
$name = $_GET['item_rune']; $name = $_GET['item_rune'];
} }
@ -2084,10 +2056,7 @@ class User
); );
} }
while ($pl = mysql_fetch_array($sp)) { while ($pl = mysql_fetch_array($sp)) {
$vibor .= '<img src="' . Config::img() . '/i/items/' . $pl['img'] . '"><hr>';
if (!isset($id['id'])) { if (!isset($id['id'])) {
$dt = Conversion::dataStringToArray($pl['data']);
$id = [];
$id = $pl; $id = $pl;
$id_type = $pl['type']; $id_type = $pl['type'];
} }
@ -2096,7 +2065,7 @@ class User
$vid .= '`iu`.`id` = "' . $pl[0] . '" OR'; $vid .= '`iu`.`id` = "' . $pl[0] . '" OR';
} }
} }
}
if ($vi > 0) { if ($vi > 0) {
$itm_inv = $this->genInv(80, ' ' . rtrim($vid, 'OR') . ' '); $itm_inv = $this->genInv(80, ' ' . rtrim($vid, 'OR') . ' ');
@ -2113,8 +2082,6 @@ class User
$ruid = $_GET['use_rune']; $ruid = $_GET['use_rune'];
} }
$idtrue = false;
$rune = mysql_fetch_array( $rune = mysql_fetch_array(
mysql_query( mysql_query(
'SELECT 'SELECT
@ -3155,7 +3122,7 @@ class User
if (isset($po['modif'])) { if (isset($po['modif'])) {
$mx .= ' (мф)'; $mx .= ' (мф)';
} }
$col = $this->itemsX($pl['id']); $col = ItemsModel::itemsX($pl['id']);
if ($col > 1 && $pl['inGroup'] != 0) { if ($col > 1 && $pl['inGroup'] != 0) {
$pl['kolvo'] = $col; $pl['kolvo'] = $col;
$mx .= ' (x' . $col . ')'; $mx .= ' (x' . $col . ')';
@ -4262,10 +4229,10 @@ class User
} }
if ($pl['group'] > 0) { if ($pl['group'] > 0) {
$is1 .= '<br>'; $is1 .= '<br>';
if ($this->itemsX($pl['id']) < $pl['group_max']) { if (ItemsModel::itemsX($pl['id']) < $pl['group_max']) {
$is1 .= '<a href="main.php?inv=1&otdel=' . ((int)$_GET['otdel']) . '&stack=' . $pl['id'] . '&rnd=' . $code . '" title="Собрать"><img src="' . Config::img() . '/i/stack.gif" /></a>'; $is1 .= '<a href="main.php?inv=1&otdel=' . ((int)$_GET['otdel']) . '&stack=' . $pl['id'] . '&rnd=' . $code . '" title="Собрать"><img src="' . Config::img() . '/i/stack.gif" /></a>';
} }
if ($this->itemsX($pl['id']) > 1) { if (ItemsModel::itemsX($pl['id']) > 1) {
$tbl = '<table style="border: 0; width: 100%;" cellspacing="0" cellpadding="5"><tr><td style="text-align: center; width: 70px;" rowspan="2"> $tbl = '<table style="border: 0; width: 100%;" cellspacing="0" cellpadding="5"><tr><td style="text-align: center; width: 70px;" rowspan="2">
<img src="' . Config::img() . '/i/items/' . $pl['img'] . '" alt=""></td> <img src="' . Config::img() . '/i/items/' . $pl['img'] . '" alt=""></td>
<td>Разделить предмет <strong>' . $pl['name'] . '</strong>?</td></tr></table>'; <td>Разделить предмет <strong>' . $pl['name'] . '</strong>?</td></tr></table>';
@ -4816,49 +4783,6 @@ class User
} }
public function btlMagicList(): string
{
$sv = array_fill(1, 12, '<img class="nopriemuse" title="Пустой слот магия" src="' . Config::img() . '/i/items/w/w101.gif" alt="">');
foreach ($this->stats['items'] as $stat) {
if (!in_array($stat['inslot'], [40, 51])) {
continue;
}
if (empty($stat['useInBattle']) || $stat['btl_zd'] > 0 || $stat['iznosNOW'] >= $stat['iznosMAX'] || empty($stat['magic_inci'])) {
$vl = ' class="nopriemuse"';
} else {
$po = Conversion::dataStringToArray($stat['data']);
if ($po['useOnLogin'] == 1) {
$jsvars = "'{$stat['name']}','{$stat['id']}','{$stat['img']}',1,1,'','{$stat['useInBattle']}'";
} else {
$jsvars = "'{$stat['name']}','{$stat['id']}','{$stat['img']}',1,2";
}
$vl = 'style="cursor:pointer" onclick="top.useMagicBattle(' . $jsvars . ')"';
}
$iznos = "Долговечность: {$stat['iznosNOW']} / {$stat['iznosMAX']}";
$img = Config::img() . '/i/items/' . $stat['img'];
$sv[$stat['inOdet'] - 39] = "<img alt='' '$vl' title='$iznos' src='$img'>";
}
$r = '<table style="border:0;border-spacing:0;border-collapse:collapse;">' .
'<tr>' .
'<td>' . $sv[1] . '</td>' .
'<td>' . $sv[2] . '</td>' .
'<td>' . $sv[3] . '</td>' .
'<td>' . $sv[4] . '</td>' .
'<td>' . $sv[5] . '</td>' .
'<td>' . $sv[6] . '</td>' .
'<td>' . $sv[7] . '</td>' .
'<td>' . $sv[8] . '</td>' .
'<td>' . $sv[9] . '</td>' .
'<td>' . $sv[10] . '</td>' .
'<td>' . $sv[11] . '</td>' .
'<td>' . $sv[12] . '</td>' .
'</tr>' .
'</table>';
return str_replace('"', '\"', $r);
}
/** Отрисовка коробочки персонажа с логином. */ /** Отрисовка коробочки персонажа с логином. */
public function getInfoPers($uid, $i1, $sn = 0, $ivv = 0): array public function getInfoPers($uid, $i1, $sn = 0, $ivv = 0): array
{ {
@ -4969,8 +4893,12 @@ class User
$itm = Db::getRow($sql, $args); $itm = Db::getRow($sql, $args);
unset($sql, $args); unset($sql, $args);
if (isset($itm['id'])) { if (!isset($itm['id'])) {
if ($itm['group'] == 1 && $this->itemsX($itm['id']) > 1) { $this->error = 'Предмет не найден в вашем рюкзаке';
return 0;
}
if ($itm['group'] == 1 && ItemsModel::itemsX($itm['id']) > 1) {
$this->unstack($itm['id'], 1); $this->unstack($itm['id'], 1);
} }
@ -5323,13 +5251,11 @@ class User
return 0; return 0;
} }
} }
} else {
$this->error = 'Предмет не найден в вашем рюкзаке';
return 0;
}
} }
public function unstack($id, $x = null) public function unstack($id, $x = null): void
{ {
$id = (int)$id; $id = (int)$id;
$itm = mysql_fetch_array( $itm = mysql_fetch_array(
@ -5344,9 +5270,11 @@ ORDER BY `iu`.lastUPD DESC
LIMIT 1' LIMIT 1'
) )
); );
if (isset($itm['id']) && $itm['inGroup'] > 0 && $itm['inGroupCount'] > 0) { if (!isset($itm['id']) || $itm['inGroup'] <= 0 || $itm['inGroupCount'] <= 0) {
return;
}
if ($x == 0 or $x == null) { if ($x == 0 or $x == null) {
$x = $this->itemsX($itm['id']); //кол-во распада $x = ItemsModel::itemsX($itm['id']); //кол-во распада
$inGroup = 0; $inGroup = 0;
} else { } else {
$inGroup = $this->stackGroupCheck($this->info['id'], $itm['inGroup'], $itm['item_id']); $inGroup = $this->stackGroupCheck($this->info['id'], $itm['inGroup'], $itm['item_id']);
@ -5416,31 +5344,26 @@ LIMIT 1'
`iu`.`lbtl_`, `iu`.`lbtl_`,
`iu`.`bexp`, `iu`.`bexp`,
`iu`.`so`, `iu`.`so`,
`iu`.`blvl` FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`uid` = "' . $this->info['id'] . '" AND `iu`.`delete` = "0" AND `iu`.`inGroup` = "' . $itm['inGroup'] . '" AND `iu`.`item_id` = "' . $itm['item_id'] . '" AND `iu`.`inOdet` = "0" AND `iu`.`inShop` = "0" AND `im`.`group` = "1" LIMIT ' . $x . '' `iu`.`blvl` FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`uid` = "' . $this->info['id'] . '" AND `iu`.`delete` = "0" AND `iu`.`inGroup` = "' . $itm['inGroup'] . '" AND `iu`.`item_id` = "' . $itm['item_id'] . '" AND `iu`.`inOdet` = "0" AND `iu`.`inShop` = "0" AND `im`.`group` = "1" LIMIT ' . $x
); );
$i = 0;
$j = 0;
while ($pl = mysql_fetch_array($sp)) { while ($pl = mysql_fetch_array($sp)) {
$upd = mysql_query( mysql_query(
'UPDATE `items_users` SET `inGroup` = "' . $inGroup . '", `lastUPD` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' 'UPDATE `items_users` SET `inGroup` = "' . $inGroup . '", `lastUPD` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
); );
if ($upd) {
$j++;
} }
$i++; if (ItemsModel::itemsX($itm['id']) == 1) {
}
if ($this->itemsX($itm['id']) == 1) {
mysql_query( mysql_query(
'UPDATE `items_users` SET `inGroup` = "0", `lastUPD` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1' 'UPDATE `items_users` SET `inGroup` = "0", `lastUPD` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
); );
} }
if ($this->itemsX($pl['id']) == 1) { if (ItemsModel::itemsX($pl['id']) == 1) {
mysql_query( mysql_query(
'UPDATE `items_users` SET `inGroup` = "0", `lastUPD` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' 'UPDATE `items_users` SET `inGroup` = "0", `lastUPD` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
); );
} }
} }
}
private function trItem($po): int private function trItem($po): int
{ {
@ -5460,7 +5383,7 @@ LIMIT 1'
return $notr; return $notr;
} }
public function deleteItem($id, $uid = 0, $coldel = 0) public function deleteItem($id, $uid = 0, $coldel = 0): void
{ {
if ($uid != 0) { if ($uid != 0) {
$au = 'AND `iu`.`uid`="' . mysql_real_escape_string($uid) . '"'; $au = 'AND `iu`.`uid`="' . mysql_real_escape_string($uid) . '"';
@ -5476,13 +5399,16 @@ LIMIT 1'
) . '" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" ' . $au . ' AND (`iu`.`delete`="0" OR `iu`.`delete`="1000") LIMIT 1' ) . '" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" ' . $au . ' AND (`iu`.`delete`="0" OR `iu`.`delete`="1000") LIMIT 1'
) )
); );
if (isset($itm['id'])) { if (!isset($itm['id'])) {
$this->error = 'Предмет не найден в вашем рюкзаке';
return;
}
if ($coldel == 0) { if ($coldel == 0) {
//Удаляем целиком //Удаляем целиком
$upd = mysql_query( $upd = mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `id`="' . $itm['id'] . '" LIMIT 1' 'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `id`="' . $itm['id'] . '" LIMIT 1'
); );
$col = $this->itemsX($itm['id']); $col = ItemsModel::itemsX($itm['id']);
if ($col > 0) { if ($col > 0) {
mysql_query( mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '",`inGroup` = "0" WHERE `inGroup`="' . $itm['id'] . '" LIMIT ' . $col 'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '",`inGroup` = "0" WHERE `inGroup`="' . $itm['id'] . '" LIMIT ' . $col
@ -5490,7 +5416,7 @@ LIMIT 1'
} }
} else { } else {
//Удаляем конкретное кол-во //Удаляем конкретное кол-во
$col = $this->itemsX($itm['id']); $col = ItemsModel::itemsX($itm['id']);
if ($col > 1) { if ($col > 1) {
if ($col <= $coldel) { if ($col <= $coldel) {
mysql_query( mysql_query(
@ -5542,11 +5468,8 @@ LIMIT 1'
'&quot;<span style="color: maroon; ">System.inventory</span>&quot;: Предмет &quot;<strong>' . $itm['name'] . '</strong>&quot; [itm:' . $itm['id'] . '] был <strong>выброшен</strong>.', '&quot;<span style="color: maroon; ">System.inventory</span>&quot;: Предмет &quot;<strong>' . $itm['name'] . '</strong>&quot; [itm:' . $itm['id'] . '] был <strong>выброшен</strong>.',
); );
} }
return 1;
} else {
$this->error = 'Предмет не найден в вашем рюкзаке';
}
} }
public function testLevel() public function testLevel()
@ -5980,119 +5903,6 @@ LIMIT 1'
return [$sh, $sm, 'hpNow' => $st['hpNow'], 'mpNow' => $st['mpNow']]; return [$sh, $sm, 'hpNow' => $st['hpNow'], 'mpNow' => $st['mpNow']];
} }
public function ungive_itm_cl($id, $user, $cl): string
{
$itm_ = mysql_fetch_array(
mysql_query(
'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` >= 0 AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1'
)
);
$res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1'));
$user_itm = mysql_fetch_array(
mysql_query('SELECT `id`,`bot`,`clone` FROM `stats` WHERE `id` = "' . $itm_['uid'] . '" LIMIT 1')
);
if ($user_itm['bot'] > 0 || $user_itm['clone'] > 0 || !isset($user_itm['id'])) {
$r = '<font color="#FF0000"><strong>Вы не можете изьять данный предмет, он не принадлежит клану</strong></font><br />';
} elseif (isset($itm_['id'])) {
if ($user['inTurnir'] == 0 && $user['inTurnirnew'] == 0) {
if ($itm_['inOdet'] != 0) {
$o = ', `inOdet` = 0';
} else {
$o = '';
}
$r = '<font color="#FF0000"><strong>Вы успешно изъяли предмет &quot;' . $itm_['name'] . '&quot;</strong></font><br />';
$col = $this->itemsX(((int)$id));
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")'
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1'
);
} else {
$r = '<font color="#FF0000"><strong>Во время участия в турнире запрещено использовать клановое хранилище.</strong></font><br />';
}
} else {
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />';
}
return $r;
}
public function take_itm_cl($id, $user, $cl): string
{
$itm_ = mysql_fetch_array(
mysql_query(
'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` = "-21' . $user['clan'] . '" AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1'
)
);
$res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1'));
if (isset($itm_['id'])) {
$po = Conversion::dataStringToArray($itm_['data']);
if (isset($po['toclan'])) {
$cls = explode('#', $po['toclan']);
$cls = $cls[1];
}
if ($user['inTurnir'] == 0 && $user['inTurnirnew'] == 0) {
$col = $this->itemsX(((int)$id));
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")'
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1'
);
$r = '<font color="#FF0000"><strong>Вы успешно взяли предмет &quot;' . $itm_['name'] . '&quot; из хранилища</strong></font><br />';
} else {
$r = '<font color="#FF0000"><strong>Во время участия в турнире запрещено использовать клановое хранилище.</strong></font><br />';
}
} else {
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />' . $id;
}
return $r;
}
public function rem_itm_cl($user, $cl, $type): void
{
$itms = mysql_query(
'SELECT * FROM `items_users` WHERE (`uid` = "-21' . $user['clan'] . '" OR `data` LIKE "%toclan=' . $user['clan'] . '#%")'
);
while ($pl = mysql_fetch_array($itms)) {
$po = Conversion::dataStringToArray($pl['data']);
if (isset($po['toclan'])) {
$cls = explode('#', $po['toclan']);
$cls = $cls[1];
}
if ($cls == $user['id']) {
if ($pl['uid'] != $user['id']) {
if ($pl['inOdet'] != 0) {
mysql_query('UPDATE `items_users` SET `inOdet` = 0 WHERE `id` = "' . $pl['id'] . '"');
}
}
unset($po['toclan']);
$pl['data'] = Conversion::arrayToDataString($po);
$col = $this->itemsX((int)$pl['id']);
$it_n = mysql_fetch_array(
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"'
);
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $cl . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
);
} elseif ($pl['uid'] == $user['id']) {
$col = $this->itemsX(((int)$pl['id']));
$it_n = mysql_fetch_array(
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
);
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"'
);
mysql_query(
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $cl . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
);
}
}
}
public function isModerator(): bool public function isModerator(): bool
{ {
return $this->isAdmin() || $this->info['align'] > 3 && $this->info['align'] < 4; return $this->isAdmin() || $this->info['align'] > 3 && $this->info['align'] < 4;

View File

@ -81,12 +81,14 @@ class ItemsModel
/** Выбор предмета в инвентаре. /** Выбор предмета в инвентаре.
* @param int $itemId * @param int $itemId
* @param int $ownerId * @param int $ownerId
* @param bool $includeWeared
* @return array * @return array
*/ */
public static function getOwnedItemById(int $itemId, int $ownerId): array public static function getOwnedItemById(int $itemId, int $ownerId, bool $includeWeared = false): array
{ {
return Db::getRow('select * from items_users left join items_main on item_id = items_main.id $iw = $includeWeared ? 1 : 0;
where uid = ? and items_users.id = ? and `delete` = 0 and inOdet = 0 and inShop = 0 and is_arrested = 0', [$ownerId, $itemId]); return Db::getRow("select * from items_users left join items_main on item_id = items_main.id
where uid = ? and items_users.id = ? and `delete` = 0 and inOdet = $iw and inShop = 0 and is_arrested = 0", [$ownerId, $itemId]);
} }
public static function delete(int $id): void public static function delete(int $id): void
@ -216,4 +218,22 @@ class ItemsModel
{ {
Db::sql('update items_users set iznosNOW = iznosNOW + 1 where id = ?', [$itemId]); Db::sql('update items_users set iznosNOW = iznosNOW + 1 where id = ?', [$itemId]);
} }
public static function itemsX(int $id, $uid = null, $item_id = null): bool|int
{
//fixme какая-то дичь тут.
$item = Db::getRow('select uid, item_id, ingroup, inshop from items_users where id = ?', [$id]);
if ($uid) {
$item['uid'] = $uid;
}
if ($item_id) {
$item['item_id'] = $item_id;
}
return Db::getValue(
'select count(id) from items_users where inshop = ? and item_id = ? and uid = ? and ingroup = ?',
[$item['inShop'], $item['item_id'], $item['uid'], $item['ingroup']]
);
}
} }

View File

@ -1,6 +1,7 @@
<?php <?php
use Core\Db; use Core\Db;
use User\ItemsModel;
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php'; require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
@ -34,7 +35,7 @@ where inShop = 30 and `delete` = 0';
foreach (Db::getRows($q) as $row) { foreach (Db::getRows($q) as $row) {
if ($row['inGroup']) { if ($row['inGroup']) {
$col = $u->itemsX($row['id']); $col = ItemsModel::itemsX($row['id']);
if ($col > 1) { if ($col > 1) {
$stmt = Db::prepare( $stmt = Db::prepare(
'update items_users set inShop = 0, 1price = ? 'update items_users set inShop = 0, 1price = ?

View File

@ -1,5 +1,6 @@
<?php <?php
use Battle\BattleHTML;
use Core\Config; use Core\Config;
use Core\Db; use Core\Db;
@ -213,7 +214,7 @@ if (!$isBattle) {
$nabito = floor($btl->users[$btl->uids[$u->info['id']]]['battle_yron']); $nabito = floor($btl->users[$btl->uids[$u->info['id']]]['battle_yron']);
$expmaybe = floor($btl->users[$btl->uids[$u->info['id']]]['battle_exp']); $expmaybe = floor($btl->users[$btl->uids[$u->info['id']]]['battle_exp']);
$tmr = round(($btl->i->timeout / 60), 2); $tmr = round(($btl->i->timeout / 60), 2);
$persMagic = $u->btlMagicList(); $persMagic = BattleHTML::printMagicScrolls();
$za = (int)$btl->stats[$btl->uids[$u->info['id']]]['zona']; $za = (int)$btl->stats[$btl->uids[$u->info['id']]]['zona'];
$zb = (int)$btl->testZonbVis(); $zb = (int)$btl->testZonbVis();
$tactic1 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic1']; $tactic1 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic1'];

View File

@ -1,5 +1,7 @@
<?php <?php
use Battle\BattleHTML;
function e($t) function e($t)
{ {
(new Chat())->debug($t, true); (new Chat())->debug($t, true);
@ -215,7 +217,7 @@ if (!$isBattle) {
{ {
document.getElementById("timer_out").innerHTML = "' . round(($btl->i->timeout / 60), 2) . '"; document.getElementById("timer_out").innerHTML = "' . round(($btl->i->timeout / 60), 2) . '";
} }
$(\'#pers_magic\').html("' . $u->btlMagicList() . '"); $(\'#pers_magic\').html("' . BattleHTML::printMagicScrolls() . '");
g_iCount = 30; g_iCount = 30;
noconnect = 15; noconnect = 15;
connect = 1; connect = 1;

View File

@ -1,5 +1,7 @@
<?php <?php
use Battle\BattleHTML;
function e($t) function e($t)
{ {
(new Chat())->debug($t, true); (new Chat())->debug($t, true);
@ -47,8 +49,7 @@ if (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['i
if (!isset($CRON_CORE)) { if (!isset($CRON_CORE)) {
if ($u->info['online'] < time() - 30) { if ($u->info['online'] < time() - 30) {
mysql_query( mysql_query(
"UPDATE `users` SET `online`='" . time() . "',`timeMain`='" . time( "UPDATE `users` SET `online`='" . time() . "',`timeMain`='" . time() . "' WHERE `id`='" . $u->info['id'] . "' LIMIT 1"
) . "' WHERE `id`='" . $u->info['id'] . "' LIMIT 1"
); );
} }
} }
@ -59,8 +60,7 @@ if (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['i
if ($u->info['battle'] == -1) { if ($u->info['battle'] == -1) {
//завершаем поединок //завершаем поединок
$upd = mysql_query( $upd = mysql_query(
'UPDATE `users` SET `battle` = "0",`online` = "' . time( 'UPDATE `users` SET `battle` = "0",`online` = "' . time() . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
); );
if (!$upd) { if (!$upd) {
if (!isset($CRON_CORE)) { if (!isset($CRON_CORE)) {
@ -218,7 +218,7 @@ if (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['i
{ {
document.getElementById("timer_out").innerHTML = "' . round(($btl->i->timeout / 60), 2) . '"; document.getElementById("timer_out").innerHTML = "' . round(($btl->i->timeout / 60), 2) . '";
} }
$(\'#pers_magic\').html("' . $u->btlMagicList() . '"); $(\'#pers_magic\').html("' . BattleHTML::printMagicScrolls() . '");
g_iCount = 30; g_iCount = 30;
noconnect = 15; noconnect = 15;
connect = 1; connect = 1;
@ -233,14 +233,14 @@ if (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['i
za = ' . (0 + $btl->stats[$btl->uids[$u->info['id']]]['zona']) . '; genZoneAtack(); za = ' . (0 + $btl->stats[$btl->uids[$u->info['id']]]['zona']) . '; genZoneAtack();
zb = ' . (0 + $btl->testZonbVis()) . '; genZoneBlock(); zb = ' . (0 + $btl->testZonbVis()) . '; genZoneBlock();
refleshPoints(); refleshPoints();
tactic(1,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic1']) . '); tactic(1,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic1']) . ')
tactic(2,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic2']) . '); tactic(2,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic2']) . ')
tactic(3,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic3']) . '); tactic(3,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic3']) . ')
tactic(4,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic4']) . '); tactic(4,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic4']) . ')
tactic(5,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic5']) . '); tactic(5,' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic5']) . ')
tactic(6,' . (0 + floor($btl->users[$btl->uids[$u->info['id']]]['tactic6'])) . '); tactic(6,' . (0 + floor($btl->users[$btl->uids[$u->info['id']]]['tactic6'])) . ')
smnpty=' . (0 + $u->info['smena']) . '; smnpty=' . (0 + $u->info['smena']) . ';
mainstatus(' . $btl->mainStatus . '); mainstatus(' . $btl->mainStatus . ')
tactic(7,"' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic7']) . '"); tactic(7,"' . (0 + $btl->users[$btl->uids[$u->info['id']]]['tactic7']) . '");
smena_alls = "0"; smena_alls = "0";
ggcode="' . $code . '"; ggcode="' . $code . '";

View File

@ -444,7 +444,7 @@ if (isset($btl_last['id']) && $u->info['battle'] == 0) {
} elseif (isset($_GET['oid']) && isset($_GET['inv'])) { } elseif (isset($_GET['oid']) && isset($_GET['inv'])) {
$act = $u->odetItem($_GET['oid'], $u->info['id']); $act = $u->odetItem($_GET['oid'], $u->info['id']);
} elseif (isset($_GET['item_rune']) && isset($_GET['inv'])) { } elseif (isset($_GET['item_rune']) && isset($_GET['inv'])) {
$u->runeItem(null); $u->runeItem();
} elseif (isset($_GET['remitem'], $_GET['inv'])) { } elseif (isset($_GET['remitem'], $_GET['inv'])) {
$act = $u->snatItemAll($u->info['id']); $act = $u->snatItemAll($u->info['id']);
} elseif (isset($_GET['delete']) && isset($_GET['inv']) && $u->newAct($_GET['sd4'])) { } elseif (isset($_GET['delete']) && isset($_GET['inv']) && $u->newAct($_GET['sd4'])) {

View File

@ -35,8 +35,6 @@ if (
$_GET['events'] = 1; $_GET['events'] = 1;
} }
$storage = new ItemStorage();
//Возможности текущего титула //Возможности текущего титула
$tt = [ $tt = [
0 => ['000000000', 'Доступные каналы'], 0 => ['000000000', 'Доступные каналы'],
@ -67,10 +65,10 @@ if ($u->info['clan_prava'] != 'glava') {
mysql_query('SELECT * FROM `clan_tituls` WHERE `id` = "' . $u->info['clan_prava'] . '" LIMIT 1') mysql_query('SELECT * FROM `clan_tituls` WHERE `id` = "' . $u->info['clan_prava'] . '" LIMIT 1')
); );
if (!isset($utitl['id'])) { if (!isset($utitl['id'])) {
$utitl = mysql_fetch_array(mysql_query('SELECT * FROM `clan_tituls` WHERE `id` = 2 LIMIT 1')); $utitl = mysql_fetch_array(mysql_query('select * from clan_tituls where id = 2 limit 1'));
} }
} else { } else {
$utitl = mysql_fetch_array(mysql_query('SELECT * FROM `clan_tituls` WHERE `id` = 1 LIMIT 1')); $utitl = mysql_fetch_array(mysql_query('select * from clan_tituls where id = 1 limit 1'));
} }
if (isset($utitl['id'])) { if (isset($utitl['id'])) {
@ -379,18 +377,18 @@ $lvl_prava = [
<script> <script>
function openMod(title, dat) { function openMod(title, dat) {
var d = document.getElementById('useMagic'); var d = document.getElementById('useMagic');
if (d != undefined) { if (d) {
document.getElementById('modtitle').innerHTML = document.getElementById('modtitle').innerHTML = `
'<table width="100%" border="0" cellspacing="0" cellpadding="0">' + <table width="100%" border="0" cellspacing="0" cellpadding="0">
'<tr>' + <tr>
'<td valign="top">' + title + '</td>' + <td valign="top">${title}</td>
'<td width="30" valign="top">' + <td width="30" valign="top">
'<div align="right">' + <div align="right">
'<a title="Закрыть" onClick="closeMod(); return false;" href="#">x</a>' + <a title="Закрыть" onClick="closeMod(); return false;" href="#">x</a>
'</div>' + </div>
'</td>' + </td>
'</tr>' + </tr>
'</table>'; </table>`;
document.getElementById('moddata').innerHTML = dat; document.getElementById('moddata').innerHTML = dat;
d.style.display = ''; d.style.display = '';
} }
@ -398,7 +396,7 @@ $lvl_prava = [
function closeMod() { function closeMod() {
var d = document.getElementById('useMagic'); var d = document.getElementById('useMagic');
if (d != undefined) { if (d) {
document.getElementById('modtitle').innerHTML = ''; document.getElementById('modtitle').innerHTML = '';
document.getElementById('moddata').innerHTML = ''; document.getElementById('moddata').innerHTML = '';
d.style.display = 'none'; d.style.display = 'none';
@ -406,61 +404,25 @@ $lvl_prava = [
} }
function addNewEvent() { function addNewEvent() {
openMod('Добавить событие', const html = `
'<form method="post" action="main.php?clan&events&add=<?=$code?>">" + <form method="post" action="main.php?clan&events&add=<?=$code?>">
"Заголовок: <input name=" Заголовок: <input name="titleadd" style="335px;" type="text"><br>
titleadd <textarea name="textadd" style="412px;" rows="5"></textarea><br>
" value=" <div align="right"><input type="submit" value="Добавить событие"></div>
" style=" </form>
335 `;
px; openMod('Добавить событие', html);
" type="
text
"><br>" +
"<textarea name="
textadd
" style="
412
px;
" rows="
5
"></textarea><br>" +
"<div align="
right
"><input type="
submit
" value="
Добавить
событие
"></div>" +
"</form>');
} }
function addNewTitul() { function addNewTitul() {
openMod('Добавить титул', const html = `
'<form method="post" action="main.php?clan&titul&add=<?=$code?>">" + <form method="post" action="main.php?clan&titul&add=<?=$code?>">
"Название титула: <input name=" Название титула: <input name="tituladd" style="235px;" type="text"><br>
tituladd <small style="left">(не более 30-ти символов)</small>
" value=" <input style="right" type="submit" value="Добавить титул">
" style=" </form>
235 `;
px; openMod('Добавить титул', html);
" type="
text
"><br>" +
"<small style="
left
">(не более 30-ти символов)</small>" +
"<input style="
right
" type="
submit
" value="
Добавить
титул
">" +
"</div>" +
"</form>');
} }
// С этим мигающим кулаком надо что-то делать.. // С этим мигающим кулаком надо что-то делать..
@ -527,6 +489,8 @@ if (!$res) {
?> ?>
<?php <?php
$storage = new ItemStorage();
if ($u->info['clan_prava'] != 'glava') { if ($u->info['clan_prava'] != 'glava') {
if (isset($_GET['clan_exit']) && $u->newAct($_GET['sd4']) == true) { if (isset($_GET['clan_exit']) && $u->newAct($_GET['sd4']) == true) {
if ($u->info['money'] >= 50) { if ($u->info['money'] >= 50) {
@ -547,7 +511,7 @@ if ($u->info['clan_prava'] != 'glava') {
'UPDATE `users` SET `clan` = 0, `clan_zv` = 0, `align` = 0, `clan_prava` = "0|0|0|0", `money` = `money` - 50 , `clan_delay` = "' . time() . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1' 'UPDATE `users` SET `clan` = 0, `clan_zv` = 0, `align` = 0, `clan_prava` = "0|0|0|0", `money` = `money` - 50 , `clan_delay` = "' . time() . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
); );
} }
$ar = $u->rem_itm_cl($u->info, $res['id'], 7); $storage->remove(7);
} else { } else {
echo '<script>setTimeout("alert(\'Для выхода из клана требуется наличие 50 кр.\');",500)</script>'; echo '<script>setTimeout("alert(\'Для выхода из клана требуется наличие 50 кр.\');",500)</script>';
} }
@ -1126,7 +1090,7 @@ if ($u->info['clan_prava'] != 'glava') {
} elseif ($usr['clan_prava'] == 'galva' && $u->info['clan_prava'] != 'glava') { } elseif ($usr['clan_prava'] == 'galva' && $u->info['clan_prava'] != 'glava') {
echo '<font color="#FF0000"><b>Игрок старше вас по званию, либо звания совпадают</b></font><br>'; echo '<font color="#FF0000"><b>Игрок старше вас по званию, либо звания совпадают</b></font><br>';
} else { } else {
$ar = $u->rem_itm_cl($usr, $res['id'], 8); $storage->remove(8);
if ($usr['level'] < 10) { if ($usr['level'] < 10) {
mysql_query( mysql_query(
'UPDATE `users` SET `clan_prava` = 0, `clan` = 0, `clan_zv` = 0, `mod_zvanie` = "", `align` = 0, `clan_delay` = "0" WHERE `id` = "' . $usr['id'] . '" LIMIT 1' 'UPDATE `users` SET `clan_prava` = 0, `clan` = 0, `clan_zv` = 0, `mod_zvanie` = "", `align` = 0, `clan_delay` = "0" WHERE `id` = "' . $usr['id'] . '" LIMIT 1'
@ -2346,7 +2310,7 @@ if ($u->info['clan_prava'] != 'glava') {
if ($u->testBattle($btlud['battle']) == true) { if ($u->testBattle($btlud['battle']) == true) {
echo '<font color="#FF0000"><b>Нельзя изымать предметы с персонажа в бою</b></font><br>'; echo '<font color="#FF0000"><b>Нельзя изымать предметы с персонажа в бою</b></font><br>';
} else { } else {
echo $u->ungive_itm_cl($_GET['ungive_itm'], $u->info, $res['id']); echo $storage->backToOwner($itm['id']);
} }
} }
} elseif (isset($_GET['take_itm']) && $tt[4][0] == 1) { } elseif (isset($_GET['take_itm']) && $tt[4][0] == 1) {
@ -2357,7 +2321,7 @@ if ($u->info['clan_prava'] != 'glava') {
) )
); );
if (isset($itm['id'])) { if (isset($itm['id'])) {
echo $u->take_itm_cl($_GET['take_itm'], $u->info, $res['id']); echo $storage->take($itm['id']);
} }
} elseif (isset($_GET['give_itm'])) { } elseif (isset($_GET['give_itm'])) {
$itm = mysql_fetch_array( $itm = mysql_fetch_array(
@ -2369,7 +2333,7 @@ if ($u->info['clan_prava'] != 'glava') {
if ($itmc >= $lvl_prava[$res['level']][5]) { if ($itmc >= $lvl_prava[$res['level']][5]) {
echo '<font color="#FF0000"><b>Хранилище переполнено</b></font><br>'; echo '<font color="#FF0000"><b>Хранилище переполнено</b></font><br>';
} elseif (isset($itm['id'])) { } elseif (isset($itm['id'])) {
echo $storage->put($_GET['give_itm'], $res['id']); echo $storage->put($itm['id']);
} }
} }
if ($tt[4][0] == 1) { if ($tt[4][0] == 1) {
@ -2421,7 +2385,7 @@ if ($u->info['clan_prava'] != 'glava') {
<?php } elseif (isset($_GET['titul']) && $tt[11][0] == 1) { ?> <?php } elseif (isset($_GET['titul']) && $tt[11][0] == 1) { ?>
<script> <script>
function editTitul(id) { function editTitul(id) {
if ($('#edpnltitul' + id).css('display') == 'none') { if ($('#edpnltitul' + id).css('display') === 'none') {
$('#edpnltitul' + id).css({'display': ''}); $('#edpnltitul' + id).css({'display': ''});
} else { } else {
$('#edpnltitul' + id).css({'display': 'none'}); $('#edpnltitul' + id).css({'display': 'none'});

View File

@ -69,12 +69,12 @@ if ($u->room['file'] == 'commision2') {
$itemkt['min'] = $itemkt['min'] * $itemcount['total']; $itemkt['min'] = $itemkt['min'] * $itemcount['total'];
$itemkt['max'] = $itemkt['max'] * $itemcount['total']; $itemkt['max'] = $itemkt['max'] * $itemcount['total'];
if ($_POST['summTR'] >= $itemkt['min'] && $_POST['summTR'] <= $itemkt['max']) { if ($_POST['summTR'] >= $itemkt['min'] && $_POST['summTR'] <= $itemkt['max']) {
$comshop->rent(mysql_real_escape_string($_POST['PresTR']), (int)$_POST['iid'], (int)$_POST['summTR'], $u); $comshop->rent(mysql_real_escape_string($_POST['PresTR']), (int)$_POST['iid'], (int)$_POST['summTR']);
} else { } else {
$re = '<div align="left">Не удалось сдать предмет его цена может быть мин: ' . $itemkt['min'] . 'кр. макс: ' . $itemkt['max'] . 'кр. кол-во: ' . $itemcount['total'] . '</div>'; $re = '<div align="left">Не удалось сдать предмет его цена может быть мин: ' . $itemkt['min'] . 'кр. макс: ' . $itemkt['max'] . 'кр. кол-во: ' . $itemcount['total'] . '</div>';
} }
} else { } else {
$comshop->rent(mysql_real_escape_string($_POST['PresTR']), (int)$_POST['iid'], (int)$_POST['summTR'], $u); $comshop->rent(mysql_real_escape_string($_POST['PresTR']), (int)$_POST['iid'], (int)$_POST['summTR']);
} }
} }

View File

@ -11,13 +11,44 @@ if (!defined('GAME')) {
die(); die();
} }
$am = new ActionModel($u->info['id']); $dailyQuest = new class {
private int $uid;
private string $login;
private ActionModel $am;
private int $room;
private const ACT = 'day_quest';
private string $status = '';
private int $exp;
$txt ??= ''; public function __construct()
if (isset($_GET['getq'])) { {
$zadID = !$am->getDailyQuest() ? mt_rand(1, 7) : 0;
$txt .= match ($zadID) { $this->uid = User::start()->info['id'];
$this->login = User::start()->info['login'];
$this->room = User::start()->info['room'];
$this->exp = User::start()->info['exp'];
$this->am = new ActionModel($this->uid);
}
private function getQuest(): array
{
return $this->am::get(["uid = $this->uid", 'vars = ' . self::ACT], 'val, vals, time');
}
private function sendSysChat(string $message): void
{
$cmsg = new ChatMessage();
$cmsg->setRoom($this->room);
$cmsg->setTo($this->login);
$cmsg->setType(6);
$cmsg->setText($message);
(new Chat())->sendMsg($cmsg);
}
public function get(): void
{
$questId = $this->getQuest() ? 0 : mt_rand(1, 7);
$this->status .= match ($questId) {
1 => 'Говорят в городе завелись всякие Трупожоры. Пойди да убей двоих, порадуй бабушку.', 1 => 'Говорят в городе завелись всякие Трупожоры. Пойди да убей двоих, порадуй бабушку.',
2 => 'Покажи на что способен! Поучаствуй в 10 хаотических поединках!', 2 => 'Покажи на что способен! Поучаствуй в 10 хаотических поединках!',
3 => 'Необходимо исследовать для бабушки два любых подземелия, ей очень интересно что там внутри! Только гляди милок, пропуски не используй!', 3 => 'Необходимо исследовать для бабушки два любых подземелия, ей очень интересно что там внутри! Только гляди милок, пропуски не используй!',
@ -28,95 +59,116 @@ if (isset($_GET['getq'])) {
8 => 'Сходи-ка милок в Башню Смерти! Да попробуй там свои силенки.', 8 => 'Сходи-ка милок в Башню Смерти! Да попробуй там свои силенки.',
default => 'Эх шустрый малец, получал задание уже сегодня! Завтра приходи, накормлю чем нибудь вкусным ну и задание дам!' default => 'Эх шустрый малец, получал задание уже сегодня! Завтра приходи, накормлю чем нибудь вкусным ну и задание дам!'
}; };
$txt = "<b>$txt</b>"; $this->status = "<b>$this->status</b>";
if ($zadID > 0) { if ($questId) {
ActionModel::new($u->info, $zadID, 'day_quest'); $this->am::new(['id' => $this->uid, 'room' => $this->room], $questId, self::ACT);
sendSysChat($txt); $this->sendSysChat($this->status);
} }
} }
function sendSysChat($message): void public function getControl(): string
{ {
global $u; $test = ActionModel::getOne(["uid = $this->uid", 'vars = ' . self::ACT], 'vals');
$cmsg = new ChatMessage(); $q = [
$cmsg->setRoom($u->info['room']); '1' => 'Убийство Трупожоров',
$cmsg->setTo($u->info['login']); '2' => 'Победы в хаотических боях',
$cmsg->setType(6); '3' => 'Спуск в Подземелия',
$cmsg->setText($message); '4' => 'Набрать в хаотических поединках 100 000 Опыта',
(new Chat())->sendMsg($cmsg); '5' => 'Открыть Сундук Трупожора',
'6' => 'Посетить Излом Хаоса',
'7' => 'Сдача 3 заданий в пещерах',
'8' => 'Поучаствовать в Башне Смерти',
];
$n = $test ? "<a href='/main.php?putq=1'>Сдать задание</a><br>" . $q[$test['vals']] : "<a href='/main.php?getq=1'>Получить задание</a>";
return "<b style='color:green'>$n</b>";
} }
function giveDailyQuestPrize(): void private function givePrize(): void
{ {
global $u; Db::sql('update actions set vals = 0 where vars = ? and uid = ?', [self::ACT, $this->uid]);
Db::sql('update actions set vals = 0 where vars = ? and uid = ?', ['day_quest', $u->info['id']]); Db::sql('update users_achiv set zb = zb + 1 where id = ?', [$this->uid]);
Db::sql('update users_achiv set zb = zb + 1 where id = ?', [$u->info['id']]); ItemsModel::addItem(10020, $this->uid, '|sudba=' . $this->login);
ItemsModel::addItem(10020, $u->info['id'], '|sudba=' . $u->info['login']); StatsModel::addRepexpById($this->uid, 50); //Репутация +20
StatsModel::addRepexpById($u->info['id'], 50); //Репутация +20 }
public function getStatus(): void
{
$quest = $this->getQuest();
if (!$quest) {
$this->status = 'У тебя нет задания милок, не юли! Хоть бабушка плохо видит но бабушка хорошо помнит.';
return;
}
$questId = $quest['vals'];
$finishedTasks = $this->am->getFinishedDailyQuestTasks($quest['time']);
$happy = 'Порадовал бабушку! ';
switch ($questId) {
case 1:
if ($finishedTasks['end_trup'] > 1) {
$this->status = $happy . 'Убил ипостата! Может на печи полежим? - Нет, ну держи жетончик!';
$this->givePrize();
} else {
$this->status = 'Победи в боях с Трупожором ' . $finishedTasks['end_trup'] . '/2.';
}
break;
case 2:
if ($finishedTasks['end_xaot'] > 9) {
$this->status = $happy . 'Поучаствовал в боях! А точно покушать не хочешь? - Нет, ну держи жетончик!';
$this->givePrize();
} else {
$this->status = 'Участия в хаотах ' . $finishedTasks['end_xaot'] . '/10.';
}
break;
case 3:
if ($finishedTasks['psh0'] > 1) {
$this->status = $happy . 'Хороший запах! А точно покушать не хочешь? - Нет, ну держи жетончик!';
$this->givePrize();
} else {
$this->status = 'Посещение Подземелий ' . $finishedTasks['psh0'] . '/2.';
}
break;
case 4:
if (($this->exp - $quest['val']) > 100000) {
$this->status = $happy . 'Подрос, подрос! держи жетончик!';
$this->givePrize();
} else {
$this->status = 'Получение ' . ($this->exp - $quest['val']) . '/100 000 опыта.';
}
break;
case 5:
if ($finishedTasks['trup_sun'] > 0) {
$this->status = $happy . 'Сундучек удачу принес? Нет? Ну держи жетончик!';
$this->givePrize();
} else {
$this->status = 'Открытие сундуков Трупожора 0/1';
}
break;
case 6:
if ($finishedTasks['izlom'] > 0) {
$this->status = $happy . 'Так пахнет гарью и смертью Ммммм ... За это тебе жетончик!';
$this->givePrize();
} else {
$this->status = 'Посещение Излома Хаоса 0/1';
}
break;
case 7:
if ($finishedTasks['win'] > 2) {
$this->status = $happy . 'Стало в мире светлее, но бабка как была слепая так и осталась... <br> Чуть не забыла жетончик!';
$this->givePrize();
} else {
$this->status = 'Выполни 3 задания в подземелиях. ' . $finishedTasks['win'] . '/3.';
}
break;
}
$this->sendSysChat("<b>$this->status</b>");
}
};
if (isset($_GET['getq'])) {
$dailyQuest->get();
} }
if (isset($_GET['putq'])) { if (isset($_GET['putq'])) {
$test = $am->getDailyQuest(); $dailyQuest->getStatus();
if (!$test) {
$txt .= 'У тебя нет задания милок, не юли! Хоть бабушка плохо видит но бабушка хорошо помнит.';
} else {
$zadID = $test['vals'];
$finishedTasks = $am->getFinishedDailyQuestTasks($test['time']);
if ($zadID == 1) {
if ($finishedTasks['end_trup'] > 1) {
$txt .= 'Порадовал бабушку! Убил ипостата! Может на печи полежим? - Нет, ну держи жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Победи в боях с Трупожором ' . $finishedTasks['end_trup'] . '/2.';
}
} elseif ($zadID == 2) {
if ($finishedTasks['end_xaot'] > 9) {
$txt .= 'Порадовал бабушку! Поучаствовал в боях! А точно покушать не хочешь? - Нет, ну держи жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Участия в хаотах ' . $finishedTasks['end_xaot'] . '/10.';
}
} elseif ($zadID == 3) {
if ($finishedTasks['psh0'] > 1) {
$txt .= 'Порадовал бабушку! Хороший запах! А точно покушать не хочешь? - Нет, ну держи жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Посещение Подземелий ' . $finishedTasks['psh0'] . '/2.';
}
} elseif ($zadID == 4) {
if (($u->info['exp'] - $test['val']) > 100000) {
$txt .= 'Порадовал бабушку! Подрос, подрос! держи жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Получение ' . ($u->info['exp'] - $test['val']) . '/100 000 опыта.';
}
} elseif ($zadID == 5) {
if ($finishedTasks['trup_sun'] > 0) {
$txt .= 'Порадовал бабушку! Сундучек удачу принес? Нет? Ну держи жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Открытие сундуков Трупожора 0/1';
}
} elseif ($zadID == 6) {
if ($finishedTasks['izlom'] > 0) {
$txt .= 'Порадовал бабушку! Так пахнет гарью и смертью Ммммм ... За это тебе жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Посещение Излома Хаоса 0/1';
}
} elseif ($zadID == 7) {
if ($finishedTasks['win'] > 2) {
$txt .= 'Порадовал бабушку! Стало в мире светлее, но бабка как была слепая так и осталась... <br> Чуть не забыла жетончик!';
giveDailyQuestPrize();
} else {
$txt .= 'Выполни 3 задания в подземелиях. ' . $finishedTasks['win'] . '/3.';
}
}
sendSysChat("<b>$txt</b>");
}
} }
$nowby = Db::getValue('select good from pay_operation where uid = ? and good > 0 order by good desc limit 1', [$u->info['id']]); $nowby = Db::getValue('select good from pay_operation where uid = ? and good > 0 order by good desc limit 1', [$u->info['id']]);
@ -137,7 +189,7 @@ $repovo = $u->rep['rep3'] - $u->rep['rep3_buy'];
<a href="/main.php?skills=1&side=1">+ Способности</a><br> <a href="/main.php?skills=1&side=1">+ Способности</a><br>
<?php endif; ?> <?php endif; ?>
&nbsp;<br> <br>
Опыт:&nbsp;<a href="/exp" target="_blank"><?= number_format($u->info['exp'], 0, ",", " ") ?></a><br> Опыт:&nbsp;<a href="/exp" target="_blank"><?= number_format($u->info['exp'], 0, ",", " ") ?></a><br>
Уровень:&nbsp;<?= $u->info['level']; ?><br> Уровень:&nbsp;<?= $u->info['level']; ?><br>
Побед:&nbsp;<?= number_format($u->info['win'], 0, ",", " ") ?><br> Побед:&nbsp;<?= number_format($u->info['win'], 0, ",", " ") ?><br>
@ -157,4 +209,4 @@ $repovo = $u->rep['rep3'] - $u->rep['rep3_buy'];
Воинственность:&nbsp;<b style="color:green"><?= $repovo; ?> ед.</b><br> Воинственность:&nbsp;<b style="color:green"><?= $repovo; ?> ед.</b><br>
<?php endif; ?> <?php endif; ?>
<br> <br>
<?= $u->dayquest($u->info['id']) ?> <?= $dailyQuest->getControl() ?>

View File

@ -12,9 +12,7 @@ if (!defined('GAME_VERSION')) {
use Core\{Config, Database, Db}; use Core\{Config, Database, Db};
use User\Confirmation; use User\{Confirmation, Register, UserIp};
use User\Register;
use User\UserIp;
Config::init(); Config::init();
Database::init(); Database::init();
@ -149,7 +147,6 @@ $errorMessage = $newUser->getError() ? "<h4>{$newUser->getError()}</h4>" : '';
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<title><?= Config::GAMENAME ?>: Регистрация - создай персонажа в игре.</title> <title><?= Config::GAMENAME ?>: Регистрация - создай персонажа в игре.</title>
<meta name="description" content="<?= Config::get('desc') ?>"/> <meta name="description" content="<?= Config::get('desc') ?>"/>
</head> </head>

View File

@ -1,6 +1,7 @@
<?php <?php
use Helper\Conversion; use Helper\Conversion;
use User\ItemsModel;
header('Expires: Mon, 26 Jul 1970 05:00:00 GMT'); header('Expires: Mon, 26 Jul 1970 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
@ -139,7 +140,7 @@ if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
$x = 0; $x = 0;
$uus = []; $uus = [];
while ($pl = mysql_fetch_array($sp)) { while ($pl = mysql_fetch_array($sp)) {
$x = $u->itemsX($pl['id'], $pl['uid']); $x = ItemsModel::itemsX($pl['id'], $pl['uid']);
$fu = $pl['uid']; $fu = $pl['uid'];
if ($pl['uid'] == $u->tfer['uid1']) { if ($pl['uid'] == $u->tfer['uid1']) {
$pl['uid'] = $u->tfer['uid2']; $pl['uid'] = $u->tfer['uid2'];
@ -301,7 +302,7 @@ if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
function itmInfotf($pl, $cl) function itmInfotf($pl, $cl)
{ {
global $u, $c, $code; global $u, $c, $code;
$x = $u->itemsX($pl['id'], $pl['uid']); $x = ItemsModel::itemsX($pl['id'], $pl['uid']);
if ($x > 1) { if ($x > 1) {
$x = ' (x' . $x . ')'; $x = ' (x' . $x . ')';
} else { } else {