/** * @param $playerOne * @param $playerTwo * @return array */ public function run(Combatant $playerOne, Combatant $playerTwo) { $output = []; $playerOneHealth = $playerOne->getHealth(); if ($playerOne->isStunned()) { $output[] = $playerOne->getName() . " is stunned and misses attack turn"; return $output; } $output[] = $playerOne->getName() . " attacks"; $hit = $playerOne->attack($playerTwo); if ($hit) { $output[] = $playerOne->getName() . " does " . $hit . " damage"; if ($playerTwo->isStunned()) { $output[] = $playerTwo->getName() . " is stunned"; } } else { $output[] = $playerTwo->getName() . " dodged the attack"; if ($playerOne->getHealth() !== $playerOneHealth) { $lostHealth = $playerOneHealth - $playerOne->getHealth(); $output[] = $playerOne->getName() . " lost " . $lostHealth . " health during the attack"; } } return $output; }