|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Movement\Route; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Component\Map\DirectionEnum; |
|
10
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
11
|
|
|
use Stu\Orm\Entity\StarSystem; |
|
12
|
|
|
use Stu\Orm\Entity\StarSystemMap; |
|
13
|
|
|
use Stu\Orm\Repository\StarSystemMapRepositoryInterface; |
|
14
|
|
|
|
|
15
|
|
|
class RandomSystemEntry implements RandomSystemEntryInterface |
|
16
|
|
|
{ |
|
17
|
1 |
|
public function __construct(private StarSystemMapRepositoryInterface $starSystemMapRepository) {} |
|
18
|
|
|
|
|
19
|
1 |
|
#[Override] |
|
20
|
|
|
public function getRandomEntryPoint(SpacecraftWrapperInterface $wrapper, StarSystem $system): StarSystemMap |
|
21
|
|
|
{ |
|
22
|
1 |
|
[$posx, $posy] = $this->getDestinationCoordinates($wrapper, $system); |
|
23
|
|
|
|
|
24
|
|
|
// the destination starsystem map field |
|
25
|
1 |
|
$starsystemMap = $this->starSystemMapRepository->getByCoordinates($system->getId(), $posx, $posy); |
|
26
|
|
|
|
|
27
|
1 |
|
if ($starsystemMap === null) { |
|
28
|
|
|
throw new RuntimeException('starsystem map is missing'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
1 |
|
return $starsystemMap; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return array{0: int,1: int} |
|
36
|
|
|
*/ |
|
37
|
1 |
|
private function getDestinationCoordinates(SpacecraftWrapperInterface $wrapper, StarSystem $system): array |
|
38
|
|
|
{ |
|
39
|
1 |
|
$flightDirection = $wrapper->getComputerSystemDataMandatory()->getFlightDirection(); |
|
40
|
1 |
|
while ($flightDirection === DirectionEnum::NON) { |
|
41
|
1 |
|
$flightDirection = DirectionEnum::from(random_int(1, 4)); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
switch ($flightDirection) { |
|
45
|
1 |
|
case DirectionEnum::BOTTOM: |
|
46
|
1 |
|
$posx = random_int(1, $system->getMaxX()); |
|
47
|
1 |
|
$posy = 1; |
|
48
|
1 |
|
break; |
|
49
|
|
|
case DirectionEnum::TOP: |
|
50
|
|
|
$posx = random_int(1, $system->getMaxX()); |
|
51
|
|
|
$posy = $system->getMaxY(); |
|
52
|
|
|
break; |
|
53
|
|
|
case DirectionEnum::RIGHT: |
|
54
|
|
|
$posx = 1; |
|
55
|
|
|
$posy = random_int(1, $system->getMaxY()); |
|
56
|
|
|
break; |
|
57
|
|
|
case DirectionEnum::LEFT: |
|
58
|
|
|
$posx = $system->getMaxX(); |
|
59
|
|
|
$posy = random_int(1, $system->getMaxY()); |
|
60
|
|
|
break; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
return [$posx, $posy]; |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
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