mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-01 07:39:35 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
commit
cf3012b78f
@ -414,9 +414,9 @@ public class RoboRallyGame implements IDrawableGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* repair all robots standing on a reparer tile
|
* repair all robots standing on a repair tile
|
||||||
*/
|
*/
|
||||||
private void repairAllRobotsOnReparerTiles(){
|
private void repairAllRobotsOnRepairTiles(){
|
||||||
List<BoardElementContainer<Tile>> listOfRepareTiles = gameBoard.getPositionsOfTileOnBoard(TileType.FLAG_1,
|
List<BoardElementContainer<Tile>> listOfRepareTiles = gameBoard.getPositionsOfTileOnBoard(TileType.FLAG_1,
|
||||||
TileType.FLAG_2, TileType.FLAG_3, TileType.FLAG_4, TileType.WRENCH, TileType.WRENCH_AND_HAMMER);
|
TileType.FLAG_2, TileType.FLAG_3, TileType.FLAG_4, TileType.WRENCH, TileType.WRENCH_AND_HAMMER);
|
||||||
for (BoardElementContainer<Tile> repareTile:listOfRepareTiles) {
|
for (BoardElementContainer<Tile> repareTile:listOfRepareTiles) {
|
||||||
@ -437,4 +437,13 @@ public class RoboRallyGame implements IDrawableGame {
|
|||||||
player.setPowerDownNextRound(false);
|
player.setPowerDownNextRound(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the powerdown status of a robots
|
||||||
|
* @param player the player that owns the robot
|
||||||
|
* @param powerdownStatus the powerdown status
|
||||||
|
*/
|
||||||
|
private void setRobotPowerDown(Player player,Boolean powerdownStatus){
|
||||||
|
gameBoard.setPowerDown(player.getRobotID(),powerdownStatus);
|
||||||
|
}
|
||||||
}
|
}
|
@ -39,6 +39,8 @@ public class BoardTest {
|
|||||||
private final Map<TileType,Integer> tileTypeNumberMap = new HashMap<>();
|
private final Map<TileType,Integer> tileTypeNumberMap = new HashMap<>();
|
||||||
private List<Robot> robotListforlaser;
|
private List<Robot> robotListforlaser;
|
||||||
private Board boardforlaser;
|
private Board boardforlaser;
|
||||||
|
private List<Robot> robotListforpowerdown;
|
||||||
|
private Board boardforpowerdown;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void globalSetUp() {
|
public static void globalSetUp() {
|
||||||
@ -56,6 +58,19 @@ public class BoardTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
||||||
|
Grid<Tile> tileGridforpowerdown = new Grid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
||||||
|
Grid<Wall> wallGridforpowerdown = new Grid<>(8, 8);
|
||||||
|
robotListforpowerdown = new ArrayList<>();
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_1, new Position(2,1)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_2, new Position(4,0)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_3, new Position(4,1)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_4, new Position(1,7)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_5, new Position(0,4)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_6, new Position(0,5)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_7, new Position(7,0)));
|
||||||
|
robotListforpowerdown.add(new Robot(RobotID.ROBOT_8, new Position(1,1)));
|
||||||
|
boardforpowerdown = new Board(tileGridforpowerdown, wallGridforpowerdown, robotListforpowerdown);
|
||||||
|
|
||||||
Grid<Tile> tileGridforlaser = new Grid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
Grid<Tile> tileGridforlaser = new Grid<>(8, 8, new Tile(TileType.TILE, Direction.NORTH));
|
||||||
Grid<Wall> wallGridforlaser = new Grid<>(8, 8);
|
Grid<Wall> wallGridforlaser = new Grid<>(8, 8);
|
||||||
robotListforlaser = new ArrayList<>();
|
robotListforlaser = new ArrayList<>();
|
||||||
@ -123,6 +138,30 @@ public class BoardTest {
|
|||||||
boardWithDifferentAmountOfAllTypes = new Board(tileGridAllTypes,wallGridAllTypes,emptyRobotList);
|
boardWithDifferentAmountOfAllTypes = new Board(tileGridAllTypes,wallGridAllTypes,emptyRobotList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void setRobotPowerDownStatus(){
|
||||||
|
Robot testrobot = robotListforpowerdown.get(0);
|
||||||
|
assertEquals(false , testrobot.isInPowerDown());
|
||||||
|
boardforpowerdown.setPowerDown(RobotID.ROBOT_1,true);
|
||||||
|
assertEquals(true , testrobot.isInPowerDown());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void executRobotPowerDown(){
|
||||||
|
Robot testrobot = robotListforpowerdown.get(1);
|
||||||
|
boardforpowerdown.setPowerDown(RobotID.ROBOT_2,true);
|
||||||
|
testrobot.setDamageTaken(4);
|
||||||
|
assertEquals(4,testrobot.getDamageTaken());
|
||||||
|
boardforpowerdown.executePowerdown();
|
||||||
|
assertEquals(0,testrobot.getDamageTaken());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void repairRobotOnRepairTile(){
|
||||||
|
Robot testrobot = robotListforpowerdown.get(2);
|
||||||
|
testrobot.setDamageTaken(4);
|
||||||
|
assertEquals(4,testrobot.getDamageTaken());
|
||||||
|
boardforpowerdown.repairRobotOnTile(RobotID.ROBOT_3);
|
||||||
|
assertEquals(3,testrobot.getDamageTaken());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void robotHitByLaserGetsDamaged(){
|
public void robotHitByLaserGetsDamaged(){
|
||||||
@ -155,9 +194,7 @@ public class BoardTest {
|
|||||||
assertEquals(0, testRobot.getDamageTaken());
|
assertEquals(0, testRobot.getDamageTaken());
|
||||||
boardforlaser.fireAllLasers();
|
boardforlaser.fireAllLasers();
|
||||||
assertEquals(2,testRobot.getDamageTaken());
|
assertEquals(2,testRobot.getDamageTaken());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void robotGetsHitByTwoLasers(){
|
public void robotGetsHitByTwoLasers(){
|
||||||
Robot testRobot = robotListforlaser.get(3);
|
Robot testRobot = robotListforlaser.get(3);
|
||||||
@ -165,9 +202,6 @@ public class BoardTest {
|
|||||||
boardforlaser.fireAllLasers();
|
boardforlaser.fireAllLasers();
|
||||||
assertEquals(2, testRobot.getDamageTaken());
|
assertEquals(2, testRobot.getDamageTaken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void robotDamageEachOther() {
|
public void robotDamageEachOther() {
|
||||||
Robot robot5 = robotListforlaser.get(4);
|
Robot robot5 = robotListforlaser.get(4);
|
||||||
@ -179,9 +213,6 @@ public class BoardTest {
|
|||||||
assertEquals(1, robot5.getDamageTaken());
|
assertEquals(1, robot5.getDamageTaken());
|
||||||
assertEquals(2, robot6.getDamageTaken());
|
assertEquals(2, robot6.getDamageTaken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void robotStandingOnLaserTakesDamage() {
|
public void robotStandingOnLaserTakesDamage() {
|
||||||
Robot robot6 = robotListforlaser.get(5);
|
Robot robot6 = robotListforlaser.get(5);
|
||||||
@ -189,11 +220,6 @@ public class BoardTest {
|
|||||||
boardforlaser.fireAllLasers();
|
boardforlaser.fireAllLasers();
|
||||||
assertEquals(1, robot6.getDamageTaken());
|
assertEquals(1, robot6.getDamageTaken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void flagGetsUpdatedOnRobotWithCorrectLastVisitedFlag() {
|
public void flagGetsUpdatedOnRobotWithCorrectLastVisitedFlag() {
|
||||||
Robot testRobot = robotList.get(6);
|
Robot testRobot = robotList.get(6);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user