From 63204a4b29ee12a76a25dbbf7e6fbd0088d0b240 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 18 Mar 2022 10:43:22 +0100 Subject: [PATCH] fixes in Game.java Method gamePhase --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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(); } /**