Passed
Push — master ( cbe5a3...403d23 )
by Paweł
02:46
created

Entity   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 65
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0
wmc 12

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getEtherum() 0 3 1
A getTalents() 0 3 1
A __construct() 0 10 1
A getHealth() 0 3 1
A getName() 0 3 1
A getWeaponMasteryLevel() 0 12 3
A getStrength() 0 3 1
A getInventory() 0 3 1
A getWeapon() 0 3 1
A isCorrupted() 0 3 1
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
    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
    ) {}
28
29
    public function getName(): string
30
    {
31
        return $this->name;
32
    }
33
34
    public function getHealth(): Health
35
    {
36
        return $this->health;
37
    }
38
39
    public function getEtherum(): Etherum
40
    {
41
        return $this->etherum;
42
    }
43
44
    public function getStrength(): Strength
45
    {
46
        return $this->strength;
47
    }
48
49
    public function getTalents(): TalentCollection
50
    {
51
        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
    public function getInventory(): Inventory
69
    {
70
        return $this->inventory;
71
    }
72
73
    public function getWeapon(): ?Weapon
74
    {
75
        return $this->weapon;
76
    }
77
78
    public function isCorrupted(): bool
79
    {
80
        return $this->corrupted;
81
    }
82
}
83