From 1c618ad09aaafa036eb8ccbf35a9e7b5b0f4fb84 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 18 Mar 2022 16:45:16 +0100 Subject: [PATCH] change in gamephase in Game.java --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 508244d..cdac7ab 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -189,7 +189,12 @@ public class Game implements GameSpecification { public int gamePhase() throws PositionVectorNotValid { while (CarsMoving() && getWinner() == NO_WINNER) { userInterface.printTrack(track); - Direction direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove(); + Direction direction = null; + direction= track.getCar(currentCarIndex).getMoveStrategy().nextMove(); + if(direction == null) { + track.getCar(currentCarIndex).setMoveStrategy(new DoNotMoveStrategy()); + direction= track.getCar(currentCarIndex).getMoveStrategy().nextMove(); + } doCarTurn(direction); switchToNextActiveCar(); }