@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | |
31 | 31 | private function configureOptions(OptionsResolver $resolver): void |
32 | 32 | { |
33 | - $allStats = ["id", "deployed", "bonusStat", "bonusValue",]; |
|
33 | + $allStats = ["id", "deployed", "bonusStat", "bonusValue", ]; |
|
34 | 34 | $resolver->setRequired($allStats); |
35 | 35 | $resolver->setAllowedTypes("id", "integer"); |
36 | 36 | $resolver->setAllowedTypes("deployed", "boolean"); |
37 | 37 | $resolver->setAllowedTypes("bonusStat", "string"); |
38 | - $resolver->setAllowedValues("bonusStat", function (string $value): bool { |
|
38 | + $resolver->setAllowedValues("bonusStat", function(string $value): bool { |
|
39 | 39 | return in_array($value, $this->getAllowedStats(), true); |
40 | 40 | }); |
41 | 41 | $resolver->setAllowedTypes("bonusValue", "integer"); |
42 | - $resolver->setAllowedValues("bonusValue", function (int $value): bool { |
|
42 | + $resolver->setAllowedValues("bonusValue", function(int $value): bool { |
|
43 | 43 | return ($value >= 0); |
44 | 44 | }); |
45 | 45 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function getCombatEffects(): array |
65 | 65 | { |
66 | - if (!$this->deployed) { |
|
66 | + if(!$this->deployed) { |
|
67 | 67 | return []; |
68 | 68 | } |
69 | 69 | return [new CharacterEffect($this->getDeployParams())]; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function getAliveMembers(): array |
48 | 48 | { |
49 | - return $this->getItems(["hitpoints>" => 0,]); |
|
49 | + return $this->getItems(["hitpoints>" => 0, ]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setCharacterPosition($id, int $row, int $column): void |
78 | 78 | { |
79 | - if (!$this->hasItems(["id" => $id])) { |
|
79 | + if(!$this->hasItems(["id" => $id])) { |
|
80 | 80 | throw new \OutOfBoundsException("Character $id is not in the team"); |
81 | - } elseif (count($this->getItems(["positionRow" => $row])) >= $this->maxRowSize) { |
|
81 | + } elseif(count($this->getItems(["positionRow" => $row])) >= $this->maxRowSize) { |
|
82 | 82 | throw new InvalidCharacterPositionException( |
83 | 83 | "Row $row is full.", |
84 | 84 | InvalidCharacterPositionException::ROW_FULL |
85 | 85 | ); |
86 | - } elseif ($this->hasItems(["positionRow" => $row, "positionColumn" => $column])) { |
|
86 | + } elseif($this->hasItems(["positionRow" => $row, "positionColumn" => $column])) { |
|
87 | 87 | throw new InvalidCharacterPositionException( |
88 | 88 | "Row $row column $column is occupied.", |
89 | 89 | InvalidCharacterPositionException::POSITION_OCCUPIED |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | public function getRandomCharacter(): ?Character |
98 | 98 | { |
99 | 99 | $characters = $this->aliveMembers; |
100 | - if (count($characters) === 0) { |
|
100 | + if(count($characters) === 0) { |
|
101 | 101 | return null; |
102 | - } elseif (count($characters) === 1) { |
|
102 | + } elseif(count($characters) === 1) { |
|
103 | 103 | return $characters[0]; |
104 | 104 | } |
105 | 105 | $roll = rand(0, count($characters) - 1); |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | { |
111 | 111 | $lowestHp = PHP_INT_MAX; |
112 | 112 | $lowestIndex = PHP_INT_MIN; |
113 | - if (count($this->aliveMembers) === 0) { |
|
113 | + if(count($this->aliveMembers) === 0) { |
|
114 | 114 | return null; |
115 | 115 | } |
116 | - foreach ($this->aliveMembers as $index => $member) { |
|
117 | - if ($member->hitpoints <= $member->maxHitpoints * $threshold && $member->hitpoints < $lowestHp) { |
|
116 | + foreach($this->aliveMembers as $index => $member) { |
|
117 | + if($member->hitpoints <= $member->maxHitpoints * $threshold && $member->hitpoints < $lowestHp) { |
|
118 | 118 | $lowestHp = $member->hitpoints; |
119 | 119 | $lowestIndex = $index; |
120 | 120 | } |
121 | 121 | } |
122 | - if ($lowestIndex === PHP_INT_MIN) { |
|
122 | + if($lowestIndex === PHP_INT_MIN) { |
|
123 | 123 | return null; |
124 | 124 | } |
125 | 125 | return $this->aliveMembers[$lowestIndex]; |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | |
128 | 128 | protected function getRowToAttack(): ?int |
129 | 129 | { |
130 | - for ($i = 1; $i <= $this->maxRowSize; $i++) { |
|
131 | - if ($this->hasItems(["positionRow" => $i, "hitpoints>" => 0,])) { |
|
130 | + for($i = 1; $i <= $this->maxRowSize; $i++) { |
|
131 | + if($this->hasItems(["positionRow" => $i, "hitpoints>" => 0, ])) { |
|
132 | 132 | return $i; |
133 | 133 | } |
134 | 134 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | protected function setTemplate(string $template): void |
30 | 30 | { |
31 | - if (!is_file($template)) { |
|
31 | + if(!is_file($template)) { |
|
32 | 32 | throw new \RuntimeException("File $template does not exist."); |
33 | 33 | } |
34 | 34 | $this->template = $template; |
@@ -40,22 +40,22 @@ discard block |
||
40 | 40 | return $this->latte->renderToString($this->template, $params); |
41 | 41 | } |
42 | 42 | |
43 | - public function renderItem(CombatLogEntry|string $item): string |
|
43 | + public function renderItem(CombatLogEntry | string $item): string |
|
44 | 44 | { |
45 | - if (!$item instanceof CombatLogEntry) { |
|
45 | + if(!$item instanceof CombatLogEntry) { |
|
46 | 46 | return $item; |
47 | 47 | } |
48 | 48 | $character1 = $item->character1->name; |
49 | 49 | $character2 = $item->character2->name; |
50 | - switch ($item->action) { |
|
50 | + switch($item->action) { |
|
51 | 51 | case CombatActions\Attack::ACTION_NAME: |
52 | 52 | $message = ($item->result) ? "combat.log.attackHits" : "combat.log.attackFails"; |
53 | 53 | $text = $this->translator->translate( |
54 | 54 | $message, |
55 | 55 | $item->amount, |
56 | - ["character1" => $character1, "character2" => $character2,] |
|
56 | + ["character1" => $character1, "character2" => $character2, ] |
|
57 | 57 | ); |
58 | - if ($item->result && $item->character2->hitpoints < 1) { |
|
58 | + if($item->result && $item->character2->hitpoints < 1) { |
|
59 | 59 | $text .= $this->translator->translate("combat.log.characterFalls"); |
60 | 60 | } |
61 | 61 | return $text; |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | $text = $this->translator->translate( |
65 | 65 | $message, |
66 | 66 | $item->amount, |
67 | - ["character1" => $character1, "character2" => $character2, "name" => $item->name,] |
|
67 | + ["character1" => $character1, "character2" => $character2, "name" => $item->name, ] |
|
68 | 68 | ); |
69 | - if ($item->result && $item->character2->hitpoints < 1) { |
|
69 | + if($item->result && $item->character2->hitpoints < 1) { |
|
70 | 70 | $text .= $this->translator->translate("combat.log.characterFalls"); |
71 | 71 | } |
72 | 72 | return $text; |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | return $this->translator->translate( |
76 | 76 | $message, |
77 | 77 | 0, |
78 | - ["character1" => $character1, "character2" => $character2, "name" => $item->name,] |
|
78 | + ["character1" => $character1, "character2" => $character2, "name" => $item->name, ] |
|
79 | 79 | ); |
80 | 80 | case CombatActions\Heal::ACTION_NAME: |
81 | 81 | $message = ($item->result) ? "combat.log.healingSuccess" : "combat.log.healingFailure"; |
82 | 82 | return $this->translator->translate( |
83 | 83 | $message, |
84 | 84 | $item->amount, |
85 | - ["character1" => $character1, "character2" => $character2,] |
|
85 | + ["character1" => $character1, "character2" => $character2, ] |
|
86 | 86 | ); |
87 | 87 | case CombatLogEntry::ACTION_POISON: |
88 | 88 | return $this->translator->translate("combat.log.poison", $item->amount, ["character1" => $character1]); |
@@ -12,16 +12,16 @@ |
||
12 | 12 | { |
13 | 13 | public function chooseAction(CombatBase $combat, Character $character): ?ICombatAction |
14 | 14 | { |
15 | - if (!$character->canAct()) { |
|
15 | + if(!$character->canAct()) { |
|
16 | 16 | return null; |
17 | 17 | } |
18 | 18 | /** @var ICombatAction[] $actions */ |
19 | 19 | $actions = $combat->combatActions->toArray(); |
20 | - usort($actions, function (ICombatAction $a, ICombatAction $b): int { |
|
20 | + usort($actions, function(ICombatAction $a, ICombatAction $b): int { |
|
21 | 21 | return $a->getPriority() <=> $b->getPriority(); |
22 | 22 | }); |
23 | - foreach ($actions as $action) { |
|
24 | - if ($action->shouldUse($combat, $character)) { |
|
23 | + foreach($actions as $action) { |
|
24 | + if($action->shouldUse($combat, $character)) { |
|
25 | 25 | return $action; |
26 | 26 | } |
27 | 27 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | try { |
42 | 42 | /** @var CharacterEffect $item */ |
43 | 43 | $item = Arrays::get($this->items, $index); |
44 | - } catch (\Nette\InvalidArgumentException) { |
|
44 | + } catch(\Nette\InvalidArgumentException) { |
|
45 | 45 | throw new \OutOfRangeException("Offset invalid or out of range."); |
46 | 46 | } |
47 | 47 | parent::offsetUnset($index); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | public function decreaseCooldown(): void |
59 | 59 | { |
60 | - if ($this->cooldown > 0) { |
|
60 | + if($this->cooldown > 0) { |
|
61 | 61 | $this->cooldown--; |
62 | 62 | } |
63 | 63 | } |