diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 48bd162..c7dbfbb 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -179,17 +179,17 @@ public class Game implements GameSpecification { } public int gamePhase() throws PositionVectorNotValid { - do{ + while (getWinner() == NO_WINNER) { userInterface.printTrack(track); Direction direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove(); doCarTurn(direction); int winner = getWinner(); - if(winner != NO_WINNER) { - return winner; + if(allCarsCrashed()) { + return NO_WINNER; } switchToNextActiveCar(); - } while (!allCarsCrashed()); - return NO_WINNER; + } + return getWinner(); } /**