From 034d1e4b582e9fd7fab83654bdb29ced2e923739 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 17 Mar 2020 22:00:56 +0100 Subject: [PATCH] =?UTF-8?q?Legger=20til=20nye=20roboter=20p=C3=A5=20brette?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flytter på søvn når transportbånd flyttes Fikser testen for tegnbare objekter --- .../roborally/objects/RoboRallyGame.java | 24 ++++++++++++------- .../roborally/objects/DrawableObjectTest.java | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java index 6d9a75c..aef7691 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java +++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java @@ -71,6 +71,11 @@ public class RoboRallyGame implements IDrawableGame { robots.add(new Robot(RobotID.ROBOT_1, new Position(0, 16))); robots.add(new Robot(RobotID.ROBOT_2, new Position(1, 16))); robots.add(new Robot(RobotID.ROBOT_3, new Position(2, 16))); + robots.add(new Robot(RobotID.ROBOT_4, new Position(3, 16))); + robots.add(new Robot(RobotID.ROBOT_5, new Position(4, 16))); + robots.add(new Robot(RobotID.ROBOT_6, new Position(5, 16))); + robots.add(new Robot(RobotID.ROBOT_7, new Position(6, 16))); + robots.add(new Robot(RobotID.ROBOT_8, new Position(7, 16))); try { gameBoard = BoardLoaderUtil.loadBoard("boards/all_tiles_test_board.txt", robots); } catch (IOException e) { @@ -87,6 +92,11 @@ public class RoboRallyGame implements IDrawableGame { robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1))); robots.add(new Robot(RobotID.ROBOT_2, new Position(1, 2))); robots.add(new Robot(RobotID.ROBOT_3, new Position(1, 3))); + robots.add(new Robot(RobotID.ROBOT_4, new Position(4, 8))); + robots.add(new Robot(RobotID.ROBOT_5, new Position(6, 6))); + robots.add(new Robot(RobotID.ROBOT_6, new Position(7, 7))); + robots.add(new Robot(RobotID.ROBOT_7, new Position(6, 7))); + robots.add(new Robot(RobotID.ROBOT_8, new Position(6, 8))); gameBoard = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots); cogwheels = gameBoard.getPositionsOfTileOnBoard(TileType.COGWHEEL_RIGHT, TileType.COGWHEEL_LEFT); @@ -143,6 +153,8 @@ public class RoboRallyGame implements IDrawableGame { makeMove(RobotID.ROBOT_2, Action.ROTATE_LEFT); makeMove(RobotID.ROBOT_2, Action.U_TURN); makeMove(RobotID.ROBOT_2, Action.MOVE_1); + moveAllConveyorBelts(); + makeMove(RobotID.ROBOT_7, Action.MOVE_1); } /** @@ -242,16 +254,17 @@ public class RoboRallyGame implements IDrawableGame { * @throws InterruptedException If disturbed during sleep */ private void moveAllConveyorBelts() throws InterruptedException { + sleep(); moveConveyorBelts(fastConveyorBelts); + sleep(); moveConveyorBelts(conveyorBelts); } /** * Moves all conveyor belts in the input list * @param conveyorBelts A list of conveyor belts to move - * @throws InterruptedException If disturbed during sleep */ - private void moveConveyorBelts(List> conveyorBelts) throws InterruptedException { + private void moveConveyorBelts(List> conveyorBelts) { List> conveyorBeltsWithRobotsThatShouldMove = conveyorBeltsThatCanMoveWithoutConflict(conveyorBelts); for (BoardElementContainer conveyorBelt : conveyorBeltsWithRobotsThatShouldMove) { @@ -321,19 +334,14 @@ public class RoboRallyGame implements IDrawableGame { * @param robot The id of the robot to move * @param currentDirection The direction of the conveyor belt the robot is standing on * @param nextTile The tile the robot is moving to - * @throws InterruptedException If disturbed during sleep */ - private void doConveyorBeltMovement(RobotID robot, Direction currentDirection, Tile nextTile) - throws InterruptedException { + private void doConveyorBeltMovement(RobotID robot, Direction currentDirection, Tile nextTile) { Direction nextDirection = nextTile.getDirection(); - sleep(); gameBoard.moveRobot(robot, currentDirection); if (testPredicate(conveyorBelts, (container) -> container.getElement() == nextTile)) { if (Direction.getRightRotatedDirection(nextDirection) == currentDirection) { - sleep(); gameBoard.rotateRobotLeft(robot); } else if (Direction.getLeftRotatedDirection(nextDirection) == currentDirection) { - sleep(); gameBoard.rotateRobotRight(robot); } } diff --git a/src/test/java/inf112/fiasko/roborally/objects/DrawableObjectTest.java b/src/test/java/inf112/fiasko/roborally/objects/DrawableObjectTest.java index 0ba1e52..7d341c9 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/DrawableObjectTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/DrawableObjectTest.java @@ -16,9 +16,9 @@ import static org.junit.Assert.assertFalse; public class DrawableObjectTest { private static final Texture textureSheet = new Texture(Gdx.files.internal("assets/tiles.png")); - private static final Texture robotTexture = new Texture(Gdx.files.internal("assets/Robot.png")); + private static final Texture robotsTexture = new Texture(Gdx.files.internal("assets/robots.png")); public static final TextureRegion TEXTURE_MIN_ARG = new TextureRegion(textureSheet, 4*300, 0, 300, 300); - public static final TextureRegion TEXTURE_MAX_ARG = new TextureRegion(robotTexture, 0, 0, 64, 64); + public static final TextureRegion TEXTURE_MAX_ARG = new TextureRegion(robotsTexture, 0, 0, 64, 64); public static final int X_POSITION_MIN_ARG = 5; public static final int Y_POSITION_MIN_ARG = 8; public static final int X_POSITION_MAX_ARG = 6;