1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib\Movement\Component\Consequence\Flight; |
6
|
|
|
|
7
|
|
|
use Stu\Component\Ship\System\ShipSystemManagerInterface; |
8
|
|
|
use Stu\Component\Ship\System\ShipSystemTypeEnum; |
9
|
|
|
use Stu\Module\Ship\Lib\Message\Message; |
10
|
|
|
use Stu\Module\Ship\Lib\Message\MessageCollectionInterface; |
11
|
|
|
use Stu\Module\Ship\Lib\Message\MessageInterface; |
12
|
|
|
use Stu\Module\Ship\Lib\Movement\Component\Consequence\AbstractFlightConsequence; |
13
|
|
|
use Stu\Module\Ship\Lib\Movement\Route\FlightRouteInterface; |
14
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
15
|
|
|
|
16
|
|
|
class DriveActivationConsequence extends AbstractFlightConsequence |
17
|
|
|
{ |
18
|
|
|
private ShipSystemManagerInterface $shipSystemManager; |
19
|
|
|
|
20
|
9 |
|
public function __construct(ShipSystemManagerInterface $shipSystemManager) |
21
|
|
|
{ |
22
|
9 |
|
$this->shipSystemManager = $shipSystemManager; |
23
|
|
|
} |
24
|
|
|
|
25
|
7 |
|
protected function triggerSpecific( |
26
|
|
|
ShipWrapperInterface $wrapper, |
27
|
|
|
FlightRouteInterface $flightRoute, |
28
|
|
|
MessageCollectionInterface $messages |
29
|
|
|
): void { |
30
|
7 |
|
if ($wrapper->get()->isTractored()) { |
31
|
1 |
|
return; |
32
|
|
|
} |
33
|
|
|
|
34
|
6 |
|
$message = new Message(); |
35
|
6 |
|
$messages->add($message); |
36
|
|
|
|
37
|
6 |
|
if ($flightRoute->isImpulseDriveNeeded()) { |
38
|
2 |
|
$this->activate( |
39
|
2 |
|
$wrapper, |
40
|
2 |
|
ShipSystemTypeEnum::SYSTEM_IMPULSEDRIVE, |
41
|
2 |
|
$message |
42
|
2 |
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
6 |
|
if ($flightRoute->isWarpDriveNeeded()) { |
46
|
2 |
|
$this->activate( |
47
|
2 |
|
$wrapper, |
48
|
2 |
|
ShipSystemTypeEnum::SYSTEM_WARPDRIVE, |
49
|
2 |
|
$message |
50
|
2 |
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
6 |
|
if ($flightRoute->isTranswarpCoilNeeded()) { |
54
|
2 |
|
$this->activate( |
55
|
2 |
|
$wrapper, |
56
|
2 |
|
ShipSystemTypeEnum::SYSTEM_TRANSWARP_COIL, |
57
|
2 |
|
$message |
58
|
2 |
|
); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
6 |
|
private function activate( |
63
|
|
|
ShipWrapperInterface $wrapper, |
64
|
|
|
int $systemId, |
65
|
|
|
MessageInterface $message |
66
|
|
|
): void { |
67
|
6 |
|
$ship = $wrapper->get(); |
68
|
|
|
|
69
|
6 |
|
if (!$ship->getSystemState($systemId)) { |
70
|
3 |
|
$this->shipSystemManager->activate($wrapper, $systemId); |
71
|
|
|
|
72
|
3 |
|
$message->add(sprintf( |
73
|
3 |
|
_('Die %s aktiviert %s %s'), |
74
|
3 |
|
$ship->getName(), |
75
|
3 |
|
$systemId === ShipSystemTypeEnum::SYSTEM_TRANSWARP_COIL ? 'die' : 'den', |
76
|
3 |
|
ShipSystemTypeEnum::getDescription($systemId) |
77
|
3 |
|
)); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|