|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace HeroesofAbenez\Combat; |
|
5
|
|
|
|
|
6
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver, |
|
7
|
|
|
Nexendrie\Utils\Constants; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Base Skill |
|
11
|
|
|
* |
|
12
|
|
|
* @author Jakub Konečný |
|
13
|
|
|
* @property-read int $id |
|
14
|
|
|
* @property-read string $name |
|
15
|
|
|
* @property-read string $description |
|
16
|
|
|
* @property-read int $neededClass |
|
17
|
|
|
* @property-read int|NULL $neededSpecialization |
|
18
|
|
|
* @property-read int $neededLevel |
|
19
|
|
|
* @property-read string $target |
|
20
|
|
|
* @property-read int $levels |
|
21
|
|
|
* @property-read int $cooldown |
|
22
|
|
|
*/ |
|
23
|
1 |
|
abstract class BaseSkill { |
|
24
|
1 |
|
use \Nette\SmartObject; |
|
25
|
|
|
|
|
26
|
|
|
/** @var int */ |
|
27
|
|
|
protected $id; |
|
28
|
|
|
/** @var string */ |
|
29
|
|
|
protected $name; |
|
30
|
|
|
/** @var string */ |
|
31
|
|
|
protected $description; |
|
32
|
|
|
/** @var int */ |
|
33
|
|
|
protected $neededClass; |
|
34
|
|
|
/** @var int|NULL */ |
|
35
|
|
|
protected $neededSpecialization; |
|
36
|
|
|
/** @var int */ |
|
37
|
|
|
protected $neededLevel; |
|
38
|
|
|
/** @var string */ |
|
39
|
|
|
protected $target; |
|
40
|
|
|
/** @var int */ |
|
41
|
|
|
protected $levels; |
|
42
|
|
|
|
|
43
|
|
|
protected function configureOptions(OptionsResolver $resolver): void { |
|
44
|
1 |
|
$resolver->setRequired(["id", "name", "target", "levels",]); |
|
45
|
1 |
|
$resolver->setDefined(["description", "neededClass", "neededSpecialization", "neededLevel",]); |
|
46
|
1 |
|
$resolver->setAllowedTypes("id", "int"); |
|
47
|
1 |
|
$resolver->setAllowedTypes("name", "string"); |
|
48
|
1 |
|
$resolver->setAllowedTypes("description", "string"); |
|
49
|
1 |
|
$resolver->setDefault("description", ""); |
|
50
|
1 |
|
$resolver->setAllowedTypes("neededClass", "integer"); |
|
51
|
1 |
|
$resolver->setDefault("neededClass", 1); |
|
52
|
1 |
|
$resolver->setAllowedTypes("neededSpecialization", ["integer", "null"]); |
|
53
|
1 |
|
$resolver->setDefault("neededSpecialization", NULL); |
|
54
|
1 |
|
$resolver->setAllowedTypes("neededLevel", "integer"); |
|
55
|
1 |
|
$resolver->setDefault("neededLevel", 1); |
|
56
|
1 |
|
$resolver->setAllowedTypes("target", "string"); |
|
57
|
1 |
|
$resolver->setAllowedValues("target", function(string $value) { |
|
58
|
1 |
|
return in_array($value, $this->getAllowedTargets(), true); |
|
59
|
1 |
|
}); |
|
60
|
1 |
|
$resolver->setAllowedTypes("levels", "integer"); |
|
61
|
1 |
|
$resolver->setAllowedValues("levels", function(int $value) { |
|
62
|
1 |
|
return ($value > 0); |
|
63
|
1 |
|
}); |
|
64
|
1 |
|
} |
|
65
|
|
|
|
|
66
|
|
|
protected function getAllowedTargets(): array { |
|
67
|
1 |
|
return Constants::getConstantsValues(static::class, "TARGET_"); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
abstract public function getCooldown(): int; |
|
71
|
|
|
|
|
72
|
|
|
public function getId(): int { |
|
73
|
1 |
|
return $this->id; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getName(): string { |
|
77
|
1 |
|
return $this->name; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getDescription(): string { |
|
81
|
|
|
return $this->description; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function getNeededClass(): int { |
|
85
|
|
|
return $this->neededClass; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getNeededSpecialization(): ?int { |
|
89
|
|
|
return $this->neededSpecialization; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function getNeededLevel(): int { |
|
93
|
|
|
return $this->neededLevel; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getTarget(): string { |
|
97
|
1 |
|
return $this->target; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function getLevels(): int { |
|
101
|
1 |
|
return $this->levels; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
?> |