private static function takeTurns(GameState $state, Spell $spell) { $state->applyEffects(); if ($state->isBossDead()) { return true; } if (!$state->isSpellAvailable($spell)) { return false; } $state->castSpell($spell); $state->applyEffects(); if ($state->isBossDead()) { return true; } $state->takeDamage(); if ($state->isPlayerDead()) { return false; } return null; }