@@ -54,9 +54,11 @@ |
||
54 | 54 | /** |
55 | 55 | * @throws NotImplementedException |
56 | 56 | */ |
57 | - public function do(CombatBase $combat, Character $character): void { |
|
57 | + public function do { |
|
58 | + (CombatBase $combat, Character $character): void { |
|
58 | 59 | /** @var CharacterAttackSkill $skill */ |
59 | 60 | $skill = $character->usableSkills[0]; |
61 | + } |
|
60 | 62 | $targets = []; |
61 | 63 | /** @var Character $primaryTarget */ |
62 | 64 | $primaryTarget = $combat->selectAttackTarget($character); |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $targets = $combat->getTeam($primaryTarget)->getItems(["positionColumn" => $primaryTarget->positionColumn]); |
72 | 72 | break; |
73 | 73 | default: |
74 | - throw new NotImplementedException("Target {$skill->skill->target} for attack skills is not implemented."); |
|
74 | + throw new NotImplementedException("target {$skill->skill->target} for attack skills is not implemented."); |
|
75 | 75 | } |
76 | 76 | foreach($targets as $target) { |
77 | 77 | for($i = 1; $i <= $skill->skill->strikes; $i++) { |
@@ -10,6 +10,8 @@ |
||
10 | 10 | public function getName(): string; |
11 | 11 | public function getPriority(): int; |
12 | 12 | public function shouldUse(CombatBase $combat, Character $character): bool; |
13 | - public function do(CombatBase $combat, Character $character): void; |
|
14 | -} |
|
13 | + public function do { |
|
14 | + (CombatBase $combat, Character $character): void; |
|
15 | + } |
|
16 | + } |
|
15 | 17 | ?> |
16 | 18 | \ No newline at end of file |
@@ -26,8 +26,10 @@ |
||
26 | 26 | * Hit chance = Attacker's hit - Defender's dodge, but at least 15% |
27 | 27 | * Damage = Attacker's damage - defender's defense |
28 | 28 | */ |
29 | - public function do(CombatBase $combat, Character $character): void { |
|
29 | + public function do { |
|
30 | + (CombatBase $combat, Character $character): void { |
|
30 | 31 | $result = []; |
32 | + } |
|
31 | 33 | /** @var Character $defender */ |
32 | 34 | $defender = $combat->selectAttackTarget($character); |
33 | 35 | $result["result"] = $combat->successCalculator->hasHit($character, $defender); |
@@ -70,7 +70,7 @@ |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function configureOptions(OptionsResolver $resolver): void { |
73 | - $allStats = ["id", "type", "value", "valueAbsolute", "duration", "stat",]; |
|
73 | + $allStats = ["id", "type", "value", "valueAbsolute", "duration", "stat", ]; |
|
74 | 74 | $resolver->setRequired($allStats); |
75 | 75 | $resolver->setAllowedTypes("id", "string"); |
76 | 76 | $resolver->setAllowedTypes("type", "string"); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $resolver = new OptionsResolver(); |
47 | 47 | $this->configureOptions($resolver); |
48 | 48 | $effect = $resolver->resolve($effect); |
49 | - if(!in_array($effect["type"], SkillSpecial::NO_STAT_TYPES, true) AND $effect["stat"] === "") { |
|
49 | + if(!in_array($effect["type"], SkillSpecial::NO_STAT_TYPES, true) and $effect["stat"] === "") { |
|
50 | 50 | throw new \InvalidArgumentException("The option stat with value '' is invalid."); |
51 | 51 | } |
52 | 52 | $this->id = $effect["id"]; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | $resolver->setAllowedTypes("stat", "string"); |
81 | 81 | $resolver->setDefault("stat", ""); |
82 | 82 | $resolver->setAllowedValues("stat", function(string $value) { |
83 | - return $value === "" OR in_array($value, $this->getAllowedStats(), true); |
|
83 | + return $value === "" or in_array($value, $this->getAllowedStats(), true); |
|
84 | 84 | }); |
85 | 85 | $resolver->setAllowedTypes("value", "integer"); |
86 | 86 | $resolver->setAllowedTypes("valueAbsolute", "bool"); |
87 | 87 | $resolver->setDefault("value", 0); |
88 | 88 | $resolver->setAllowedTypes("duration", ["string", "integer"]); |
89 | 89 | $resolver->setAllowedValues("duration", function($value) { |
90 | - return (in_array($value, $this->getDurations(), true)) OR ($value > 0); |
|
90 | + return (in_array($value, $this->getDurations(), true)) or ($value > 0); |
|
91 | 91 | }); |
92 | 92 | } |
93 | 93 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @throws \InvalidArgumentException |
149 | 149 | */ |
150 | 150 | public function setDuration($value): void { |
151 | - if(!is_int($value) AND !in_array($value, $this->getDurations(), true)) { |
|
151 | + if(!is_int($value) and !in_array($value, $this->getDurations(), true)) { |
|
152 | 152 | throw new \InvalidArgumentException("Invalid value set to CharacterEffect::\$duration. Expected string or integer."); |
153 | 153 | } |
154 | 154 | $this->duration = $value; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function setTemplate(string $template): void { |
33 | 33 | if(!is_file($template)) { |
34 | - throw new \RuntimeException("File $template does not exist."); |
|
34 | + throw new \RuntimeException("file $template does not exist."); |
|
35 | 35 | } |
36 | 36 | $this->template = $template; |
37 | 37 | } |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | case CombatLogEntry::ACTION_ATTACK: |
55 | 55 | $message = ($item->result) ? "combat.log.attackHits" : "combat.log.attackFails"; |
56 | 56 | $text = $this->translator->translate($message, $item->amount, ["character1" => $character1, "character2" => $character2]); |
57 | - if($item->result AND $item->character2->hitpoints < 1) { |
|
57 | + if($item->result and $item->character2->hitpoints < 1) { |
|
58 | 58 | $text .= $this->translator->translate("combat.log.characterFalls"); |
59 | 59 | } |
60 | 60 | return $text; |
61 | 61 | case CombatLogEntry::ACTION_SKILL_ATTACK: |
62 | 62 | $message = ($item->result) ? "combat.log.specialAttackHits" : "combat.log.specialAttackFails"; |
63 | 63 | $text = $this->translator->translate($message, $item->amount, ["character1" => $character1, "character2" => $character2, "name" => $item->name]); |
64 | - if($item->result AND $item->character2->hitpoints < 1) { |
|
64 | + if($item->result and $item->character2->hitpoints < 1) { |
|
65 | 65 | $text .= $this->translator->translate("combat.log.characterFalls"); |
66 | 66 | } |
67 | 67 | return $text; |
@@ -51,8 +51,8 @@ |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | protected function configureOptions(OptionsResolver $resolver): void { |
54 | - $requiredStats = ["action", "result", "character1", "character2",]; |
|
55 | - $resolver->setDefined(["amount", "name",]); |
|
54 | + $requiredStats = ["action", "result", "character1", "character2", ]; |
|
55 | + $resolver->setDefined(["amount", "name", ]); |
|
56 | 56 | $resolver->setRequired($requiredStats); |
57 | 57 | $resolver->setAllowedTypes("action", "string"); |
58 | 58 | $resolver->setAllowedTypes("result", "bool"); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $this->onCombatEnd[] = [$this, "resetInitiative"]; |
75 | 75 | $this->onRoundStart[] = [$this, "applyEffectProviders"]; |
76 | 76 | $this->onRoundStart[] = [$this, "decreaseEffectsDuration"]; |
77 | - $this->onRoundStart[] = [$this ,"recalculateStats"]; |
|
77 | + $this->onRoundStart[] = [$this, "recalculateStats"]; |
|
78 | 78 | $this->onRoundStart[] = [$this, "logRoundNumber"]; |
79 | 79 | $this->onRoundStart[] = [$this, "applyPoison"]; |
80 | 80 | $this->onRound[] = [$this, "mainStage"]; |
@@ -343,14 +343,14 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function selectAttackTarget(Character $attacker): ?Character { |
345 | 345 | $enemyTeam = $this->getEnemyTeam($attacker); |
346 | - $rangedWeapon = ($attacker->equipment->hasItems(["%class%" => Weapon::class, "worn" => true, "ranged" => true,])); |
|
346 | + $rangedWeapon = ($attacker->equipment->hasItems(["%class%" => Weapon::class, "worn" => true, "ranged" => true, ])); |
|
347 | 347 | if(!$rangedWeapon) { |
348 | 348 | $rowToAttack = $enemyTeam->rowToAttack; |
349 | 349 | if(is_null($rowToAttack)) { |
350 | 350 | return null; |
351 | 351 | } |
352 | 352 | /** @var Team $enemies */ |
353 | - $enemies = Team::fromArray($enemyTeam->getItems(["positionRow" => $rowToAttack, "hitpoints>" => 0,]), $enemyTeam->name); |
|
353 | + $enemies = Team::fromArray($enemyTeam->getItems(["positionRow" => $rowToAttack, "hitpoints>" => 0, ]), $enemyTeam->name); |
|
354 | 354 | } else { |
355 | 355 | $enemies = $enemyTeam; |
356 | 356 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | foreach($team as $character) { |
229 | 229 | try { |
230 | 230 | $column++; |
231 | - if($character->positionRow > 0 AND $character->positionColumn > 0) { |
|
231 | + if($character->positionRow > 0 and $character->positionColumn > 0) { |
|
232 | 232 | continue; |
233 | 233 | } |
234 | 234 | setPosition: |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | continue 2; |
401 | 401 | } |
402 | 402 | } |
403 | - throw new NotImplementedException("Action $action is not implemented."); |
|
403 | + throw new NotImplementedException("action $action is not implemented."); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 |
@@ -201,10 +201,10 @@ |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | protected function setStats(array $stats): void { |
204 | - $requiredStats = array_merge(["id", "name", "level", "initiativeFormula",], static::BASE_STATS); |
|
205 | - $allStats = array_merge($requiredStats, ["occupation", "race", "specialization", "gender",]); |
|
204 | + $requiredStats = array_merge(["id", "name", "level", "initiativeFormula", ], static::BASE_STATS); |
|
205 | + $allStats = array_merge($requiredStats, ["occupation", "race", "specialization", "gender", ]); |
|
206 | 206 | $numberStats = static::BASE_STATS; |
207 | - $textStats = ["name", "race", "occupation", "specialization", "initiativeFormula",]; |
|
207 | + $textStats = ["name", "race", "occupation", "specialization", "initiativeFormula", ]; |
|
208 | 208 | $resolver = new OptionsResolver(); |
209 | 209 | $resolver->setDefined($allStats); |
210 | 210 | $resolver->setAllowedTypes("id", ["integer", "string"]); |