Passed
Push — master ( fa53c0...9478ec )
by Paweł
02:37
created

Entity::isCorrupted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Entity;
6
7
use AardsGerds\Game\Build\Attribute\Etherum;
8
use AardsGerds\Game\Build\Attribute\Health;
9
use AardsGerds\Game\Build\Attribute\Strength;
10
use AardsGerds\Game\Build\Talent\TalentCollection;
11
use AardsGerds\Game\Build\Talent\WeaponMastery\WeaponMasteryLevel;
12
use AardsGerds\Game\Fight\Fighter;
13
use AardsGerds\Game\Inventory\Inventory;
14
use AardsGerds\Game\Inventory\Weapon\Weapon;
15
16
abstract class Entity implements Fighter
17
{
18 1
    public function __construct(
19
        protected string $name,
20
        protected Health $health,
21
        protected Etherum $etherum,
22
        protected Strength $strength,
23
        protected TalentCollection $talentCollection,
24
        protected Inventory $inventory,
25
        protected ?Weapon $weapon,
26
        protected bool $corrupted = false,
27 1
    ) {}
28
29 1
    public function getName(): string
30
    {
31 1
        return $this->name;
32
    }
33
34 1
    public function getHealth(): Health
35
    {
36 1
        return $this->health;
37
    }
38
39 1
    public function getEtherum(): Etherum
40
    {
41 1
        return $this->etherum;
42
    }
43
44 1
    public function getStrength(): Strength
45
    {
46 1
        return $this->strength;
47
    }
48
49 1
    public function getTalents(): TalentCollection
50
    {
51 1
        return $this->talentCollection;
52
    }
53
54
    public function getWeaponMasteryLevel(): WeaponMasteryLevel
55
    {
56
        if ($this->weapon === null) {
57
            return WeaponMasteryLevel::inexperienced();
58
        }
59
60
        $weaponMastery = $this->talentCollection->findWeaponMasteryForWeaponType($this->weapon->getType());
61
        if ($weaponMastery === null) {
62
            return WeaponMasteryLevel::inexperienced();
63
        }
64
65
        return $weaponMastery->getLevel();
66
    }
67
68 1
    public function getInventory(): Inventory
69
    {
70 1
        return $this->inventory;
71
    }
72
73 1
    public function getWeapon(): ?Weapon
74
    {
75 1
        return $this->weapon;
76
    }
77
78 1
    public function isCorrupted(): bool
79
    {
80 1
        return $this->corrupted;
81
    }
82
}
83