Passed
Push — master ( 7a48d2...d0f71f )
by Jakub
12:49
created
src/Equipment.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,27 +52,27 @@  discard block
 block discarded – undo
52 52
 
53 53
     protected function configureOptions(OptionsResolver $resolver): void
54 54
     {
55
-        $allStats = ["id", "name", "slot", "type", "strength", "worn",];
55
+        $allStats = ["id", "name", "slot", "type", "strength", "worn", ];
56 56
         $resolver->setRequired($allStats);
57 57
         $resolver->setAllowedTypes("id", "integer");
58 58
         $resolver->setAllowedTypes("name", "string");
59 59
         $resolver->setAllowedTypes("slot", "string");
60
-        $resolver->setAllowedValues("slot", function (string $value): bool {
60
+        $resolver->setAllowedValues("slot", function(string $value): bool {
61 61
             return in_array($value, $this->getAllowedSlots(), true);
62 62
         });
63 63
         $resolver->setAllowedTypes("type", "null");
64 64
         $resolver->setDefault("type", null);
65 65
         $resolver->setAllowedTypes("strength", "integer");
66
-        $resolver->setAllowedValues("strength", function (int $value): bool {
66
+        $resolver->setAllowedValues("strength", function(int $value): bool {
67 67
             return ($value >= 0);
68 68
         });
69 69
         $resolver->setAllowedTypes("worn", "boolean");
70 70
         $resolver->setDefault("maxDurability", 0);
71 71
         $resolver->setAllowedTypes("maxDurability", "integer");
72
-        $resolver->setAllowedValues("maxDurability", function (int $value): bool {
72
+        $resolver->setAllowedValues("maxDurability", function(int $value): bool {
73 73
             return ($value >= 0);
74 74
         });
75
-        $resolver->setDefault("durability", function (Options $options) {
75
+        $resolver->setDefault("durability", function(Options $options) {
76 76
             return $options["maxDurability"];
77 77
         });
78 78
         $resolver->setAllowedTypes("durability", "integer");
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 
86 86
     protected function getStrength(): int
87 87
     {
88
-        if ($this->durability >= $this->maxDurability * 0.7) {
88
+        if($this->durability >= $this->maxDurability * 0.7) {
89 89
             return $this->rawStrength;
90
-        } elseif ($this->durability >= $this->maxDurability / 2) {
90
+        } elseif($this->durability >= $this->maxDurability / 2) {
91 91
             return (int) ($this->rawStrength * 0.75);
92
-        } elseif ($this->durability >= $this->maxDurability / 4) {
92
+        } elseif($this->durability >= $this->maxDurability / 4) {
93 93
             return (int) ($this->rawStrength / 2);
94
-        } elseif ($this->durability >= $this->maxDurability / 10) {
94
+        } elseif($this->durability >= $this->maxDurability / 10) {
95 95
             return (int) ($this->rawStrength / 4);
96 96
         }
97 97
         return 0;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function getCombatEffects(): array
129 129
     {
130
-        if (!$this->worn) {
130
+        if(!$this->worn) {
131 131
             return [];
132 132
         }
133 133
         return [new CharacterEffect($this->getDeployParams())];
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@  discard block
 block discarded – undo
15 15
  * @property-read int $strength
16 16
  * @property int $durability
17 17
  */
18
-class Equipment implements ICharacterEffectsProvider
19
-{
18
+class Equipment implements ICharacterEffectsProvider {
20 19
     use \Nette\SmartObject;
21 20
 
22 21
     public const SLOT_WEAPON = "weapon";
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
     protected int $durability;
36 35
     public readonly int $maxDurability;
37 36
 
38
-    public function __construct(array $data)
39
-    {
37
+    public function __construct(array $data) {
40 38
         $resolver = new OptionsResolver();
41 39
         $this->configureOptions($resolver);
42 40
         $data = $resolver->resolve($data);
Please login to merge, or discard this patch.
src/VictoryConditions.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
     public static function moreDamage(CombatBase $combat): int
21 21
     {
22 22
         $result = 0;
23
-        if ($combat->round <= $combat->roundLimit) {
24
-            if (!$combat->team1->hasAliveMembers()) {
23
+        if($combat->round <= $combat->roundLimit) {
24
+            if(!$combat->team1->hasAliveMembers()) {
25 25
                 $result = 2;
26
-            } elseif (!$combat->team2->hasAliveMembers()) {
26
+            } elseif(!$combat->team2->hasAliveMembers()) {
27 27
                 $result = 1;
28 28
             }
29
-        } elseif ($combat->round > $combat->roundLimit) {
29
+        } elseif($combat->round > $combat->roundLimit) {
30 30
             $result = ($combat->team1Damage > $combat->team2Damage) ? 1 : 2;
31 31
         }
32 32
         return $result;
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
     public static function eliminateSecondTeam(CombatBase $combat): int
40 40
     {
41 41
         $result = 0;
42
-        if ($combat->round <= $combat->roundLimit) {
43
-            if (!$combat->team1->hasAliveMembers()) {
42
+        if($combat->round <= $combat->roundLimit) {
43
+            if(!$combat->team1->hasAliveMembers()) {
44 44
                 $result = 2;
45
-            } elseif (!$combat->team2->hasAliveMembers()) {
45
+            } elseif(!$combat->team2->hasAliveMembers()) {
46 46
                 $result = 1;
47 47
             }
48
-        } elseif ($combat->round > $combat->roundLimit) {
48
+        } elseif($combat->round > $combat->roundLimit) {
49 49
             $result = (!$combat->team2->hasAliveMembers()) ? 1 : 2;
50 50
         }
51 51
         return $result;
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     public static function firstTeamSurvives(CombatBase $combat): int
59 59
     {
60 60
         $result = 0;
61
-        if ($combat->round <= $combat->roundLimit) {
62
-            if (!$combat->team1->hasAliveMembers()) {
61
+        if($combat->round <= $combat->roundLimit) {
62
+            if(!$combat->team1->hasAliveMembers()) {
63 63
                 $result = 2;
64
-            } elseif (!$combat->team2->hasAliveMembers()) {
64
+            } elseif(!$combat->team2->hasAliveMembers()) {
65 65
                 $result = 1;
66 66
             }
67
-        } elseif ($combat->round > $combat->roundLimit) {
67
+        } elseif($combat->round > $combat->roundLimit) {
68 68
             $result = ($combat->team1->hasAliveMembers()) ? 1 : 2;
69 69
         }
70 70
         return $result;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
  *
9 9
  * @author Jakub Konečný
10 10
  */
11
-final class VictoryConditions
12
-{
11
+final class VictoryConditions {
13 12
     use \Nette\StaticClass;
14 13
 
15 14
     /**
Please login to merge, or discard this patch.
src/InitiativeFormulaParser.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         ];
22 22
         $formula = str_replace(array_keys($stats), array_values($stats), $formula);
23 23
         preg_match("/^([1-9]+)d([1-9]+)/", $formula, $dices);
24
-        for ($i = 1; $i <= (int) $dices[1]; $i++) {
24
+        for($i = 1; $i <= (int) $dices[1]; $i++) {
25 25
             $result += rand(1, (int) $dices[2]);
26 26
         }
27 27
         preg_match("/\+([0-9]+)\/([0-9]+)/", $formula, $ammendum);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
  *
9 9
  * @author Jakub Konečný
10 10
  */
11
-final class InitiativeFormulaParser implements IInitiativeFormulaParser
12
-{
11
+final class InitiativeFormulaParser implements IInitiativeFormulaParser {
13 12
     public function calculateInitiative(Character $character): int
14 13
     {
15 14
         $result = 0;
Please login to merge, or discard this patch.
src/SkillSpecial.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public const TARGET_PARTY = "party";
24 24
     public const TARGET_ENEMY_PARTY = "enemy_party";
25 25
     /** @var string[] */
26
-    public const NO_STAT_TYPES = [self::TYPE_STUN, self::TYPE_POISON, self::TYPE_HIDE,];
26
+    public const NO_STAT_TYPES = [self::TYPE_STUN, self::TYPE_POISON, self::TYPE_HIDE, ];
27 27
 
28 28
     public readonly string $type;
29 29
     public readonly ?string $stat;
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
     protected function configureOptions(OptionsResolver $resolver): void
51 51
     {
52 52
         parent::configureOptions($resolver);
53
-        $allStats = ["type", "stat", "value", "valueGrowth", "duration",];
53
+        $allStats = ["type", "stat", "value", "valueGrowth", "duration", ];
54 54
         $resolver->setRequired($allStats);
55 55
         $resolver->setAllowedTypes("type", "string");
56
-        $resolver->setAllowedValues("type", function (string $value): bool {
56
+        $resolver->setAllowedValues("type", function(string $value): bool {
57 57
             return in_array($value, $this->getAllowedTypes(), true);
58 58
         });
59 59
         $resolver->setAllowedTypes("stat", ["string", "null"]);
60
-        $resolver->setAllowedValues("stat", function (?string $value): bool {
60
+        $resolver->setAllowedValues("stat", function(?string $value): bool {
61 61
             return $value === null || in_array($value, $this->getAllowedStats(), true);
62 62
         });
63 63
         $resolver->setAllowedTypes("value", "integer");
64
-        $resolver->setAllowedValues("value", function (int $value): bool {
64
+        $resolver->setAllowedValues("value", function(int $value): bool {
65 65
             return ($value >= 0);
66 66
         });
67 67
         $resolver->setAllowedTypes("valueGrowth", "integer");
68
-        $resolver->setAllowedValues("valueGrowth", function (int $value): bool {
68
+        $resolver->setAllowedValues("valueGrowth", function(int $value): bool {
69 69
             return ($value >= 0);
70 70
         });
71 71
         $resolver->setAllowedTypes("duration", "integer");
72
-        $resolver->setAllowedValues("duration", function (int $value): bool {
72
+        $resolver->setAllowedValues("duration", function(int $value): bool {
73 73
             return ($value >= 0);
74 74
         });
75 75
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
  *
12 12
  * @author Jakub Konečný
13 13
  */
14
-final class SkillSpecial extends BaseSkill
15
-{
14
+final class SkillSpecial extends BaseSkill {
16 15
     public const TYPE_BUFF = "buff";
17 16
     public const TYPE_DEBUFF = "debuff";
18 17
     public const TYPE_STUN = "stun";
@@ -31,8 +30,7 @@  discard block
 block discarded – undo
31 30
     public readonly int $valueGrowth;
32 31
     public readonly int $duration;
33 32
 
34
-    public function __construct(array $data)
35
-    {
33
+    public function __construct(array $data) {
36 34
         $resolver = new OptionsResolver();
37 35
         $this->configureOptions($resolver);
38 36
         $data = $resolver->resolve($data);
Please login to merge, or discard this patch.
src/CombatBase.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         public ICombatActionSelector $actionSelector = new CombatActionSelector()
60 60
     ) {
61 61
         $this->victoryCondition = [VictoryConditions::class, "moreDamage"];
62
-        $this->healers = function (): Team {
62
+        $this->healers = function(): Team {
63 63
             return new Team("healers");
64 64
         };
65 65
         $this->combatActions = new class extends Collection {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function setTeams(Team $team1, Team $team2): void
115 115
     {
116
-        if (isset($this->team1)) {
116
+        if(isset($this->team1)) {
117 117
             throw new ImmutableException("Teams has already been set.");
118 118
         }
119 119
         $this->team1 = $team1;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     public function getWinner(): int
192 192
     {
193 193
         static $result = 0;
194
-        if ($result === 0) {
194
+        if($result === 0) {
195 195
             $result = call_user_func($this->victoryCondition, $this);
196 196
             $result = Numbers::range($result, 0, 2);
197 197
         }
@@ -218,30 +218,30 @@  discard block
 block discarded – undo
218 218
     {
219 219
         /** @var Character[] $characters */
220 220
         $characters = array_merge($combat->team1->toArray(), $combat->team2->toArray());
221
-        foreach ($characters as $character) {
221
+        foreach($characters as $character) {
222 222
             $character->applyEffectProviders();
223 223
         }
224 224
     }
225 225
 
226 226
     public function assignPositions(self $combat): void
227 227
     {
228
-        $assignPositions = function (Team $team): void {
228
+        $assignPositions = function(Team $team): void {
229 229
             $row = 1;
230 230
             $column = 0;
231 231
             /** @var Character $character */
232
-            foreach ($team as $character) {
232
+            foreach($team as $character) {
233 233
                 try {
234 234
                     $column++;
235
-                    if ($character->positionRow > 0 && $character->positionColumn > 0) {
235
+                    if($character->positionRow > 0 && $character->positionColumn > 0) {
236 236
                         continue;
237 237
                     }
238 238
                     setPosition:
239 239
                     $team->setCharacterPosition($character->id, $row, $column);
240
-                } catch (InvalidCharacterPositionException $e) {
241
-                    if ($e->getCode() === InvalidCharacterPositionException::ROW_FULL) {
240
+                } catch(InvalidCharacterPositionException $e) {
241
+                    if($e->getCode() === InvalidCharacterPositionException::ROW_FULL) {
242 242
                         $row++;
243 243
                         $column = 1;
244
-                    } elseif ($e->getCode() === InvalidCharacterPositionException::POSITION_OCCUPIED) {
244
+                    } elseif($e->getCode() === InvalidCharacterPositionException::POSITION_OCCUPIED) {
245 245
                         $column++;
246 246
                     } else {
247 247
                         throw $e;
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
     {
259 259
         /** @var Character[] $characters */
260 260
         $characters = array_merge($combat->team1->toArray(), $combat->team2->toArray());
261
-        foreach ($characters as $character) {
262
-            foreach ($character->effects as $effect) {
263
-                if (is_int($effect->duration)) {
261
+        foreach($characters as $character) {
262
+            foreach($character->effects as $effect) {
263
+                if(is_int($effect->duration)) {
264 264
                     $effect->duration--;
265 265
                 }
266 266
             }
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
     {
275 275
         /** @var Character[] $characters */
276 276
         $characters = array_merge($combat->team1->toArray(), $combat->team2->toArray());
277
-        foreach ($characters as $character) {
278
-            foreach ($character->skills as $skill) {
277
+        foreach($characters as $character) {
278
+            foreach($character->skills as $skill) {
279 279
                 $skill->decreaseCooldown();
280 280
             }
281 281
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     {
289 289
         /** @var Character[] $characters */
290 290
         $characters = array_merge($combat->team1->toArray(), $combat->team2->toArray());
291
-        foreach ($characters as $character) {
291
+        foreach($characters as $character) {
292 292
             $character->effects->removeByFilter(["duration!=" => CharacterEffect::DURATION_FOREVER]);
293 293
         }
294 294
     }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
     {
323 323
         /** @var Character[] $characters */
324 324
         $characters = array_merge($combat->team1->toArray(), $combat->team2->toArray());
325
-        foreach ($characters as $character) {
325
+        foreach($characters as $character) {
326 326
             $character->recalculateStats();
327 327
         }
328 328
     }
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
     {
335 335
         /** @var Character[] $characters */
336 336
         $characters = array_merge($combat->team1->toArray(), $combat->team2->toArray());
337
-        foreach ($characters as $character) {
337
+        foreach($characters as $character) {
338 338
             $character->resetInitiative();
339 339
         }
340 340
     }
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
     public function selectAttackTarget(Character $attacker): ?Character
348 348
     {
349 349
         $enemyTeam = $this->getEnemyTeam($attacker);
350
-        $rangedWeapon = ($attacker->equipment->hasItems(["%class%" => Weapon::class, "worn" => true, "ranged" => true,]));
351
-        if (!$rangedWeapon) {
350
+        $rangedWeapon = ($attacker->equipment->hasItems(["%class%" => Weapon::class, "worn" => true, "ranged" => true, ]));
351
+        if(!$rangedWeapon) {
352 352
             $rowToAttack = $enemyTeam->rowToAttack;
353
-            if ($rowToAttack === null) {
353
+            if($rowToAttack === null) {
354 354
                 return null;
355 355
             }
356 356
             $enemies = Team::fromArray(
357
-                $enemyTeam->getItems(["positionRow" => $rowToAttack, "hitpoints>" => 0, "hidden" => false,]),
357
+                $enemyTeam->getItems(["positionRow" => $rowToAttack, "hitpoints>" => 0, "hidden" => false, ]),
358 358
                 $enemyTeam->name
359 359
             );
360 360
         } else {
361 361
             $enemies = $enemyTeam;
362 362
         }
363 363
         $target = $enemies->getLowestHpCharacter();
364
-        if ($target !== null) {
364
+        if($target !== null) {
365 365
             return $target;
366 366
         }
367 367
         return $enemies->getRandomCharacter();
@@ -376,13 +376,13 @@  discard block
 block discarded – undo
376 376
     {
377 377
         /** @var Character[] $characters */
378 378
         $characters = array_merge($combat->team1->usableMembers, $combat->team2->usableMembers);
379
-        usort($characters, function (Character $a, Character $b): int {
379
+        usort($characters, function(Character $a, Character $b): int {
380 380
             return -1 * strcmp((string) $a->initiative, (string) $b->initiative);
381 381
         });
382
-        foreach ($characters as $character) {
382
+        foreach($characters as $character) {
383 383
             /** @var ICombatAction|null $combatAction */
384 384
             $combatAction = $combat->actionSelector->chooseAction($combat, $character);
385
-            if ($combatAction === null) {
385
+            if($combatAction === null) {
386 386
                 break;
387 387
             }
388 388
             $combatAction->do($combat, $character);
@@ -396,18 +396,18 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function execute(): int
398 398
     {
399
-        if (!isset($this->team1)) {
399
+        if(!isset($this->team1)) {
400 400
             throw new InvalidStateException("Teams are not set.");
401 401
         }
402 402
         $this->onCombatStart($this);
403
-        while ($this->round <= $this->roundLimit) {
403
+        while($this->round <= $this->roundLimit) {
404 404
             $this->onRoundStart($this);
405
-            if ($this->getWinner() > 0) {
405
+            if($this->getWinner() > 0) {
406 406
                 break;
407 407
             }
408 408
             $this->onRound($this);
409 409
             $this->onRoundEnd($this);
410
-            if ($this->getWinner() > 0) {
410
+            if($this->getWinner() > 0) {
411 411
                 break;
412 412
             }
413 413
         }
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
     {
423 423
         /** @var Character[] $characters */
424 424
         $characters = array_merge(
425
-            $combat->team1->getItems(["hitpoints>" => 0, "poisoned!=" => false,]),
426
-            $combat->team2->getItems(["hitpoints>" => 0, "poisoned!=" => false,])
425
+            $combat->team1->getItems(["hitpoints>" => 0, "poisoned!=" => false, ]),
426
+            $combat->team2->getItems(["hitpoints>" => 0, "poisoned!=" => false, ])
427 427
         );
428
-        foreach ($characters as $character) {
428
+        foreach($characters as $character) {
429 429
             $poisonValue = $character->getStatus(Character::STATUS_POISONED);
430 430
             $character->harm($poisonValue);
431 431
             $action = [
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
  * @method void onRound(CombatBase $combat)
27 27
  * @method void onRoundEnd(CombatBase $combat)
28 28
  */
29
-class CombatBase
30
-{
29
+class CombatBase {
31 30
     use \Nette\SmartObject;
32 31
 
33 32
     protected Team $team1;
Please login to merge, or discard this patch.
src/CombatActions/SkillAttack.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
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 CharacterAttackSkill);
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         $result = [];
47 47
         $result["result"] = $combat->successCalculator->hasHit($attacker, $defender, $skill);
48 48
         $result["amount"] = 0;
49
-        if ($result["result"]) {
49
+        if($result["result"]) {
50 50
             $amount = (int) (($attacker->damage - $defender->defense) / 100 * $skill->damage);
51 51
             $result["amount"] = Numbers::range($amount, 0, $defender->hitpoints);
52 52
         }
53
-        if ($result["amount"] > 0) {
53
+        if($result["amount"] > 0) {
54 54
             $defender->harm($result["amount"]);
55 55
         }
56 56
         $result["action"] = $this->getName();
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
             Skill::TARGET_COLUMN => $combat->getTeam($primaryTarget)->getItems(["positionColumn" => $primaryTarget->positionColumn]),
78 78
             default => throw new NotImplementedException("Target {$skill->skill->target} for attack skills is not implemented."),
79 79
         };
80
-        foreach ($targets as $target) {
81
-            for ($i = 1; $i <= $skill->skill->strikes; $i++) {
82
-                if ($target->hitpoints > 0) {
80
+        foreach($targets as $target) {
81
+            for($i = 1; $i <= $skill->skill->strikes; $i++) {
82
+                if($target->hitpoints > 0) {
83 83
                     $this->doSingleAttack($character, $target, $skill, $combat);
84 84
                 }
85 85
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 use HeroesofAbenez\Combat\NotImplementedException;
12 12
 use Nexendrie\Utils\Numbers;
13 13
 
14
-final class SkillAttack implements ICombatAction
15
-{
14
+final class SkillAttack implements ICombatAction {
16 15
     public const ACTION_NAME = "skill_attack";
17 16
 
18 17
     public function getName(): string
@@ -65,10 +64,12 @@  discard block
 block discarded – undo
65 64
     /**
66 65
      * @throws NotImplementedException
67 66
      */
68
-    public function do(CombatBase $combat, Character $character): void
67
+    public function do {
68
+      (CombatBase $combat, Character $character): void
69 69
     {
70 70
         /** @var CharacterAttackSkill $skill */
71 71
         $skill = $character->usableSkills[0];
72
+    }
72 73
         /** @var Character $primaryTarget */
73 74
         $primaryTarget = $combat->selectAttackTarget($character);
74 75
         $targets = match ($skill->skill->target) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
             Skill::TARGET_SINGLE => [$primaryTarget],
76 76
             Skill::TARGET_ROW => $combat->getTeam($primaryTarget)->getItems(["positionRow" => $primaryTarget->positionRow]),
77 77
             Skill::TARGET_COLUMN => $combat->getTeam($primaryTarget)->getItems(["positionColumn" => $primaryTarget->positionColumn]),
78
-            default => throw new NotImplementedException("Target {$skill->skill->target} for attack skills is not implemented."),
78
+            default => throw new NotImplementedException("target {$skill->skill->target} for attack skills is not implemented."),
79 79
         };
80 80
         foreach ($targets as $target) {
81 81
             for ($i = 1; $i <= $skill->skill->strikes; $i++) {
Please login to merge, or discard this patch.
src/CombatActions/Attack.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@
 block discarded – undo
36 36
     {
37 37
         $result = [];
38 38
         $defender = $combat->selectAttackTarget($character);
39
-        if ($defender === null) {
39
+        if($defender === null) {
40 40
             return;
41 41
         }
42 42
         $result["result"] = $combat->successCalculator->hasHit($character, $defender);
43 43
         $result["amount"] = 0;
44
-        if ($result["result"]) {
44
+        if($result["result"]) {
45 45
             $amount = $character->damage - $defender->defense;
46 46
             $result["amount"] = Numbers::range($amount, 0, $defender->hitpoints);
47 47
         }
48
-        if ($result["amount"] > 0) {
48
+        if($result["amount"] > 0) {
49 49
             $defender->harm($result["amount"]);
50 50
         }
51 51
         $result["action"] = $this->getName();
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@  discard block
 block discarded – undo
8 8
 use HeroesofAbenez\Combat\ICombatAction;
9 9
 use Nexendrie\Utils\Numbers;
10 10
 
11
-final class Attack implements ICombatAction
12
-{
11
+final class Attack implements ICombatAction {
13 12
     public const ACTION_NAME = "attack";
14 13
 
15 14
     public function getName(): string
@@ -32,9 +31,11 @@  discard block
 block discarded – undo
32 31
      * Hit chance = Attacker's hit - Defender's dodge, but at least 15%
33 32
      * Damage = Attacker's damage - defender's defense
34 33
      */
35
-    public function do(CombatBase $combat, Character $character): void
34
+    public function do {
35
+      (CombatBase $combat, Character $character): void
36 36
     {
37 37
         $result = [];
38
+    }
38 39
         $defender = $combat->selectAttackTarget($character);
39 40
         if ($defender === null) {
40 41
             return;
Please login to merge, or discard this patch.
src/CombatActions/SkillSpecial.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 use HeroesofAbenez\Combat\NotImplementedException;
12 12
 use HeroesofAbenez\Combat\CharacterEffect;
13 13
 
14
-final class SkillSpecial implements ICombatAction
15
-{
14
+final class SkillSpecial implements ICombatAction {
16 15
     public const ACTION_NAME = "skill_special";
17 16
 
18 17
     public function getName(): string
@@ -63,10 +62,12 @@  discard block
 block discarded – undo
63 62
     /**
64 63
      * @throws NotImplementedException
65 64
      */
66
-    public function do(CombatBase $combat, Character $character): void
65
+    public function do {
66
+      (CombatBase $combat, Character $character): void
67 67
     {
68 68
         /** @var CharacterSpecialSkill $skill */
69 69
         $skill = $character->usableSkills[0];
70
+    }
70 71
         $targets = match ($skill->skill->target) {
71 72
             Skill::TARGET_ENEMY => [$combat->selectAttackTarget($character)],
72 73
             Skill::TARGET_SELF => [$character],
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             "character1" => $character1, "character2" => $target,
49 49
         ];
50 50
         $effect = new CharacterEffect([
51
-            "id" => "skill{$skill->skill->id}Effect",
51
+            "id" => "skill{$skill->skill->id}effect",
52 52
             "type" => $skill->skill->type,
53 53
             "stat" => ((in_array($skill->skill->type, Skill::NO_STAT_TYPES, true)) ? null : $skill->skill->stat),
54 54
             "value" => $skill->value,
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             Skill::TARGET_SELF => [$character],
73 73
             Skill::TARGET_PARTY => $combat->getTeam($character)->toArray(),
74 74
             Skill::TARGET_ENEMY_PARTY => $combat->getEnemyTeam($character)->toArray(),
75
-            default => throw new NotImplementedException("Target {$skill->skill->target} for special skills is not implemented."),
75
+            default => throw new NotImplementedException("target {$skill->skill->target} for special skills is not implemented."),
76 76
         };
77 77
         foreach ($targets as $target) {
78 78
             $this->doSingleTarget($character, $target, $skill, $combat);
Please login to merge, or discard this patch.
src/CombatActions/Heal.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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");
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
 use Nexendrie\Utils\Numbers;
10 10
 use HeroesofAbenez\Combat\Team;
11 11
 
12
-final class Heal implements ICombatAction
13
-{
12
+final class Heal implements ICombatAction {
14 13
     public const ACTION_NAME = "healing";
15 14
 
16 15
     public function getName(): string
@@ -28,9 +27,11 @@  discard block
 block discarded – undo
28 27
         return (in_array($character, $this->findHealers($combat)->toArray(), true) && $this->selectHealingTarget($character, $combat) !== null);
29 28
     }
30 29
 
31
-    public function do(CombatBase $combat, Character $character): void
30
+    public function do {
31
+      (CombatBase $combat, Character $character): void
32 32
     {
33 33
         $result = [];
34
+    }
34 35
         /** @var Character $patient */
35 36
         $patient = $this->selectHealingTarget($character, $combat);
36 37
         $result["result"] = $combat->successCalculator->hasHealed($character);
Please login to merge, or discard this patch.