|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace HeroesofAbenez\Combat; |
|
5
|
|
|
|
|
6
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
7
|
|
|
use 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->setAllowedTypes("id", "int"); |
|
46
|
1 |
|
$resolver->setAllowedTypes("name", "string"); |
|
47
|
1 |
|
$resolver->setAllowedTypes("target", "string"); |
|
48
|
1 |
|
$resolver->setAllowedValues("target", function(string $value) { |
|
49
|
1 |
|
return in_array($value, $this->getAllowedTargets(), true); |
|
50
|
1 |
|
}); |
|
51
|
1 |
|
$resolver->setAllowedTypes("levels", "integer"); |
|
52
|
1 |
|
$resolver->setAllowedValues("levels", function(int $value) { |
|
53
|
1 |
|
return ($value > 0); |
|
54
|
1 |
|
}); |
|
55
|
1 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
protected function getAllowedTargets(): array { |
|
58
|
1 |
|
return Constants::getConstantsValues(static::class, "TARGET_"); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
abstract public function getCooldown(): int; |
|
62
|
|
|
|
|
63
|
|
|
public function getId(): int { |
|
64
|
1 |
|
return $this->id; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getName(): string { |
|
68
|
1 |
|
return $this->name; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getTarget(): string { |
|
72
|
1 |
|
return $this->target; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function getLevels(): int { |
|
76
|
1 |
|
return $this->levels; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
?> |