@@ -3,10 +3,11 @@ |
||
| 3 | 3 | |
| 4 | 4 | namespace HeroesofAbenez\Combat; |
| 5 | 5 | |
| 6 | -interface ICombatAction |
|
| 7 | -{ |
|
| 6 | +interface ICombatAction { |
|
| 8 | 7 | public function getName(): string; |
| 9 | 8 | public function getPriority(): int; |
| 10 | 9 | public function shouldUse(CombatBase $combat, Character $character): bool; |
| 11 | - public function do(CombatBase $combat, Character $character): void; |
|
| 12 | -} |
|
| 10 | + public function do { |
|
| 11 | + (CombatBase $combat, Character $character): void; |
|
| 12 | + } |
|
| 13 | + } |
|
@@ -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 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | * @property-read bool $ranged |
| 14 | 14 | * @property-read string $damageStat |
| 15 | 15 | */ |
| 16 | -class Weapon extends Equipment |
|
| 17 | -{ |
|
| 16 | +class Weapon extends Equipment { |
|
| 18 | 17 | public const TYPE_SWORD = "sword"; |
| 19 | 18 | public const TYPE_AXE = "axe"; |
| 20 | 19 | public const TYPE_CLUB = "club"; |
@@ -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"); |
@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | * |
| 11 | 11 | * @author Jakub Konečný |
| 12 | 12 | */ |
| 13 | -final class CombatLogEntry |
|
| 14 | -{ |
|
| 13 | +final class CombatLogEntry { |
|
| 15 | 14 | /** @internal */ |
| 16 | 15 | public const ACTION_POISON = "poison"; |
| 17 | 16 | |
@@ -22,8 +21,7 @@ discard block |
||
| 22 | 21 | public readonly bool $result; |
| 23 | 22 | public readonly int $amount; |
| 24 | 23 | |
| 25 | - public function __construct(array $action) |
|
| 26 | - { |
|
| 24 | + public function __construct(array $action) { |
|
| 27 | 25 | $resolver = new OptionsResolver(); |
| 28 | 26 | $this->configureOptions($resolver); |
| 29 | 27 | $action = $resolver->resolve($action); |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | namespace HeroesofAbenez\Combat; |
| 5 | 5 | |
| 6 | -interface ICombatLogRender |
|
| 7 | -{ |
|
| 6 | +interface ICombatLogRender { |
|
| 8 | 7 | public function render(array $params): string; |
| 9 | 8 | } |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | * |
| 9 | 9 | * @author Jakub Konečný |
| 10 | 10 | */ |
| 11 | -interface IInitiativeFormulaParser |
|
| 12 | -{ |
|
| 11 | +interface IInitiativeFormulaParser { |
|
| 13 | 12 | public function calculateInitiative(Character $character): int; |
| 14 | 13 | } |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | * |
| 9 | 9 | * @author Jakub Konečný |
| 10 | 10 | */ |
| 11 | -interface ISuccessCalculator |
|
| 12 | -{ |
|
| 11 | +interface ISuccessCalculator { |
|
| 13 | 12 | public function hasHit(Character $character1, Character $character2, ?CharacterAttackSkill $skill = null): bool; |
| 14 | 13 | public function hasHealed(Character $healer): bool; |
| 15 | 14 | } |
@@ -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); |
@@ -10,8 +10,7 @@ |
||
| 10 | 10 | * |
| 11 | 11 | * @author Jakub Konečný |
| 12 | 12 | */ |
| 13 | -final class RandomSuccessCalculator implements ISuccessCalculator |
|
| 14 | -{ |
|
| 13 | +final class RandomSuccessCalculator implements ISuccessCalculator { |
|
| 15 | 14 | public const MAX_HIT_CHANCE = 100; |
| 16 | 15 | public const MIN_HIT_CHANCE = 15; |
| 17 | 16 | |
@@ -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 | } |
@@ -16,8 +16,7 @@ |
||
| 16 | 16 | * @property-read int $levels |
| 17 | 17 | * @property-read int $cooldown |
| 18 | 18 | */ |
| 19 | -abstract class BaseSkill |
|
| 20 | -{ |
|
| 19 | +abstract class BaseSkill { |
|
| 21 | 20 | use \Nette\SmartObject; |
| 22 | 21 | |
| 23 | 22 | protected int $id; |
@@ -8,10 +8,8 @@ |
||
| 8 | 8 | * |
| 9 | 9 | * @author Jakub Konečný |
| 10 | 10 | */ |
| 11 | -final class ConstantInitiativeFormulaParser implements IInitiativeFormulaParser |
|
| 12 | -{ |
|
| 13 | - public function __construct(private readonly int $initiative) |
|
| 14 | - { |
|
| 11 | +final class ConstantInitiativeFormulaParser implements IInitiativeFormulaParser { |
|
| 12 | + public function __construct(private readonly int $initiative) { |
|
| 15 | 13 | } |
| 16 | 14 | |
| 17 | 15 | public function calculateInitiative(Character $character): int |