|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace HeroesofAbenez\Combat; |
|
5
|
|
|
|
|
6
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* SkillAttackDummy |
|
10
|
|
|
* |
|
11
|
|
|
* @author Jakub Konečný |
|
12
|
|
|
* @property-read string $baseDamage |
|
13
|
|
|
* @property-read string $damageGrowth |
|
14
|
|
|
* @property-read int $strikes |
|
15
|
|
|
* @property-read string|NULL $hitRate |
|
16
|
|
|
*/ |
|
17
|
1 |
|
class SkillAttack extends BaseSkill { |
|
18
|
|
|
public const TARGET_SINGLE = "single"; |
|
19
|
|
|
public const TARGET_ROW = "row"; |
|
20
|
|
|
public const TARGET_COLUMN = "column"; |
|
21
|
|
|
|
|
22
|
|
|
/** @var string */ |
|
23
|
|
|
protected $baseDamage; |
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
protected $damageGrowth; |
|
26
|
|
|
/** @var int */ |
|
27
|
|
|
protected $strikes; |
|
28
|
|
|
/** @var string|NULL */ |
|
29
|
|
|
protected $hitRate; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(array $data) { |
|
32
|
1 |
|
$resolver = new OptionsResolver(); |
|
33
|
1 |
|
$this->configureOptions($resolver); |
|
34
|
1 |
|
$data = $resolver->resolve($data); |
|
35
|
1 |
|
$this->id = $data["id"]; |
|
36
|
1 |
|
$this->name = $data["name"]; |
|
37
|
1 |
|
$this->description = $data["description"]; |
|
38
|
1 |
|
$this->neededClass = $data["neededClass"]; |
|
39
|
1 |
|
$this->neededSpecialization = $data["neededSpecialization"]; |
|
40
|
1 |
|
$this->neededLevel = $data["neededLevel"]; |
|
41
|
1 |
|
$this->baseDamage = $data["baseDamage"]; |
|
42
|
1 |
|
$this->damageGrowth = $data["damageGrowth"]; |
|
43
|
1 |
|
$this->levels = $data["levels"]; |
|
44
|
1 |
|
$this->target = $data["target"]; |
|
45
|
1 |
|
$this->strikes = $data["strikes"]; |
|
46
|
1 |
|
$this->hitRate = $data["hitRate"]; |
|
47
|
1 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function configureOptions(OptionsResolver $resolver): void { |
|
50
|
1 |
|
parent::configureOptions($resolver); |
|
51
|
1 |
|
$allStats = ["baseDamage", "damageGrowth", "strikes", "hitRate",]; |
|
52
|
1 |
|
$resolver->setRequired($allStats); |
|
53
|
1 |
|
$resolver->setAllowedTypes("baseDamage", "string"); |
|
54
|
1 |
|
$resolver->setAllowedTypes("damageGrowth", "string"); |
|
55
|
1 |
|
$resolver->setAllowedTypes("strikes", "integer"); |
|
56
|
1 |
|
$resolver->setAllowedValues("strikes", function(int $value) { |
|
57
|
1 |
|
return ($value > 0); |
|
58
|
1 |
|
}); |
|
59
|
1 |
|
$resolver->setAllowedTypes("hitRate", ["string", "null"]); |
|
60
|
1 |
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getCooldown(): int { |
|
63
|
1 |
|
return 3; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getBaseDamage(): string { |
|
67
|
1 |
|
return $this->baseDamage; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getDamageGrowth(): string { |
|
71
|
1 |
|
return $this->damageGrowth; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getStrikes(): int { |
|
75
|
1 |
|
return $this->strikes; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getHitRate(): ?string { |
|
79
|
1 |
|
return $this->hitRate; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
?> |