|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Ship\Lib\Battle\AlertDetection; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Component\Ship\ShipAlertStateEnum; |
|
6
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
7
|
|
|
use Stu\Module\Ship\Lib\Battle\Party\AlertStateBattleParty; |
|
8
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
9
|
|
|
|
|
10
|
|
|
class AlertedShipInformation implements AlertedShipInformationInterface |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
4 |
|
public function addAlertedShipsInfo( |
|
14
|
|
|
ShipInterface $incomingShip, |
|
15
|
|
|
array $alertedBattleParties, |
|
16
|
|
|
InformationInterface $informations |
|
17
|
|
|
): void { |
|
18
|
|
|
|
|
19
|
4 |
|
$this->addInformation( |
|
20
|
4 |
|
$incomingShip, |
|
21
|
4 |
|
$alertedBattleParties, |
|
22
|
4 |
|
ShipAlertStateEnum::ALERT_RED, |
|
23
|
4 |
|
false, |
|
24
|
4 |
|
'Flotte(n) auf [b][color=red]Alarm-Rot![/color][/b]', |
|
25
|
4 |
|
$informations |
|
26
|
4 |
|
); |
|
27
|
4 |
|
$this->addInformation( |
|
28
|
4 |
|
$incomingShip, |
|
29
|
4 |
|
$alertedBattleParties, |
|
30
|
4 |
|
ShipAlertStateEnum::ALERT_RED, |
|
31
|
4 |
|
true, |
|
32
|
4 |
|
'Einzelschiff(e) auf [b][color=red]Alarm-Rot![/color][/b]', |
|
33
|
4 |
|
$informations |
|
34
|
4 |
|
); |
|
35
|
4 |
|
$this->addInformation( |
|
36
|
4 |
|
$incomingShip, |
|
37
|
4 |
|
$alertedBattleParties, |
|
38
|
4 |
|
ShipAlertStateEnum::ALERT_YELLOW, |
|
39
|
4 |
|
false, |
|
40
|
4 |
|
'Flotte(n) auf [b][color=yellow]Alarm-Gelb![/color][/b]', |
|
41
|
4 |
|
$informations |
|
42
|
4 |
|
); |
|
43
|
4 |
|
$this->addInformation( |
|
44
|
4 |
|
$incomingShip, |
|
45
|
4 |
|
$alertedBattleParties, |
|
46
|
4 |
|
ShipAlertStateEnum::ALERT_YELLOW, |
|
47
|
4 |
|
true, |
|
48
|
4 |
|
'Einzelschiff(e) auf [b][color=yellow]Alarm-Gelb![/color][/b]', |
|
49
|
4 |
|
$informations |
|
50
|
4 |
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** @param array<AlertStateBattleParty> $alertedBattleParties */ |
|
54
|
4 |
|
private function addInformation( |
|
55
|
|
|
ShipInterface $incomingShip, |
|
56
|
|
|
array $alertedBattleParties, |
|
57
|
|
|
ShipAlertStateEnum $alertState, |
|
58
|
|
|
bool $isSingleton, |
|
59
|
|
|
string $format, |
|
60
|
|
|
InformationInterface $informations |
|
61
|
|
|
): void { |
|
62
|
|
|
|
|
63
|
4 |
|
$count = count(array_filter( |
|
64
|
4 |
|
$alertedBattleParties, |
|
65
|
4 |
|
fn (AlertStateBattleParty $battlyParty) => $battlyParty->isSingleton() === $isSingleton |
|
66
|
4 |
|
&& $battlyParty->getAlertState() === $alertState |
|
67
|
4 |
|
)); |
|
68
|
|
|
|
|
69
|
4 |
|
if ($count === 0) { |
|
70
|
4 |
|
return; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
4 |
|
$informations->addInformation(sprintf( |
|
74
|
4 |
|
_('In Sektor %d|%d %s %d %s') . "\n", |
|
75
|
4 |
|
$incomingShip->getPosX(), |
|
76
|
4 |
|
$incomingShip->getPosY(), |
|
77
|
4 |
|
$count > 1 ? 'befinden sich' : 'befindet sich', |
|
78
|
4 |
|
$count, |
|
79
|
4 |
|
$format |
|
80
|
4 |
|
)); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|