|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Smr\Pages\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use DummyShip; |
|
6
|
|
|
use Smr\Page\AccountPage; |
|
7
|
|
|
use Smr\Template; |
|
8
|
|
|
use SmrAccount; |
|
9
|
|
|
|
|
10
|
|
|
class CombatSimulator extends AccountPage { |
|
11
|
|
|
|
|
12
|
|
|
public string $file = 'admin/combat_simulator.php'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @param ?array<mixed> $results |
|
16
|
|
|
* @param array<\AbstractSmrPlayer> $attackers |
|
17
|
|
|
* @param array<\AbstractSmrPlayer> $defenders |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct( |
|
20
|
|
|
private readonly ?array $results = null, |
|
21
|
|
|
private readonly array $attackers = [], |
|
22
|
|
|
private readonly array $defenders = [] |
|
23
|
|
|
) {} |
|
24
|
|
|
|
|
25
|
|
|
public function build(SmrAccount $account, Template $template): void { |
|
26
|
|
|
$template->assign('PageTopic', 'Combat Simulator'); |
|
27
|
|
|
|
|
28
|
|
|
$template->assign('EditDummysLink', (new EditDummies())->href()); |
|
29
|
|
|
$template->assign('DummyNames', DummyShip::getDummyNames()); |
|
30
|
|
|
|
|
31
|
|
|
$duplicates = false; |
|
32
|
|
|
|
|
33
|
|
|
$attackers = $this->attackers; |
|
34
|
|
|
for ($i = count($attackers) + 1; $i <= MAXIMUM_PVP_FLEET_SIZE; ++$i) { |
|
35
|
|
|
$attackers[$i] = null; |
|
36
|
|
|
} |
|
37
|
|
|
$template->assign('Attackers', $attackers); |
|
38
|
|
|
|
|
39
|
|
|
$defenders = $this->defenders; |
|
40
|
|
|
for ($i = count($defenders) + 1; $i <= MAXIMUM_PVP_FLEET_SIZE; ++$i) { |
|
41
|
|
|
$defenders[$i] = null; |
|
42
|
|
|
} |
|
43
|
|
|
$template->assign('Defenders', $defenders); |
|
44
|
|
|
|
|
45
|
|
|
$template->assign('Duplicates', $duplicates); |
|
46
|
|
|
|
|
47
|
|
|
$template->assign('CombatSimHREF', (new CombatSimulatorProcessor())->href()); |
|
48
|
|
|
|
|
49
|
|
|
$template->assign('TraderCombatResults', $this->results); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|