Skip to content

Commit

Permalink
Fix: Break when player have mission
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurJCQ committed Dec 25, 2023
1 parent 2a3fac9 commit f4bdb15
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function execute(Room $room): void

foreach ($players as $player) {
$this->assignMissions($missions, $player);

if (!$player->getAssignedMission()) {
throw new \LogicException('Error while assigning mission to the player');
}
}

return;
Expand Down Expand Up @@ -78,6 +82,11 @@ public function execute(Room $room): void

// Dive into all playerMissions missions.
$this->assignMissions($missions, $player);

// Break to not keep trying to assign mission to the player
if ($player->getAssignedMission() instanceof Mission) {
break;
}
}
}
}
Expand All @@ -104,9 +113,5 @@ private function assignMissions(array $missions, Player $player): void

break;
}

if (!$player->getAssignedMission()) {
throw new \LogicException('Error while assigning mission to player');
}
}
}

0 comments on commit f4bdb15

Please sign in to comment.