From 826f67d125320c326cfa7d11c65a682dcad0836e Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Wed, 23 Mar 2022 09:10:51 +0100 Subject: [PATCH] gamePhase() prevent null direction --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 44bf317..fcfd270 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -222,10 +222,9 @@ public class Game implements GameSpecification { direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove(); if (direction == null) { track.getCar(currentCarIndex).setMoveStrategy(new DoNotMoveStrategy()); - track.getCar(currentCarIndex).getMoveStrategy().nextMove(); - }else { - doCarTurn(direction); + direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove(); } + doCarTurn(direction); switchToNextActiveCar(); } userInterface.printTrack(track);