Зачем-то сделал описание echoscroll() и сделал выхлоп функции через heredoc для избегания ошибок вывода и простоты поддержки

This commit is contained in:
lopar 2020-06-24 09:45:32 +03:00
parent 58da58d010
commit 7f3f422126

View File

@ -330,29 +330,31 @@ function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_colo
HTML; HTML;
} }
/**
* Функция отображает слот для свитков в окне персонажа.
* @param $slot
* @throws \Krugozor\Database\Mysql\Exception
*/
function echoscroll($slot) function echoscroll($slot)
{ {
global $user; global $user;
$all_magic = 0;
if ($user['battle']) { if ($user['battle']) {
$script = 'fbattle'; $script = 'fbattle';
} else {
$script = 'main';
}
$all_magic = 0;
if ($user['battle'] > 0) {
$bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc(); $bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc();
$all_magic = unserialize($bat['magic']); $all_magic = unserialize($bat['magic']);
} else {
$script = 'main';
} }
$dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user[$slot])->fetch_assoc(); $dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user[$slot])->fetch_assoc();
$need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); $need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
if (($user[$slot] > 0) && ($all_magic[$user['id']] < 1 || $need_charge['needcharge'] == 0)) { if (($user[$slot] > 0) && ($all_magic[$user['id']] < 1 || empty($need_charge['needcharge']))) {
$row['id'] = $user[$slot]; $row['id'] = $user[$slot];
if ($dress['magic']) { if ($dress['magic']) {
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); $magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
echo "<a onclick=\""; echo "<a onclick=\"";
if ($magic['targeted'] == 1) { if ($magic['targeted'] == 1) {
echo "okno('Введите название предмета', '" . $script . ".php?use={$row['id']}', 'target'); "; echo "okno('Введите название предмета', '" . $script . ".php?use={$row['id']}', 'target'); ";
@ -364,11 +366,17 @@ function echoscroll($slot)
} }
echo "\"href='#'>"; echo "\"href='#'>";
} }
echo '<img class=\'tooltip\' src="i/sh/' . $dress['img'] . '" width=\'40\' title="<b>' . $dress['name'] . '</b><br /> Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '" height=\'25\' /></a>'; echo <<<ACTIVE_SCROLL
<img class='tooltip' src="i/sh/{$dress['img']}" width='40' title="<b>{$dress['name']}</b><br> Прочность {$dress['duration']} / {$dress['maxdur']} " height='25' alt="Свиток"></a>
ACTIVE_SCROLL;
} elseif (($user[$slot] > 0) && ($all_magic[$user['id']] >= 1) && $need_charge['needcharge'] > 0) { } elseif (($user[$slot] > 0) && ($all_magic[$user['id']] >= 1) && $need_charge['needcharge'] > 0) {
echo "<img src=\"i/sh/magicclock.gif\" width=\"40\" height=\"25\" title='Произведите размен ударами и магия снова станет доступна' />"; echo <<<INACTIVE_SCROLL
<img src="i/sh/magicclock.gif" width="40" height="25" title='Произведите размен ударами и магия снова станет доступна' alt="Свиток">
INACTIVE_SCROLL;
} else { } else {
echo "<img class=\"tooltip\" src=\"i/w13.gif\" width=\"40\" height=\"25\" title='<b>Пустой слот магия</b>' />"; echo <<<EMPTY_SLOT
<img class="tooltip" src="i/w13.gif" width="40" height="25" title='<b>Пустой слот магия</b>' alt="Слот для свитка">
EMPTY_SLOT;
} }
} }