|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Destruction\Handler; |
|
4
|
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
|
|
6
|
|
|
use Stu\Component\Spacecraft\SpacecraftStateEnum; |
|
7
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
8
|
|
|
use Stu\Module\Spacecraft\Lib\Auxiliary\ShipShutdownInterface; |
|
9
|
|
|
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestroyerInterface; |
|
10
|
|
|
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestructionCauseEnum; |
|
11
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftStateChangerInterface; |
|
12
|
|
|
use Stu\Module\Spacecraft\Lib\Torpedo\ClearTorpedoInterface; |
|
13
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
14
|
|
|
use Stu\Orm\Entity\StationInterface; |
|
15
|
|
|
use Stu\Orm\Repository\ConstructionProgressRepositoryInterface; |
|
16
|
|
|
use Stu\Orm\Repository\SpacecraftSystemRepositoryInterface; |
|
17
|
|
|
use Stu\Orm\Repository\StorageRepositoryInterface; |
|
18
|
|
|
use Stu\Orm\Repository\TrumfieldRepositoryInterface; |
|
19
|
|
|
use Stu\Orm\Repository\UserRepositoryInterface; |
|
20
|
|
|
|
|
21
|
|
|
class TransformToTrumfield implements SpacecraftDestructionHandlerInterface |
|
22
|
|
|
{ |
|
23
|
1 |
|
public function __construct( |
|
24
|
|
|
private TrumfieldRepositoryInterface $trumfieldRepository, |
|
25
|
|
|
private SpacecraftSystemRepositoryInterface $shipSystemRepository, |
|
26
|
|
|
private StorageRepositoryInterface $storageRepository, |
|
27
|
|
|
private UserRepositoryInterface $userRepository, |
|
28
|
|
|
private ShipShutdownInterface $shipShutdown, |
|
29
|
|
|
private SpacecraftStateChangerInterface $spacecraftStateChanger, |
|
30
|
|
|
private ClearTorpedoInterface $clearTorpedo, |
|
31
|
|
|
private ConstructionProgressRepositoryInterface $constructionProgressRepository, |
|
32
|
1 |
|
) {} |
|
33
|
|
|
|
|
34
|
|
|
#[Override] |
|
35
|
|
|
public function handleSpacecraftDestruction( |
|
36
|
|
|
?SpacecraftDestroyerInterface $destroyer, |
|
37
|
|
|
SpacecraftWrapperInterface $destroyedSpacecraftWrapper, |
|
38
|
|
|
SpacecraftDestructionCauseEnum $cause, |
|
39
|
|
|
InformationInterface $informations |
|
40
|
|
|
): void { |
|
41
|
|
|
|
|
42
|
|
|
$nobody = $this->userRepository->getFallbackUser(); |
|
43
|
|
|
$spacecraft = $destroyedSpacecraftWrapper->get(); |
|
44
|
|
|
|
|
45
|
|
|
$this->shipShutdown->shutdown($destroyedSpacecraftWrapper, true); |
|
46
|
|
|
$spacecraft->setIsDestroyed(true); |
|
47
|
|
|
|
|
48
|
|
|
// create trumfield entity |
|
49
|
|
|
$trumfield = $this->trumfieldRepository->prototype(); |
|
50
|
|
|
$trumfield->setFormerRumpId($spacecraft->getRump()->getId()); |
|
51
|
|
|
$trumfield->setHuell((int) ceil($spacecraft->getMaxHull() / 20)); |
|
52
|
|
|
$trumfield->setLocation($spacecraft->getLocation()); |
|
53
|
|
|
$this->trumfieldRepository->save($trumfield); |
|
54
|
|
|
|
|
55
|
|
|
foreach ($spacecraft->getBeamableStorage() as $storage) { |
|
56
|
|
|
$storage->setSpacecraft(null) |
|
57
|
|
|
->setTrumfield($trumfield) |
|
58
|
|
|
->setUser($nobody); |
|
59
|
|
|
|
|
60
|
|
|
$this->storageRepository->save($storage); |
|
61
|
|
|
$spacecraft->getStorage()->removeElement($storage); |
|
62
|
|
|
} |
|
63
|
|
|
foreach ($spacecraft->getStorage() as $storage) { |
|
64
|
|
|
$this->storageRepository->delete($storage); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$this->spacecraftStateChanger->changeShipState($destroyedSpacecraftWrapper, SpacecraftStateEnum::SHIP_STATE_DESTROYED); |
|
68
|
|
|
|
|
69
|
|
|
// delete ship systems |
|
70
|
|
|
foreach ($spacecraft->getSystems() as $system) { |
|
71
|
|
|
$this->shipSystemRepository->delete($system); |
|
72
|
|
|
} |
|
73
|
|
|
$spacecraft->getSystems()->clear(); |
|
74
|
|
|
|
|
75
|
|
|
// delete torpedo storage |
|
76
|
|
|
$this->clearTorpedo->clearTorpedoStorage($destroyedSpacecraftWrapper); |
|
77
|
|
|
|
|
78
|
|
|
if (!$spacecraft instanceof StationInterface) { |
|
79
|
|
|
return; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$influenceArea = $spacecraft->getInfluenceArea(); |
|
83
|
|
|
if ($influenceArea !== null) { |
|
84
|
|
|
$influenceArea->unsetStation(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$constructionProgress = $spacecraft->getConstructionProgress(); |
|
88
|
|
|
if ($constructionProgress !== null) { |
|
89
|
|
|
$this->constructionProgressRepository->delete($constructionProgress); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths