|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Movement\Component\Consequence\PostFlight; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\Crew\Skill\CrewEnhancemenProxy; |
|
9
|
|
|
use Stu\Component\Crew\Skill\SkillEnhancementEnum; |
|
10
|
|
|
use Stu\Component\Ship\AstronomicalMappingEnum; |
|
|
|
|
|
|
11
|
|
|
use Stu\Component\Spacecraft\SpacecraftStateEnum; |
|
12
|
|
|
use Stu\Module\Prestige\Lib\CreatePrestigeLogInterface; |
|
13
|
|
|
use Stu\Module\Ship\Lib\AstroEntryLibInterface; |
|
14
|
|
|
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; |
|
15
|
|
|
use Stu\Module\Spacecraft\Lib\Message\MessageFactoryInterface; |
|
16
|
|
|
use Stu\Module\Spacecraft\Lib\Message\MessageInterface; |
|
17
|
|
|
use Stu\Module\Spacecraft\Lib\Movement\Component\Consequence\AbstractFlightConsequence; |
|
18
|
|
|
use Stu\Module\Spacecraft\Lib\Movement\Route\FlightRouteInterface; |
|
19
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
|
20
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
21
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
22
|
|
|
use Stu\Orm\Repository\AstroEntryRepositoryInterface; |
|
23
|
|
|
|
|
24
|
|
|
class PostFlightAstroMappingConsequence extends AbstractFlightConsequence implements PostFlightConsequenceInterface |
|
25
|
|
|
{ |
|
26
|
8 |
|
public function __construct( |
|
27
|
|
|
private AstroEntryRepositoryInterface $astroEntryRepository, |
|
28
|
|
|
private AstroEntryLibInterface $astroEntryLib, |
|
29
|
|
|
private CreatePrestigeLogInterface $createPrestigeLog, |
|
30
|
|
|
private MessageFactoryInterface $messageFactory |
|
31
|
8 |
|
) {} |
|
32
|
|
|
|
|
33
|
6 |
|
#[Override] |
|
34
|
|
|
protected function skipWhenTractored(): bool |
|
35
|
|
|
{ |
|
36
|
6 |
|
return false; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
6 |
|
#[Override] |
|
40
|
|
|
protected function triggerSpecific( |
|
41
|
|
|
SpacecraftWrapperInterface $wrapper, |
|
42
|
|
|
FlightRouteInterface $flightRoute, |
|
43
|
|
|
MessageCollectionInterface $messages |
|
44
|
|
|
): void { |
|
45
|
|
|
|
|
46
|
6 |
|
if (!$wrapper instanceof ShipWrapperInterface) { |
|
47
|
|
|
return; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
6 |
|
$ship = $wrapper->get(); |
|
51
|
|
|
|
|
52
|
6 |
|
if (!$ship->getAstroState()) { |
|
53
|
1 |
|
return; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
5 |
|
if ($ship->getSystem() === null && $ship->getMapRegion() === null) { |
|
57
|
1 |
|
return; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
4 |
|
$astroEntry = $this->astroEntryLib->getAstroEntryByShipLocation($ship, false); |
|
61
|
4 |
|
if ($astroEntry === null) { |
|
62
|
1 |
|
return; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
3 |
|
$fieldId = $ship->getLocation()->getId(); |
|
66
|
|
|
|
|
67
|
3 |
|
$message = $this->messageFactory->createMessage(null, $ship->getUser()->getId()); |
|
68
|
3 |
|
$messages->add($message); |
|
69
|
|
|
|
|
70
|
3 |
|
if ($astroEntry->getState() === AstronomicalMappingEnum::PLANNED) { |
|
71
|
|
|
/** @var array<int> */ |
|
72
|
2 |
|
$idsToMap = unserialize($astroEntry->getFieldIds()); |
|
73
|
|
|
|
|
74
|
2 |
|
$key = array_search($fieldId, $idsToMap); |
|
75
|
|
|
|
|
76
|
2 |
|
if (is_int($key)) { |
|
77
|
2 |
|
unset($idsToMap[$key]); |
|
78
|
|
|
|
|
79
|
2 |
|
if (empty($idsToMap)) { |
|
80
|
1 |
|
$astroEntry->setFieldIds(''); |
|
81
|
1 |
|
$astroEntry->setState(AstronomicalMappingEnum::MEASURED); |
|
82
|
1 |
|
$message->add(sprintf(_('Die %s hat alle Kartographierungs-Messpunkte erreicht'), $ship->getName())); |
|
83
|
|
|
} else { |
|
84
|
1 |
|
$astroEntry->setFieldIds(serialize($idsToMap)); |
|
85
|
1 |
|
$this->addReachedWaypointInfo($message, $ship); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
2 |
|
$this->createPrestigeLog($ship); |
|
89
|
2 |
|
CrewEnhancemenProxy::addExpertise($ship, SkillEnhancementEnum::REACH_ASTRO_WAYPOINT); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
3 |
|
$astroLab = $wrapper->getAstroLaboratorySystemData(); |
|
94
|
|
|
|
|
95
|
|
|
if ( |
|
96
|
3 |
|
$ship->getState() === SpacecraftStateEnum::ASTRO_FINALIZING |
|
97
|
3 |
|
&& $astroEntry->getState() === AstronomicalMappingEnum::FINISHING |
|
98
|
3 |
|
&& $astroLab !== null |
|
99
|
|
|
) { |
|
100
|
1 |
|
$ship->getCondition()->setState(SpacecraftStateEnum::NONE); |
|
101
|
1 |
|
$astroLab->setAstroStartTurn(null)->update(); |
|
102
|
1 |
|
$astroEntry->setState(AstronomicalMappingEnum::MEASURED); |
|
103
|
1 |
|
$astroEntry->setAstroStartTurn(null); |
|
104
|
1 |
|
$message->add(sprintf(_('Die %s hat das Finalisieren der Kartographierung abgebrochen'), $ship->getName())); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
3 |
|
$this->astroEntryRepository->save($astroEntry); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
2 |
|
private function createPrestigeLog(ShipInterface $ship): void |
|
111
|
|
|
{ |
|
112
|
2 |
|
$this->createPrestigeLog->createLog( |
|
113
|
2 |
|
1, |
|
114
|
2 |
|
sprintf('1 Prestige erhalten für Kartographierungs-Messpunkt "%s"', $ship->getSectorString()), |
|
115
|
2 |
|
$ship->getUser(), |
|
116
|
2 |
|
time() |
|
117
|
2 |
|
); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
1 |
|
private function addReachedWaypointInfo(MessageInterface $message, ShipInterface $ship): void |
|
121
|
|
|
{ |
|
122
|
1 |
|
$message->add(sprintf( |
|
123
|
1 |
|
_('Die %s hat einen Kartographierungs-Messpunkt erreicht: %s'), |
|
124
|
1 |
|
$ship->getName(), |
|
125
|
1 |
|
$ship->getSectorString() |
|
126
|
1 |
|
)); |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
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