|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Colony\Lib\Damage; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Lib\Damage\DamageModeEnum; |
|
10
|
|
|
use Stu\Lib\Damage\DamageWrapper; |
|
11
|
|
|
use Stu\Lib\Information\InformationWrapper; |
|
12
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
|
13
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
|
14
|
|
|
use Stu\Orm\Entity\PlanetFieldInterface; |
|
15
|
|
|
|
|
16
|
|
|
final class ApplyBuildingDamage implements ApplyBuildingDamageInterface |
|
17
|
|
|
{ |
|
18
|
1 |
|
public function __construct( |
|
19
|
|
|
private ColonyLibFactoryInterface $colonyLibFactory |
|
20
|
1 |
|
) {} |
|
21
|
|
|
|
|
22
|
|
|
#[Override] |
|
23
|
|
|
public function damageBuilding( |
|
24
|
|
|
DamageWrapper $damageWrapper, |
|
25
|
|
|
PlanetFieldInterface $target, |
|
26
|
|
|
bool $isOrbitField |
|
27
|
|
|
): InformationWrapper { |
|
28
|
|
|
$informations = new InformationWrapper(); |
|
29
|
|
|
|
|
30
|
|
|
$colony = $target->getHost(); |
|
31
|
|
|
if (!$colony instanceof ColonyInterface) { |
|
32
|
|
|
throw new RuntimeException('this should not happen'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$changeable = $colony->getChangeable(); |
|
36
|
|
|
|
|
37
|
|
|
if (!$isOrbitField && $this->colonyLibFactory->createColonyShieldingManager($colony)->isShieldingEnabled()) { |
|
38
|
|
|
$damage = (int) $damageWrapper->getDamageRelative($colony, DamageModeEnum::SHIELDS); |
|
39
|
|
|
if ($damage > $changeable->getShields()) { |
|
40
|
|
|
$informations->addInformation("- Schildschaden: " . $changeable->getShields()); |
|
41
|
|
|
$informations->addInformation("-- Schilde brechen zusammen!"); |
|
42
|
|
|
|
|
43
|
|
|
$changeable->setShields(0); |
|
44
|
|
|
} else { |
|
45
|
|
|
$changeable->setShields($changeable->getShields() - $damage); |
|
46
|
|
|
$informations->addInformation("- Schildschaden: " . $damage . " - Status: " . $changeable->getShields()); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
if ($damageWrapper->getNetDamage() <= 0) { |
|
50
|
|
|
return $informations; |
|
51
|
|
|
} |
|
52
|
|
|
$damage = (int) $damageWrapper->getDamageRelative($colony, DamageModeEnum::HULL); |
|
53
|
|
|
if ($target->getIntegrity() > $damage) { |
|
54
|
|
|
$target->setIntegrity($target->getIntegrity() - $damage); |
|
55
|
|
|
$informations->addInformation("- Gebäudeschaden: " . $damage . " - Status: " . $target->getIntegrity()); |
|
56
|
|
|
|
|
57
|
|
|
return $informations; |
|
58
|
|
|
} |
|
59
|
|
|
$informations->addInformation("- Gebäudeschaden: " . $damage); |
|
60
|
|
|
$informations->addInformation("-- Das Gebäude wurde zerstört!"); |
|
61
|
|
|
$target->setIntegrity(0); |
|
62
|
|
|
|
|
63
|
|
|
return $informations; |
|
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