mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
commit
cf8c04dc17
12
docs/team/referater/referat_21_04_2020.md
Normal file
12
docs/team/referater/referat_21_04_2020.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
## Oppmøte
|
||||||
|
Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter
|
||||||
|
Ikke tilstede:
|
||||||
|
|
||||||
|
## Agenda
|
||||||
|
- Fortsette arbeidet med MVP
|
||||||
|
|
||||||
|
- Et gruppemedlem skal ha møte med foreleser, skal oppdatere gruppen på hva som blir avgjort her
|
||||||
|
|
||||||
|
## Møte
|
||||||
|
Vi starter å fortsette arbeidet vi holdt på me fra sist gang med en gang. Et gruppemedlem drar på møte me
|
||||||
|
foreleser og oppdaterer gruppen på hva som ble snakket om der.
|
@ -43,13 +43,13 @@ class RoboRallyClientListener extends Listener {
|
|||||||
wrapper.server != null, info.getPlayerName(), wrapper.server);
|
wrapper.server != null, info.getPlayerName(), wrapper.server);
|
||||||
} else if (object instanceof ProgrammingCardDeck) {
|
} else if (object instanceof ProgrammingCardDeck) {
|
||||||
if(((ProgrammingCardDeck) object).isEmpty()){
|
if(((ProgrammingCardDeck) object).isEmpty()){
|
||||||
|
wrapper.roboRallyGame.setProgram(new ArrayList<>());
|
||||||
if (wrapper.roboRallyGame.getRobotPowerdown()){
|
if (wrapper.roboRallyGame.getRobotPowerdown()){
|
||||||
wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
|
wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
|
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
|
||||||
}
|
}
|
||||||
wrapper.roboRallyGame.setProgram(new ArrayList<>());
|
|
||||||
}
|
}
|
||||||
else {wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);}
|
else {wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);}
|
||||||
new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start();
|
new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start();
|
||||||
|
@ -4,7 +4,7 @@ package inf112.fiasko.roborally.networking.containers;
|
|||||||
* This class represents a response saying that something went wrong with the request
|
* This class represents a response saying that something went wrong with the request
|
||||||
*/
|
*/
|
||||||
public class ErrorResponse {
|
public class ErrorResponse {
|
||||||
private final String errorMessage;
|
private String errorMessage;
|
||||||
private boolean critical;
|
private boolean critical;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,6 +16,9 @@ public class ErrorResponse {
|
|||||||
this.errorMessage = errorMessage;
|
this.errorMessage = errorMessage;
|
||||||
this.critical = false;
|
this.critical = false;
|
||||||
}
|
}
|
||||||
|
public ErrorResponse(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new error response
|
* Constructs a new error response
|
||||||
|
@ -186,11 +186,10 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
|||||||
removeNonLockedProgrammingCardsFromPlayers();
|
removeNonLockedProgrammingCardsFromPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameBoard.getPowerDown(Objects.requireNonNull(getPlayerFromName(this.playerName)).getRobotID())) {
|
if (getPlayerFromName(this.playerName)!=null&& gameBoard.getPowerDown(Objects.requireNonNull(getPlayerFromName(this.playerName)).getRobotID())) {
|
||||||
setGameState(GameState.CHOOSING_STAY_IN_POWER_DOWN);
|
setGameState(GameState.CHOOSING_STAY_IN_POWER_DOWN);
|
||||||
} else {
|
} else {
|
||||||
setGameState(GameState.LOADING);
|
setGameState(GameState.LOADING);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package inf112.fiasko.roborally.objects;
|
package inf112.fiasko.roborally.objects;
|
||||||
|
|
||||||
import inf112.fiasko.roborally.elementproperties.Action;
|
import inf112.fiasko.roborally.elementproperties.Action;
|
||||||
|
import inf112.fiasko.roborally.elementproperties.Direction;
|
||||||
import inf112.fiasko.roborally.elementproperties.Position;
|
import inf112.fiasko.roborally.elementproperties.Position;
|
||||||
import inf112.fiasko.roborally.elementproperties.RobotID;
|
import inf112.fiasko.roborally.elementproperties.RobotID;
|
||||||
import inf112.fiasko.roborally.utility.BoardLoaderUtil;
|
import inf112.fiasko.roborally.utility.BoardLoaderUtil;
|
||||||
@ -109,6 +110,159 @@ public class PhaseTest {
|
|||||||
assertEquals(robot4.getRobotId(), board.getRobotOnPosition(new Position(3, 7)));
|
assertEquals(robot4.getRobotId(), board.getRobotOnPosition(new Position(3, 7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotFiresLaserAndHitsAnotherRobot() throws InterruptedException {
|
||||||
|
FakeGame testGame = new FakeGame();
|
||||||
|
List<Robot> bot = new ArrayList<>();
|
||||||
|
List<Player> botPlayer = new ArrayList<>();
|
||||||
|
Position bot1Position = new Position(9, 12);
|
||||||
|
Position bot2Position = new Position(9, 13);
|
||||||
|
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
|
||||||
|
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
|
||||||
|
bot.add(bot1);
|
||||||
|
bot.add(bot2);
|
||||||
|
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
|
||||||
|
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
|
||||||
|
botPlayer.add(botPlayer1);
|
||||||
|
botPlayer.add(botPlayer2);
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
|
||||||
|
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
|
||||||
|
assertEquals(0, bot2.getDamageTaken());
|
||||||
|
assertEquals(0, bot1.getDamageTaken());
|
||||||
|
testPhase.fireAllLasers();
|
||||||
|
assertEquals(0, bot2.getDamageTaken());
|
||||||
|
assertEquals(1, bot1.getDamageTaken());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotFiresLaserAndHitsAWallDoesNotDamageRobotOnOtherSide() throws InterruptedException {
|
||||||
|
FakeGame testGame = new FakeGame();
|
||||||
|
List<Robot> bot = new ArrayList<>();
|
||||||
|
List<Player> botPlayer = new ArrayList<>();
|
||||||
|
Position bot1Position = new Position(9, 11);
|
||||||
|
Position bot2Position = new Position(9, 13);
|
||||||
|
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
|
||||||
|
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
|
||||||
|
bot.add(bot1);
|
||||||
|
bot.add(bot2);
|
||||||
|
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
|
||||||
|
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
|
||||||
|
botPlayer.add(botPlayer1);
|
||||||
|
botPlayer.add(botPlayer2);
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
|
||||||
|
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
|
||||||
|
assertEquals(0, bot2.getDamageTaken());
|
||||||
|
assertEquals(0, bot1.getDamageTaken());
|
||||||
|
testPhase.fireAllLasers();
|
||||||
|
assertEquals(0, bot2.getDamageTaken());
|
||||||
|
assertEquals(0, bot1.getDamageTaken());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotGetsHitBy2Lasers() throws InterruptedException {
|
||||||
|
FakeGame testGame = new FakeGame();
|
||||||
|
List<Robot> bot = new ArrayList<>();
|
||||||
|
List<Player> botPlayer = new ArrayList<>();
|
||||||
|
Position bot1Position = new Position(9, 12);
|
||||||
|
Position bot2Position = new Position(9, 13);
|
||||||
|
Position bot3Position = new Position(8, 12);
|
||||||
|
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
|
||||||
|
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
|
||||||
|
Robot bot3 = new Robot(RobotID.ROBOT_3, bot3Position);
|
||||||
|
bot.add(bot1);
|
||||||
|
bot.add(bot2);
|
||||||
|
bot.add(bot3);
|
||||||
|
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
|
||||||
|
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
|
||||||
|
Player botPlayer3 = new Player(RobotID.ROBOT_3, "Player 3");
|
||||||
|
botPlayer.add(botPlayer1);
|
||||||
|
botPlayer.add(botPlayer2);
|
||||||
|
botPlayer.add(botPlayer3);
|
||||||
|
bot3.setFacingDirection(Direction.EAST);
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
|
||||||
|
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
|
||||||
|
assertEquals(0, bot1.getDamageTaken());
|
||||||
|
testPhase.fireAllLasers();
|
||||||
|
assertEquals(2, bot1.getDamageTaken());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotFiresLaserAndHitsARobotDoesNotDamageRobotOnOtherSide() throws InterruptedException {
|
||||||
|
FakeGame testGame = new FakeGame();
|
||||||
|
List<Robot> bot = new ArrayList<>();
|
||||||
|
List<Player> botPlayer = new ArrayList<>();
|
||||||
|
Position bot1Position = new Position(9, 12);
|
||||||
|
Position bot2Position = new Position(9, 13);
|
||||||
|
Position bot3Position = new Position(9, 14);
|
||||||
|
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
|
||||||
|
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
|
||||||
|
Robot bot3 = new Robot(RobotID.ROBOT_3, bot3Position);
|
||||||
|
bot.add(bot1);
|
||||||
|
bot.add(bot2);
|
||||||
|
bot.add(bot3);
|
||||||
|
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
|
||||||
|
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
|
||||||
|
Player botPlayer3 = new Player(RobotID.ROBOT_3, "Player 3");
|
||||||
|
botPlayer.add(botPlayer1);
|
||||||
|
botPlayer.add(botPlayer2);
|
||||||
|
botPlayer.add(botPlayer3);
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
|
||||||
|
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
|
||||||
|
assertEquals(0, bot1.getDamageTaken());
|
||||||
|
testPhase.fireAllLasers();
|
||||||
|
assertEquals(1, bot1.getDamageTaken());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotGetsRotatedByCog() throws InterruptedException {
|
||||||
|
FakeGame testGame = new FakeGame();
|
||||||
|
List<Robot> bot = new ArrayList<>();
|
||||||
|
List<Player> botPlayer = new ArrayList<>();
|
||||||
|
Position bot1Position = new Position(0, 0);
|
||||||
|
Position bot2Position = new Position(1, 0);
|
||||||
|
Robot bot1 = new Robot(RobotID.ROBOT_1, bot1Position);
|
||||||
|
Robot bot2 = new Robot(RobotID.ROBOT_2, bot2Position);
|
||||||
|
bot.add(bot1);
|
||||||
|
bot.add(bot2);
|
||||||
|
Player botPlayer1 = new Player(RobotID.ROBOT_1, "Player 1");
|
||||||
|
botPlayer.add(botPlayer1);
|
||||||
|
Player botPlayer2 = new Player(RobotID.ROBOT_2, "Player 2");
|
||||||
|
botPlayer.add(botPlayer2);
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/another_test_map.txt", bot);
|
||||||
|
Phase testPhase = new Phase(board, botPlayer, 0, testGame);
|
||||||
|
assertEquals(Direction.NORTH, bot1.getFacingDirection());
|
||||||
|
testPhase.rotateCogwheels();
|
||||||
|
assertEquals(Direction.EAST, bot1.getFacingDirection());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void programmingCardsGetsPlayedInOrder() throws InterruptedException {
|
public void programmingCardsGetsPlayedInOrder() throws InterruptedException {
|
||||||
List<ProgrammingCard> testProgram1 = new ArrayList<>();
|
List<ProgrammingCard> testProgram1 = new ArrayList<>();
|
||||||
@ -156,4 +310,199 @@ public class PhaseTest {
|
|||||||
assertEquals(robot5.getRobotId(), board.getRobotOnPosition(new Position(2, 12)));
|
assertEquals(robot5.getRobotId(), board.getRobotOnPosition(new Position(2, 12)));
|
||||||
assertEquals(robot6.getRobotId(), board.getRobotOnPosition(new Position(2, 14)));
|
assertEquals(robot6.getRobotId(), board.getRobotOnPosition(new Position(2, 14)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotsOnConveyorBeltsFacingTheSameEmptyTileDoesNotMove() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(8, 11)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_2, new Position(7, 10)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(8, 11)));
|
||||||
|
assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(7, 10)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotsOnConveyorBeltsFacingTheSameHoleTileDoesNotMove() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(6, 7)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_2, new Position(7, 8)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(6, 7)));
|
||||||
|
assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(7, 8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotOnConveyorBeltsFacingWallDoesNotMove() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(1, 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotBehindAnotherRobotOnConveyorBeltsFacingWallDoesNotMove() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_2, new Position(1, 2)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(1, 1)));
|
||||||
|
assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(1, 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotBehindOtherRobotsOnSlowConveyorBeltsFacingEmptyTilesMoves() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(5, 7)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_2, new Position(5, 8)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_3, new Position(5, 9)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_4, new Position(5, 10)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_3, "Player 3"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_4, "Player 4"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(5, 6)));
|
||||||
|
assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(5, 7)));
|
||||||
|
assertEquals(RobotID.ROBOT_3, board.getRobotOnPosition(new Position(5, 8)));
|
||||||
|
assertEquals(RobotID.ROBOT_4, board.getRobotOnPosition(new Position(5, 9)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotBehindOtherRobotsOnFastConveyorBeltsFacingEmptyTilesMoves() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(4, 7)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_2, new Position(4, 8)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_3, new Position(4, 9)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_4, new Position(4, 10)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_3, "Player 3"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_4, "Player 4"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(4, 5)));
|
||||||
|
assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(4, 6)));
|
||||||
|
assertEquals(RobotID.ROBOT_3, board.getRobotOnPosition(new Position(4, 7)));
|
||||||
|
assertEquals(RobotID.ROBOT_4, board.getRobotOnPosition(new Position(4, 8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotBehindOtherRobotsOnConveyorBeltsShapedAsARoundaboutMoves() {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 8)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_2, new Position(2, 8)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_3, new Position(2, 9)));
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_4, new Position(1, 9)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_2, "Player 2"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_3, "Player 3"));
|
||||||
|
players.add(new Player(RobotID.ROBOT_4, "Player 4"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(1, 9)));
|
||||||
|
assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(1, 8)));
|
||||||
|
assertEquals(RobotID.ROBOT_3, board.getRobotOnPosition(new Position(2, 8)));
|
||||||
|
assertEquals(RobotID.ROBOT_4, board.getRobotOnPosition(new Position(2, 9)));
|
||||||
|
int elapsedTime = (int) Math.floor((System.currentTimeMillis() - startTime) / 1000f);
|
||||||
|
assertTrue(elapsedTime < 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotOnConveyorBeltFacingHoleMovesAndDies() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(6, 7)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertFalse(board.isRobotAlive(RobotID.ROBOT_1));
|
||||||
|
assertNull(board.getRobotOnPosition(new Position(6, 7)));
|
||||||
|
assertNull(board.getRobotOnPosition(new Position(7, 7)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void robotOnConveyorBeltFacingOutOfMapMovesAndDies() {
|
||||||
|
List<Robot> robots = new ArrayList<>();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(7, 0)));
|
||||||
|
players.add(new Player(RobotID.ROBOT_1, "Player 1"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots);
|
||||||
|
Phase testPhase = new Phase(board, players, 0, null);
|
||||||
|
testPhase.moveAllConveyorBelts();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assertFalse(board.isRobotAlive(RobotID.ROBOT_1));
|
||||||
|
assertNull(board.getRobotOnPosition(new Position(7, 0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
33
src/test/resources/boards/another_test_map.txt
Normal file
33
src/test/resources/boards/another_test_map.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
12 16
|
||||||
|
03;1 04;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 21;7
|
||||||
|
01;1 12;3 11;3 11;3 11;3 11;3 11;3 11;3 11;3 11;3 12;5 01;1
|
||||||
|
01;1 11;1 05;3 01;1 05;3 01;1 05;7 17;1 05;7 01;1 11;5 01;1
|
||||||
|
01;1 11;1 01;1 02;1 01;1 05;3 01;1 05;7 01;1 05;7 11;5 01;1
|
||||||
|
01;1 11;1 05;3 01;1 05;3 01;1 02;1 01;1 05;7 01;1 11;5 01;1
|
||||||
|
01;1 11;1 01;1 05;3 01;1 22;7 01;1 05;7 01;1 05;7 11;5 01;1
|
||||||
|
01;1 11;1 05;3 01;1 05;3 01;1 22;7 01;1 02;1 01;1 11;5 01;1
|
||||||
|
01;1 11;1 01;1 05;3 01;1 02;1 01;1 05;7 01;1 05;7 11;5 01;1
|
||||||
|
01;1 11;1 05;3 18;1 05;3 01;1 05;7 01;1 05;7 01;1 11;5 01;1
|
||||||
|
01;1 11;1 01;1 05;3 01;1 05;3 01;1 05;7 01;1 05;7 11;5 01;1
|
||||||
|
01;1 12;1 11;7 11;7 11;7 11;7 11;7 11;7 11;7 11;7 12;7 01;1
|
||||||
|
21;7 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
||||||
|
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
||||||
|
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
||||||
|
29;1 27;1 01;1 25;1 01;1 23;1 24;1 01;1 26;1 01;1 28;1 30;1
|
||||||
|
01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1
|
||||||
|
0 0 1;1 0 1;1 0 0 1;1 0 1;1 0 0
|
||||||
|
0 0 0 1;5 0 1;5 1;5 0 1;5 0 0 0
|
||||||
|
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
||||||
|
0 1;3 0 0 0 0 0 0 0 0 1;7 0
|
||||||
|
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
||||||
|
0 1;3 0 0 0 0 0 0 0 0 1;7 0
|
||||||
|
0 1;3 0 0 0 0 0 0 0 0 1;7 0
|
||||||
|
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
||||||
|
0 1;3 0 0 0 0 0 0 0 0 1;7 0
|
||||||
|
1;7 0 0 0 0 0 0 0 0 0 0 1;3
|
||||||
|
0 0 0 1;1 0 1;1 1;1 0 1;1 0 0 0
|
||||||
|
0 0 1;5 0 1;5 0 0 1;5 0 1;5 0 0
|
||||||
|
0 0 1;1 0 1;1 0 0 1;1 0 1;1 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 1;7 0 1;7 0 1;7 1;7 1;7 0 1;7 0 1;7
|
||||||
|
0 0 1;5 0 1;5 0 0 1;5 0 1;5 0 0
|
@ -1,17 +1,17 @@
|
|||||||
12 12
|
12 12
|
||||||
01;01 05;01 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01 01;01 01;01
|
01;01 01;01 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01 01;01 01;01
|
||||||
01;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 02;01 01;01 01;01
|
01;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 02;01 01;01 01;01
|
||||||
01;01 05;03 01;01 05;07 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01
|
01;01 05;01 01;01 05;07 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 01;01 11;01 01;01 01;01 01;01 01;01 01;01 01;01
|
01;01 01;01 01;01 01;01 01;01 11;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 01;01 12;07 11;07 01;01 01;01 04;01 01;01 01;01
|
01;01 01;01 01;01 01;01 11;01 12;07 11;07 01;01 01;01 04;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
01;01 01;01 01;01 01;01 11;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 11;01 05;01 05;03 02;01 01;01 03;01 01;01 01;01
|
01;01 01;01 01;01 01;01 11;01 05;01 05;03 02;01 01;01 03;01 01;01 01;01
|
||||||
01;01 07;05 07;07 01;01 11;01 05;01 01;01 05;01 01;01 01;01 01;01 01;01
|
01;01 07;05 07;07 01;01 11;01 05;01 01;01 05;01 01;01 01;01 01;01 01;01
|
||||||
01;01 07;03 07;01 01;01 11;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01
|
01;01 07;03 07;01 01;01 11;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 11;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01
|
01;01 01;01 01;01 01;01 11;01 05;01 01;01 05;03 01;01 01;01 01;01 01;01
|
||||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01 01;01
|
||||||
0 1;1 0 0 0 0 0 0 0 0 0 0
|
0 1;5 0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user