1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Battle\Provider; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Lib\Transfer\Storage\StorageManagerInterface; |
9
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
10
|
|
|
use Stu\Orm\Entity\TorpedoTypeInterface; |
11
|
|
|
|
12
|
|
|
final class ProjectilePhalanx implements ProjectileAttackerInterface |
13
|
|
|
{ |
14
|
17 |
|
public function __construct( |
15
|
|
|
private ColonyInterface $colony, |
16
|
|
|
private StorageManagerInterface $storageManager |
17
|
17 |
|
) {} |
18
|
|
|
|
19
|
2 |
|
#[Override] |
20
|
|
|
public function hasSufficientEnergy(int $amount): bool |
21
|
|
|
{ |
22
|
2 |
|
return $this->getEps() >= $amount; |
23
|
|
|
} |
24
|
|
|
|
25
|
3 |
|
private function getEps(): int |
26
|
|
|
{ |
27
|
3 |
|
return $this->colony->getEps(); |
28
|
|
|
} |
29
|
|
|
|
30
|
1 |
|
#[Override] |
31
|
|
|
public function reduceEps(int $amount): void |
32
|
|
|
{ |
33
|
1 |
|
$this->colony->setEps($this->getEps() - $amount); |
34
|
|
|
} |
35
|
|
|
|
36
|
1 |
|
#[Override] |
37
|
|
|
public function getName(): string |
38
|
|
|
{ |
39
|
1 |
|
return 'Orbitale Torpedophalanx'; |
40
|
|
|
} |
41
|
|
|
|
42
|
2 |
|
#[Override] |
43
|
|
|
public function getTorpedoState(): bool |
44
|
|
|
{ |
45
|
2 |
|
return $this->getTorpedoCount() > 0; |
46
|
|
|
} |
47
|
|
|
|
48
|
1 |
|
#[Override] |
49
|
|
|
public function getHitChance(): int |
50
|
|
|
{ |
51
|
1 |
|
return 75; |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
#[Override] |
55
|
|
|
public function getUserId(): int |
56
|
|
|
{ |
57
|
1 |
|
return $this->colony->getUser()->getId(); |
58
|
|
|
} |
59
|
|
|
|
60
|
5 |
|
#[Override] |
61
|
|
|
public function getTorpedoCount(): int |
62
|
|
|
{ |
63
|
5 |
|
$torpedo = $this->getTorpedo(); |
64
|
|
|
|
65
|
5 |
|
if ($torpedo != null) { |
66
|
4 |
|
$stor = $this->colony->getStorage()->get($torpedo->getCommodityId()); |
67
|
|
|
|
68
|
4 |
|
if ($stor !== null) { |
69
|
3 |
|
return $stor->getAmount(); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
2 |
|
return 0; |
74
|
|
|
} |
75
|
|
|
|
76
|
2 |
|
#[Override] |
77
|
|
|
public function lowerTorpedoCount(int $amount): void |
78
|
|
|
{ |
79
|
2 |
|
$torpedo = $this->getTorpedo(); |
80
|
2 |
|
if ($torpedo === null) { |
81
|
1 |
|
return; |
82
|
|
|
} |
83
|
|
|
|
84
|
1 |
|
$this->storageManager->lowerStorage( |
85
|
1 |
|
$this->colony, |
86
|
1 |
|
$torpedo->getCommodity(), |
87
|
1 |
|
$amount |
88
|
1 |
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
#[Override] |
92
|
|
|
public function isShieldPenetration(): bool |
93
|
|
|
{ |
94
|
|
|
return false; |
95
|
|
|
} |
96
|
|
|
|
97
|
9 |
|
#[Override] |
98
|
|
|
public function getTorpedo(): ?TorpedoTypeInterface |
99
|
|
|
{ |
100
|
9 |
|
return $this->colony->getTorpedo(); |
101
|
|
|
} |
102
|
|
|
|
103
|
1 |
|
#[Override] |
104
|
|
|
public function getTorpedoVolleys(): int |
105
|
|
|
{ |
106
|
1 |
|
return 7; |
107
|
|
|
} |
108
|
|
|
|
109
|
2 |
|
#[Override] |
110
|
|
|
public function getProjectileWeaponDamage(bool $isCritical): int |
111
|
|
|
{ |
112
|
2 |
|
$torpedo = $this->getTorpedo(); |
113
|
2 |
|
if ($torpedo === null) { |
114
|
1 |
|
return 0; |
115
|
|
|
} |
116
|
|
|
|
117
|
1 |
|
$basedamage = $torpedo->getBaseDamage(); |
118
|
1 |
|
$variance = (int) round($basedamage / 100 * $torpedo->getVariance()); |
119
|
1 |
|
$damage = random_int($basedamage - $variance, $basedamage + $variance); |
120
|
|
|
|
121
|
1 |
|
return $isCritical ? $damage * 2 : $damage; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
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