Passed
Push — master ( b5c603...6073fe )
by Paweł
02:58
created

Entity   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
eloc 11
dl 0
loc 43
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getEtherum() 0 3 1
A getWeapon() 0 3 1
A __construct() 0 8 1
A getHealth() 0 3 1
A getWeaponMasteryLevel() 0 12 3
A getStrength() 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\Weapon\Weapon;
14
15
abstract class Entity implements Fighter
16
{
17
    public function __construct(
18
        protected string $name,
19
        protected Health $health,
20
        protected Etherum $etherum,
21
        protected Strength $strength,
22
        protected TalentCollection $talentCollection,
23
        protected ?Weapon $weapon,
24
    ) {}
25
26
    public function getHealth(): Health
27
    {
28
        return $this->health;
29
    }
30
31
    public function getEtherum(): Etherum
32
    {
33
        return $this->etherum;
34
    }
35
36
    public function getStrength(): Strength
37
    {
38
        return $this->strength;
39
    }
40
41
    public function getWeaponMasteryLevel(): WeaponMasteryLevel
42
    {
43
        if ($this->weapon === null) {
44
            return WeaponMasteryLevel::inexperienced();
45
        }
46
47
        $weaponMastery = $this->talentCollection->findWeaponMasteryForWeaponType($this->weapon->getType());
48
        if ($weaponMastery === null) {
49
            return WeaponMasteryLevel::inexperienced();
50
        }
51
52
        return $weaponMastery->getLevel();
53
    }
54
55
    public function getWeapon(): ?Weapon
56
    {
57
        return $this->weapon;
58
    }
59
}
60