| Conditions | 8 |
| Paths | 7 |
| Total Lines | 19 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 8.1867 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function chooseAction(CombatBase $combat, Character $character): ?string { |
||
| 22 | 1 | if($character->hitpoints < 1) { |
|
| 23 | return NULL; |
||
| 24 | 1 | } elseif(in_array($character, $combat->findHealers()->toArray(), true) AND !is_null($combat->selectHealingTarget($character))) { |
|
|
|
|||
| 25 | 1 | return CombatAction::ACTION_HEALING; |
|
| 26 | } |
||
| 27 | 1 | $attackTarget = $combat->selectAttackTarget($character); |
|
| 28 | 1 | if(is_null($attackTarget)) { |
|
| 29 | return NULL; |
||
| 30 | } |
||
| 31 | 1 | if(count($character->usableSkills) > 0) { |
|
| 32 | 1 | $skill = $character->usableSkills[0]; |
|
| 33 | 1 | if($skill instanceof CharacterAttackSkill) { |
|
| 34 | 1 | return CombatAction::ACTION_SKILL_ATTACK; |
|
| 35 | 1 | } elseif($skill instanceof CharacterSpecialSkill) { |
|
| 36 | 1 | return CombatAction::ACTION_SKILL_SPECIAL; |
|
| 37 | } |
||
| 38 | } |
||
| 39 | 1 | return CombatAction::ACTION_ATTACK; |
|
| 40 | } |
||
| 42 | ?> |