Passed
Pull Request — master (#1969)
by Janko
22:34 queued 10:03
created

TholianWebWeaponPhase   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 32
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A damageCapturedShip() 0 30 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Spacecraft\Lib\Battle\Weapon;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Lib\Damage\DamageWrapper;
9
use Stu\Lib\Information\InformationInterface;
10
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestructionCauseEnum;
11
use Stu\Module\Ship\Lib\ShipWrapperInterface;
12
use Stu\Orm\Entity\ShipInterface;
13
14
//TODO unit tests
15
final class TholianWebWeaponPhase extends AbstractWeaponPhase implements TholianWebWeaponPhaseInterface
16
{
17
    #[Override]
18
    public function damageCapturedShip(
19
        ShipInterface $ship,
20
        ShipWrapperInterface $wrapper,
21
        InformationInterface $informations
22
    ): void {
23
24
        $ship = $wrapper->get();
25
26
        $informations->addInformation(sprintf(
27
            "Das Energienetz um die %s in Sektor %s ist implodiert",
28
            $ship->getName(),
29
            $ship->getSectorString()
30
        ));
31
32
        $damage_wrapper = new DamageWrapper(
33
            (int)ceil(random_int(65, 85) * $wrapper->get()->getMaxHull() / 100)
34
        );
35
        $damage_wrapper->setCrit(random_int(0, 3) === 0);
36
        $damage_wrapper->setShieldDamageFactor(100);
37
        $damage_wrapper->setHullDamageFactor(100);
38
        $damage_wrapper->setIsPhaserDamage(true);
39
40
        $this->applyDamage->damage($damage_wrapper, $wrapper, $informations);
41
42
        $this->checkForSpacecraftDestruction(
43
            $ship,
44
            $wrapper,
45
            SpacecraftDestructionCauseEnum::THOLIAN_WEB_IMPLOSION,
46
            $informations
47
        );
48
    }
49
}
50