|
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
|
|
|
|