Passed
Push — master ( 0b1636...daadce )
by Paweł
02:53
created

Entity   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 68.97%

Importance

Changes 0
Metric Value
wmc 14
eloc 17
c 0
b 0
f 0
dl 0
loc 76
ccs 20
cts 29
cp 0.6897
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getInventory() 0 3 1
A getEtherum() 0 3 1
A getWeapon() 0 3 1
A getTalents() 0 3 1
A __construct() 0 11 1
A getHealth() 0 3 1
A isCorrupted() 0 3 1
A getName() 0 3 1
A getInitiative() 0 3 1
A getWeaponMasteryLevel() 0 12 3
A getStrength() 0 3 1
A __toString() 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\Initiative;
10
use AardsGerds\Game\Build\Attribute\Strength;
11
use AardsGerds\Game\Build\Talent\TalentCollection;
12
use AardsGerds\Game\Build\Talent\WeaponMastery\WeaponMasteryLevel;
13
use AardsGerds\Game\Fight\Fighter;
14
use AardsGerds\Game\Inventory\Inventory;
15
use AardsGerds\Game\Inventory\Weapon\Weapon;
16
17
abstract class Entity implements Fighter
18
{
19 1
    public function __construct(
20
        protected string $name,
21
        protected Health $health,
22
        protected Etherum $etherum,
23
        protected Strength $strength,
24
        protected Initiative $initiative,
25
        protected TalentCollection $talentCollection,
26
        protected Inventory $inventory,
27
        protected ?Weapon $weapon,
28
        protected bool $corrupted = false,
29 1
    ) {}
30
31 1
    public function getName(): string
32
    {
33 1
        return $this->name;
34
    }
35
36 1
    public function getHealth(): Health
37
    {
38 1
        return $this->health;
39
    }
40
41 1
    public function getEtherum(): Etherum
42
    {
43 1
        return $this->etherum;
44
    }
45
46 1
    public function getStrength(): Strength
47
    {
48 1
        return $this->strength;
49
    }
50
51 1
    public function getInitiative(): Initiative
52
    {
53 1
        return $this->initiative;
54
    }
55
56 1
    public function getTalents(): TalentCollection
57
    {
58 1
        return $this->talentCollection;
59
    }
60
61
    public function getWeaponMasteryLevel(): WeaponMasteryLevel
62
    {
63
        if ($this->weapon === null) {
64
            return WeaponMasteryLevel::inexperienced();
65
        }
66
67
        $weaponMastery = $this->talentCollection->findWeaponMasteryForWeaponType($this->weapon->getType());
68
        if ($weaponMastery === null) {
69
            return WeaponMasteryLevel::inexperienced();
70
        }
71
72
        return $weaponMastery->getLevel();
73
    }
74
75 1
    public function getInventory(): Inventory
76
    {
77 1
        return $this->inventory;
78
    }
79
80 1
    public function getWeapon(): ?Weapon
81
    {
82 1
        return $this->weapon;
83
    }
84
85 1
    public function isCorrupted(): bool
86
    {
87 1
        return $this->corrupted;
88
    }
89
90
    public function __toString(): string
91
    {
92
        return $this->name;
93
    }
94
}
95