From 3b7a5c6899cf1ac6329cd9f9d33ccb061f2b42fe Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 17 Mar 2020 14:37:49 +0100 Subject: [PATCH] =?UTF-8?q?Gj=C3=B8r=20metoden=20for=20=C3=A5=20sjekke=20o?= =?UTF-8?q?m=20et=20trekk=20blir=20stoppet=20av=20en=20vegg=20offentlig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bytter navn fra robotMove til move --- .../fiasko/roborally/objects/Board.java | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index acb43aa..049b394 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -135,7 +135,7 @@ public class Board { Position robotPosition = robot.getPosition(); Position newPosition = getNewPosition(robotPosition, direction); //There is a wall blocking the robot. It can't proceed. - if (robotMoveIsStoppedByWall(robotPosition, newPosition, direction)) { + if (moveIsStoppedByWall(robotPosition, newPosition, direction)) { return false; } //Robot tried to go outside of the map. Kill it. @@ -241,18 +241,6 @@ public class Board { return tiles.getElement(position.getXCoordinate(), position.getYCoordinate()); } - /** - * Gets the wall on a specific position - * @param position The position to get a wall from - * @return The wall on the given position - */ - public Wall getWallOnPosition(Position position) { - if (!isValidPosition(position)) { - throw new IllegalArgumentException("Position is not on the board!"); - } - return walls.getElement(position.getXCoordinate(), position.getYCoordinate()); - } - /** * Gets a list of BoardElementContainers, containing all tiles and positions of given tile types * @param tiles The tiles you want all positions for @@ -280,13 +268,13 @@ public class Board { } /** - * Checks if a potential robot move would be blocked by a wall - * @param robotPosition The current position of the robot - * @param newPosition The position the robot is trying to move to - * @param direction The direction the robot is going + * Checks if a potential move would be blocked by a wall + * @param robotPosition The current position of whatever is trying to move + * @param newPosition The position something is trying to move to + * @param direction The direction something is going * @return True if a wall would stop its path */ - private boolean robotMoveIsStoppedByWall(Position robotPosition, Position newPosition, Direction direction) { + public boolean moveIsStoppedByWall(Position robotPosition, Position newPosition, Direction direction) { return hasWallFacing(robotPosition, direction) || (isValidPosition(newPosition) && hasWallFacing(newPosition, Direction.getReverseDirection(direction))); }