@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | public function shouldUse(CombatBase $combat, Character $character): bool |
29 | 29 | { |
30 | 30 | $attackTarget = $combat->selectAttackTarget($character); |
31 | - if ($attackTarget === null) { |
|
31 | + if($attackTarget === null) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | - if (count($character->usableSkills) < 1) { |
|
34 | + if(count($character->usableSkills) < 1) { |
|
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | return ($character->usableSkills[0] instanceof CharacterSpecialSkill); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | Skill::TARGET_ENEMY_PARTY => $combat->getEnemyTeam($character)->toArray(), |
75 | 75 | default => throw new NotImplementedException("Target {$skill->skill->target} for special skills is not implemented."), |
76 | 76 | }; |
77 | - foreach ($targets as $target) { |
|
77 | + foreach($targets as $target) { |
|
78 | 78 | $this->doSingleTarget($character, $target, $skill, $combat); |
79 | 79 | } |
80 | 80 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $result["result"] = $combat->successCalculator->hasHealed($character); |
37 | 37 | $amount = ($result["result"]) ? (int) ($character->intelligence / 2) : 0; |
38 | 38 | $result["amount"] = Numbers::range($amount, 0, $patient->maxHitpoints - $patient->hitpoints); |
39 | - if ($result["amount"] > 0) { |
|
39 | + if($result["amount"] > 0) { |
|
40 | 40 | $patient->heal($result["amount"]); |
41 | 41 | } |
42 | 42 | $result["action"] = $this->getName(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | private function findHealers(CombatBase $combat): Team |
50 | 50 | { |
51 | 51 | $healers = call_user_func($combat->healers, $combat->team1, $combat->team2); |
52 | - if ($healers instanceof Team) { |
|
52 | + if($healers instanceof Team) { |
|
53 | 53 | return $healers; |
54 | 54 | } |
55 | 55 | return new Team("healers"); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | */ |
28 | 28 | public function setTeams(Team $team1, Team $team2): void |
29 | 29 | { |
30 | - if (isset($this->team1)) { |
|
30 | + if(isset($this->team1)) { |
|
31 | 31 | throw new ImmutableException("Teams has already been set."); |
32 | 32 | } |
33 | 33 | $this->team1 = $team1; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | { |
53 | 53 | parent::configureOptions($resolver); |
54 | 54 | $resolver->setAllowedTypes("type", "string"); |
55 | - $resolver->setAllowedValues("type", function (string $value): bool { |
|
55 | + $resolver->setAllowedValues("type", function(string $value): bool { |
|
56 | 56 | return in_array($value, $this->getAllowedTypes(), true); |
57 | 57 | }); |
58 | 58 | } |
@@ -37,8 +37,8 @@ |
||
37 | 37 | |
38 | 38 | private function configureOptions(OptionsResolver $resolver): void |
39 | 39 | { |
40 | - $requiredStats = ["action", "result", "character1", "character2",]; |
|
41 | - $resolver->setDefined(["amount", "name",]); |
|
40 | + $requiredStats = ["action", "result", "character1", "character2", ]; |
|
41 | + $resolver->setDefined(["amount", "name", ]); |
|
42 | 42 | $resolver->setRequired($requiredStats); |
43 | 43 | $resolver->setAllowedTypes("action", "string"); |
44 | 44 | $resolver->setAllowedTypes("result", "bool"); |
@@ -17,12 +17,12 @@ |
||
17 | 17 | |
18 | 18 | public function hasHit(Character $character1, Character $character2, ?CharacterAttackSkill $skill = null): bool |
19 | 19 | { |
20 | - if (!$character2->canDefend()) { |
|
20 | + if(!$character2->canDefend()) { |
|
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | $hitRate = $character1->hit; |
24 | 24 | $dodgeRate = $character2->dodge; |
25 | - if ($skill !== null) { |
|
25 | + if($skill !== null) { |
|
26 | 26 | $hitRate = $hitRate / 100 * $skill->hitRate; |
27 | 27 | } |
28 | 28 | $hitChance = Numbers::range((int) ($hitRate - $dodgeRate), self::MIN_HIT_CHANCE, self::MAX_HIT_CHANCE); |
@@ -27,15 +27,15 @@ |
||
27 | 27 | |
28 | 28 | protected function configureOptions(OptionsResolver $resolver): void |
29 | 29 | { |
30 | - $resolver->setRequired(["id", "name", "target", "levels",]); |
|
30 | + $resolver->setRequired(["id", "name", "target", "levels", ]); |
|
31 | 31 | $resolver->setAllowedTypes("id", "int"); |
32 | 32 | $resolver->setAllowedTypes("name", "string"); |
33 | 33 | $resolver->setAllowedTypes("target", "string"); |
34 | - $resolver->setAllowedValues("target", function (string $value): bool { |
|
34 | + $resolver->setAllowedValues("target", function(string $value): bool { |
|
35 | 35 | return in_array($value, $this->getAllowedTargets(), true); |
36 | 36 | }); |
37 | 37 | $resolver->setAllowedTypes("levels", "integer"); |
38 | - $resolver->setAllowedValues("levels", function (int $value): bool { |
|
38 | + $resolver->setAllowedValues("levels", function(int $value): bool { |
|
39 | 39 | return ($value > 0); |
40 | 40 | }); |
41 | 41 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | protected function getDamage(): int |
35 | 35 | { |
36 | 36 | $damage = 0; |
37 | - if (str_ends_with($this->skill->baseDamage, "%")) { |
|
37 | + if(str_ends_with($this->skill->baseDamage, "%")) { |
|
38 | 38 | $damage += (int) $this->skill->baseDamage; |
39 | 39 | } |
40 | - if (str_ends_with($this->skill->damageGrowth, "%")) { |
|
40 | + if(str_ends_with($this->skill->damageGrowth, "%")) { |
|
41 | 41 | $damage += (int) $this->skill->damageGrowth * ($this->level - 1); |
42 | 42 | } |
43 | 43 | return $damage; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | protected function getHitRate(): int |
47 | 47 | { |
48 | - if (is_string($this->skill->hitRate) && str_ends_with($this->skill->hitRate, "%")) { |
|
48 | + if(is_string($this->skill->hitRate) && str_ends_with($this->skill->hitRate, "%")) { |
|
49 | 49 | return (int) $this->skill->hitRate; |
50 | 50 | } |
51 | 51 | return 100; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public readonly string $stat; |
27 | 27 | public readonly int $value; |
28 | 28 | public readonly bool $valueAbsolute; |
29 | - protected int|string $duration; |
|
29 | + protected int | string $duration; |
|
30 | 30 | /** @var callable[] */ |
31 | 31 | public array $onApply = []; |
32 | 32 | /** @var callable[] */ |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $resolver = new OptionsResolver(); |
38 | 38 | $this->configureOptions($resolver); |
39 | 39 | $effect = $resolver->resolve($effect); |
40 | - if (!in_array($effect["type"], SkillSpecial::NO_STAT_TYPES, true) && $effect["stat"] === "") { |
|
40 | + if(!in_array($effect["type"], SkillSpecial::NO_STAT_TYPES, true) && $effect["stat"] === "") { |
|
41 | 41 | throw new \InvalidArgumentException("The option stat with value '' is invalid."); |
42 | 42 | } |
43 | 43 | $this->id = $effect["id"]; |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | |
52 | 52 | protected function registerDefaultHandlers(): void |
53 | 53 | { |
54 | - $this->onApply[] = function (Character $character, self $effect): void { |
|
54 | + $this->onApply[] = function(Character $character, self $effect): void { |
|
55 | 55 | $character->recalculateStats(); |
56 | - if ($effect->stat === Character::STAT_MAX_HITPOINTS) { |
|
56 | + if($effect->stat === Character::STAT_MAX_HITPOINTS) { |
|
57 | 57 | $character->heal($effect->value); |
58 | 58 | } |
59 | 59 | }; |
60 | - $this->onRemove[] = function (Character $character, self $effect): void { |
|
60 | + $this->onRemove[] = function(Character $character, self $effect): void { |
|
61 | 61 | $character->recalculateStats(); |
62 | - if ($effect->stat === Character::STAT_MAX_HITPOINTS) { |
|
62 | + if($effect->stat === Character::STAT_MAX_HITPOINTS) { |
|
63 | 63 | $character->harm($effect->value); |
64 | 64 | } |
65 | 65 | }; |
@@ -67,23 +67,23 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function configureOptions(OptionsResolver $resolver): void |
69 | 69 | { |
70 | - $allStats = ["id", "type", "value", "valueAbsolute", "duration", "stat",]; |
|
70 | + $allStats = ["id", "type", "value", "valueAbsolute", "duration", "stat", ]; |
|
71 | 71 | $resolver->setRequired($allStats); |
72 | 72 | $resolver->setAllowedTypes("id", "string"); |
73 | 73 | $resolver->setAllowedTypes("type", "string"); |
74 | - $resolver->setAllowedValues("type", function (string $value): bool { |
|
74 | + $resolver->setAllowedValues("type", function(string $value): bool { |
|
75 | 75 | return in_array($value, $this->getAllowedTypes(), true); |
76 | 76 | }); |
77 | 77 | $resolver->setAllowedTypes("stat", "string"); |
78 | 78 | $resolver->setDefault("stat", ""); |
79 | - $resolver->setAllowedValues("stat", function (string $value): bool { |
|
79 | + $resolver->setAllowedValues("stat", function(string $value): bool { |
|
80 | 80 | return $value === "" || in_array($value, $this->getAllowedStats(), true); |
81 | 81 | }); |
82 | 82 | $resolver->setAllowedTypes("value", "integer"); |
83 | 83 | $resolver->setAllowedTypes("valueAbsolute", "bool"); |
84 | 84 | $resolver->setDefault("value", 0); |
85 | 85 | $resolver->setAllowedTypes("duration", ["string", "integer"]); |
86 | - $resolver->setAllowedValues("duration", function ($value): bool { |
|
86 | + $resolver->setAllowedValues("duration", function($value): bool { |
|
87 | 87 | return (in_array($value, $this->getDurations(), true)) || ($value > 0); |
88 | 88 | }); |
89 | 89 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | return Constants::getConstantsValues(static::class, "DURATION_"); |
110 | 110 | } |
111 | 111 | |
112 | - protected function getDuration(): int|string |
|
112 | + protected function getDuration(): int | string |
|
113 | 113 | { |
114 | 114 | return $this->duration; |
115 | 115 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | /** |
118 | 118 | * @throws \InvalidArgumentException |
119 | 119 | */ |
120 | - protected function setDuration(string|int $value): void |
|
120 | + protected function setDuration(string | int $value): void |
|
121 | 121 | { |
122 | - if (!is_int($value) && !in_array($value, $this->getDurations(), true)) { |
|
122 | + if(!is_int($value) && !in_array($value, $this->getDurations(), true)) { |
|
123 | 123 | throw new \InvalidArgumentException( |
124 | 124 | "Invalid value set to CharacterEffect::\$duration. Expected string or integer." |
125 | 125 | ); |