|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Battle\Provider; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Lib\Map\FieldTypeEffectEnum; |
|
10
|
|
|
use Stu\Module\Control\StuRandom; |
|
11
|
|
|
use Stu\Orm\Entity\ModuleInterface; |
|
12
|
|
|
use Stu\Orm\Entity\WeaponInterface; |
|
13
|
|
|
|
|
14
|
|
|
abstract class AbstractEnergyAttacker implements EnergyAttackerInterface |
|
15
|
|
|
{ |
|
16
|
|
|
protected ?ModuleInterface $module = null; |
|
17
|
|
|
private ?WeaponInterface $weapon = null; |
|
18
|
|
|
|
|
19
|
24 |
|
public function __construct( |
|
20
|
|
|
protected StuRandom $stuRandom |
|
21
|
24 |
|
) {} |
|
22
|
|
|
|
|
23
|
|
|
#[Override] |
|
24
|
|
|
public function getFiringMode(): int |
|
25
|
|
|
{ |
|
26
|
|
|
$weapon = $this->getWeapon(); |
|
27
|
|
|
|
|
28
|
|
|
return $weapon->getFiringMode(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
abstract public function getWeaponModule(): ModuleInterface; |
|
32
|
|
|
|
|
33
|
|
|
#[Override] |
|
34
|
|
|
public function getWeapon(): WeaponInterface |
|
35
|
|
|
{ |
|
36
|
|
|
if ($this->weapon === null) { |
|
37
|
|
|
$weapon = $this->getWeaponModule()->getWeapon(); |
|
38
|
|
|
if ($weapon === null) { |
|
39
|
|
|
throw new RuntimeException('module system should have a weapon'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$this->weapon = $weapon; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
return $this->weapon; |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
abstract public function getEnergyWeaponBaseDamage(): int; |
|
49
|
|
|
|
|
50
|
|
|
#[Override] |
|
51
|
|
|
public function getWeaponDamage(bool $isCritical): int |
|
52
|
|
|
{ |
|
53
|
|
|
$basedamage = $this->getEnergyWeaponBaseDamage(); |
|
54
|
|
|
$variance = (int) round($basedamage / 100 * $this->getWeapon()->getVariance()); |
|
55
|
|
|
$damage = random_int($basedamage - $variance, $basedamage + $variance); |
|
56
|
|
|
|
|
57
|
|
|
if ($this->getLocation()->getFieldType()->hasEffect(FieldTypeEffectEnum::ENERGY_WEAPON_BUFF)) { |
|
58
|
|
|
$damage = (int)ceil($damage / 100 * $this->stuRandom->rand(115, 170, true, 125)); |
|
59
|
|
|
} |
|
60
|
|
|
if ($this->getLocation()->getFieldType()->hasEffect(FieldTypeEffectEnum::ENERGY_WEAPON_NERF)) { |
|
61
|
|
|
$damage = (int)ceil($damage / 100 * $this->stuRandom->rand(30, 85, true, 75)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $isCritical ? $damage * 2 : $damage; |
|
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