|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Component\Ship\AstronomicalMappingEnum; |
|
|
|
|
|
|
10
|
|
|
use Stu\Component\Ship\ShipStateEnum; |
|
11
|
|
|
use Stu\Orm\Entity\AstronomicalEntryInterface; |
|
12
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
13
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
14
|
|
|
use Stu\Orm\Repository\AstroEntryRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
final class AstroEntryLib implements AstroEntryLibInterface |
|
17
|
|
|
{ |
|
18
|
4 |
|
public function __construct(private AstroEntryRepositoryInterface $astroEntryRepository) {} |
|
19
|
|
|
|
|
20
|
|
|
#[Override] |
|
21
|
|
|
public function cancelAstroFinalizing(ShipWrapperInterface $wrapper): void |
|
22
|
|
|
{ |
|
23
|
|
|
$ship = $wrapper->get(); |
|
24
|
|
|
|
|
25
|
|
|
$ship->setState(ShipStateEnum::SHIP_STATE_NONE); |
|
26
|
|
|
$astroLab = $wrapper->getAstroLaboratorySystemData(); |
|
27
|
|
|
if ($astroLab === null) { |
|
28
|
|
|
throw new RuntimeException('this should not happen'); |
|
29
|
|
|
} |
|
30
|
|
|
$astroLab->setAstroStartTurn(null)->update(); |
|
31
|
|
|
|
|
32
|
|
|
$entry = $this->getAstroEntryByShipLocation($ship, false); |
|
33
|
|
|
if ($entry === null) { |
|
34
|
|
|
throw new RuntimeException('this should not happen'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$entry->setState(AstronomicalMappingEnum::MEASURED); |
|
38
|
|
|
$entry->setAstroStartTurn(null); |
|
39
|
|
|
$this->astroEntryRepository->save($entry); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
#[Override] |
|
43
|
|
|
public function finish(ShipWrapperInterface $wrapper): void |
|
44
|
|
|
{ |
|
45
|
|
|
$ship = $wrapper->get(); |
|
46
|
|
|
|
|
47
|
|
|
$ship->setState(ShipStateEnum::SHIP_STATE_NONE); |
|
48
|
|
|
|
|
49
|
|
|
$astroLab = $wrapper->getAstroLaboratorySystemData(); |
|
50
|
|
|
if ($astroLab === null) { |
|
51
|
|
|
throw new RuntimeException('this should not happen'); |
|
52
|
|
|
} |
|
53
|
|
|
$astroLab->setAstroStartTurn(null)->update(); |
|
54
|
|
|
|
|
55
|
|
|
$entry = $this->getAstroEntryByShipLocation($ship, false); |
|
56
|
|
|
if ($entry === null) { |
|
57
|
|
|
throw new RuntimeException('this should not happen'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$entry->setState(AstronomicalMappingEnum::DONE); |
|
61
|
|
|
$entry->setAstroStartTurn(null); |
|
62
|
|
|
$this->astroEntryRepository->save($entry); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
#[Override] |
|
66
|
|
|
public function getAstroEntryByShipLocation(ShipInterface $ship, bool $showOverSystem = true): ?AstronomicalEntryInterface |
|
67
|
|
|
{ |
|
68
|
|
|
$user = $ship->getUser(); |
|
69
|
|
|
$system = $ship->getSystem(); |
|
70
|
|
|
|
|
71
|
|
|
if ($system !== null) { |
|
72
|
|
|
return $this->getAstroEntryForUser($system, $user); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$overSystem = $ship->isOverSystem(); |
|
76
|
|
|
if ($overSystem !== null && $showOverSystem) { |
|
77
|
|
|
return $this->getAstroEntryForUser($overSystem, $user); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$mapRegion = $ship->getMapRegion(); |
|
81
|
|
|
if ($mapRegion !== null) { |
|
82
|
|
|
return $this->getAstroEntryForUser($mapRegion, $user); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return null; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
private function getAstroEntryForUser(EntityWithAstroEntryInterface $entity, UserInterface $user): ?AstronomicalEntryInterface |
|
89
|
|
|
{ |
|
90
|
|
|
return $entity->getAstronomicalEntries()->get($user->getId()); |
|
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