|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Component\Map\Effects; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Component\Map\Effects\Type\EffectHandlerInterface; |
|
10
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
11
|
|
|
use Stu\Lib\Map\FieldTypeEffectEnum; |
|
12
|
|
|
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; |
|
13
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
14
|
|
|
use Stu\Orm\Entity\Location; |
|
15
|
|
|
|
|
16
|
|
|
final class EffectHandling implements EffectHandlingInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @param array<string, EffectHandlerInterface> $handlerList |
|
20
|
|
|
*/ |
|
21
|
1 |
|
public function __construct( |
|
22
|
|
|
private array $handlerList |
|
23
|
1 |
|
) {} |
|
24
|
|
|
|
|
25
|
1 |
|
#[Override] |
|
26
|
|
|
public function handleSpacecraftTick(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void |
|
27
|
|
|
{ |
|
28
|
1 |
|
$this->walkEffects($wrapper->get()->getLocation(), function (EffectHandlerInterface $handler) use ($wrapper, $information): void { |
|
29
|
1 |
|
$handler->handleSpacecraftTick($wrapper, $information); |
|
30
|
1 |
|
}); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
4 |
|
#[Override] |
|
34
|
|
|
public function addFlightInformationForActiveEffects(Location $location, MessageCollectionInterface $messages): void |
|
35
|
|
|
{ |
|
36
|
4 |
|
$this->walkEffects($location, function (EffectHandlerInterface $handler) use ($location, $messages): void { |
|
37
|
|
|
$handler->addFlightInformation($location, $messages); |
|
38
|
4 |
|
}); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
4 |
|
#[Override] |
|
42
|
|
|
public function handleIncomingSpacecraft(SpacecraftWrapperInterface $wrapper, MessageCollectionInterface $messages): void |
|
43
|
|
|
{ |
|
44
|
4 |
|
$this->walkEffects($wrapper->get()->getLocation(), function (EffectHandlerInterface $handler) use ($wrapper, $messages): void { |
|
45
|
|
|
$handler->handleIncomingSpacecraft($wrapper, $messages); |
|
46
|
4 |
|
}); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
5 |
|
private function walkEffects(Location $location, callable $func): void |
|
50
|
|
|
{ |
|
51
|
5 |
|
foreach ($location->getFieldType()->getEffects() as $effect) { |
|
52
|
2 |
|
if ($effect->hasHandler()) { |
|
53
|
1 |
|
$func($this->getHandler($effect)); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
1 |
|
private function getHandler(FieldTypeEffectEnum $effect): EffectHandlerInterface |
|
59
|
|
|
{ |
|
60
|
1 |
|
if (!array_key_exists($effect->value, $this->handlerList)) { |
|
61
|
|
|
throw new RuntimeException(sprintf('no handler defined for type: %d', $effect->value)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
1 |
|
return $this->handlerList[$effect->value]; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
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