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