| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.128 |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function chooseAction(CombatBase $combat, Character $character): ?ICombatAction |
||
| 14 | { |
||
| 15 | 1 | if (!$character->canAct()) { |
|
| 16 | return null; |
||
| 17 | } |
||
| 18 | /** @var ICombatAction[] $actions */ |
||
| 19 | 1 | $actions = $combat->combatActions->toArray(); |
|
| 20 | 1 | usort($actions, function (ICombatAction $a, ICombatAction $b): int { |
|
| 21 | 1 | return $a->getPriority() <=> $b->getPriority(); |
|
| 22 | 1 | }); |
|
| 23 | 1 | foreach ($actions as $action) { |
|
| 24 | 1 | if ($action->shouldUse($combat, $character)) { |
|
| 25 | 1 | return $action; |
|
| 26 | } |
||
| 27 | } |
||
| 28 | return null; |
||
| 29 | } |
||
| 31 |