|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Tick\Ship\ManagerComponent; |
|
4
|
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
|
|
6
|
|
|
use Stu\Lib\Information\InformationWrapper; |
|
7
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
8
|
|
|
use Stu\Module\Ship\Lib\Destruction\ShipDestructionCauseEnum; |
|
9
|
|
|
use Stu\Module\Ship\Lib\Destruction\ShipDestructionInterface; |
|
10
|
|
|
use Stu\Module\Ship\Lib\ShipRemoverInterface; |
|
11
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface; |
|
12
|
|
|
use Stu\Orm\Repository\ShipRepositoryInterface; |
|
13
|
|
|
use Stu\Orm\Repository\TradePostRepositoryInterface; |
|
14
|
|
|
|
|
15
|
|
|
class LowerHull implements ManagerComponentInterface |
|
16
|
|
|
{ |
|
17
|
|
|
public function __construct( |
|
18
|
|
|
private ShipRemoverInterface $shipRemover, |
|
19
|
|
|
private ShipDestructionInterface $shipDestruction, |
|
20
|
|
|
private ShipRepositoryInterface $shipRepository, |
|
21
|
|
|
private TradePostRepositoryInterface $tradePostRepository, |
|
22
|
|
|
private ShipWrapperFactoryInterface $shipWrapperFactory |
|
23
|
|
|
) { |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
#[Override] |
|
27
|
|
|
public function work(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$this->lowerTrumfieldHull(); |
|
30
|
|
|
$this->lowerOrphanizedTradepostHull(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
private function lowerTrumfieldHull(): void |
|
34
|
|
|
{ |
|
35
|
|
|
foreach ($this->shipRepository->getDebrisFields() as $ship) { |
|
36
|
|
|
$lower = random_int(5, 15); |
|
37
|
|
|
if ($ship->getHull() <= $lower) { |
|
38
|
|
|
$this->shipRemover->remove($ship); |
|
39
|
|
|
continue; |
|
40
|
|
|
} |
|
41
|
|
|
$ship->setHull($ship->getHull() - $lower); |
|
42
|
|
|
|
|
43
|
|
|
$this->shipRepository->save($ship); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
private function lowerOrphanizedTradepostHull(): void |
|
48
|
|
|
{ |
|
49
|
|
|
foreach ($this->tradePostRepository->getByUser(UserEnum::USER_NOONE) as $tradepost) { |
|
50
|
|
|
$ship = $tradepost->getShip(); |
|
51
|
|
|
|
|
52
|
|
|
$lower = (int)ceil($ship->getMaxHull() / 100); |
|
53
|
|
|
|
|
54
|
|
|
if ($ship->getHull() <= $lower) { |
|
55
|
|
|
$this->shipDestruction->destroy( |
|
56
|
|
|
null, |
|
57
|
|
|
$this->shipWrapperFactory->wrapShip($ship), |
|
58
|
|
|
ShipDestructionCauseEnum::ORPHANIZED_TRADEPOST, |
|
59
|
|
|
new InformationWrapper() |
|
60
|
|
|
); |
|
61
|
|
|
|
|
62
|
|
|
continue; |
|
63
|
|
|
} |
|
64
|
|
|
$ship->setHull($ship->getHull() - $lower); |
|
65
|
|
|
|
|
66
|
|
|
$this->shipRepository->save($ship); |
|
67
|
|
|
} |
|
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