|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Ship\Lib\Battle\Party; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\Collection; |
|
6
|
|
|
use Stu\Component\Ship\ShipAlertStateEnum; |
|
7
|
|
|
use Stu\Module\Ship\Lib\Battle\ShipAttackCauseEnum; |
|
8
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
|
9
|
|
|
|
|
10
|
|
|
class AlertStateBattleParty extends AbstractBattleParty implements AlertedBattlePartyInterface |
|
11
|
|
|
{ |
|
12
|
|
|
private ShipAlertStateEnum $leaderAlertState; |
|
13
|
|
|
private bool $isSingleton = false; |
|
14
|
|
|
|
|
15
|
2 |
|
public function __construct( |
|
16
|
|
|
ShipWrapperInterface $leader |
|
17
|
|
|
) { |
|
18
|
2 |
|
parent::__construct($leader); |
|
19
|
|
|
|
|
20
|
2 |
|
$this->leaderAlertState = $leader->get()->getAlertState(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
2 |
|
public function initMembers(): Collection |
|
24
|
|
|
{ |
|
25
|
2 |
|
$fleet = $this->leader->getFleetWrapper(); |
|
26
|
|
|
|
|
27
|
2 |
|
if ($fleet === null) { |
|
28
|
1 |
|
$this->isSingleton = true; |
|
29
|
1 |
|
return $this->createSingleton($this->leader); |
|
30
|
|
|
} else { |
|
31
|
|
|
|
|
32
|
|
|
// only uncloaked and unwarped ships enter fight |
|
33
|
1 |
|
return $fleet->getShipWrappers() |
|
34
|
1 |
|
->filter(fn (ShipWrapperInterface $wrapper) => !$wrapper->get()->getCloakState() |
|
35
|
1 |
|
&& !$wrapper->get()->isWarped() |
|
36
|
1 |
|
&& $wrapper->get()->getAlertState()->isAtLeast($this->leaderAlertState)); |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function isSingleton(): bool |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->isSingleton; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getAlertState(): ShipAlertStateEnum |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->leaderAlertState; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getAttackCause(): ShipAttackCauseEnum |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->leaderAlertState->getAttackCause(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getAlertDescription(): string |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->leaderAlertState === ShipAlertStateEnum::ALERT_RED |
|
58
|
|
|
? '[b][color=red]Alarm-Rot[/color][/b]' |
|
59
|
|
|
: '[b][color=yellow]Alarm-Gelb[/color][/b]'; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|