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