game/_incl_data/class/Battle/BattleHTML.php
2024-12-10 13:09:03 +02:00

62 lines
2.2 KiB
PHP

<?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);
}
}