From ea855573e0c64dec719580afb07d5f655a6ebb47 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 21 Apr 2020 16:28:44 +0200 Subject: [PATCH] =?UTF-8?q?Fikser=20sjekking=20av=20en=20robot=20som=20st?= =?UTF-8?q?=C3=A5r=20p=C3=A5=20et=20transporb=C3=A5nd=20som=20peker=20ut?= =?UTF-8?q?=20av=20brettet,=20men=20som=20blir=20stoppet=20av=20en=20vegg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inf112/fiasko/roborally/objects/Board.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index be7db3e..0b633f2 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -329,19 +329,18 @@ public class Board { return true; } Position positionInFront = getNewPosition(conveyorBeltPosition, conveyorBeltDirection); - if (!isValidPosition(positionInFront)) { - return true; + //The tile in front of the robot is not a conveyor belt and has something on it stopping the conveyor belt + if ((!isValidPosition(positionInFront) && moveIsStoppedByWall(conveyorBeltPosition, positionInFront, + conveyorBeltDirection)) || (isValidPosition(positionInFront) && + !isConveyorBelt(getTileOnPosition(positionInFront)) && + hasFrontConflict(conveyorBeltPosition, positionInFront, conveyorBeltDirection))) { + return false; } - Tile tileInFront = getTileOnPosition(positionInFront); //If a conveyor belt will move the robot outside the map, the move is valid if (!isValidPosition(positionInFront)) { return true; } - //The tile in front of the robot is not a conveyor belt and has something on it stopping the conveyor belt - if (!isConveyorBelt(tileInFront) && - hasFrontConflict(conveyorBeltPosition, positionInFront, conveyorBeltDirection)) { - return false; - } + Tile tileInFront = getTileOnPosition(positionInFront); //There is another robot trying to enter the same crossing if (hasCrossingConflict(positionInFront, conveyorBeltDirection)) { return false;