mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-25 10:44:42 +02:00
Rydder opp i brettet og testene
Overskriver toString metoden i Position for lettere debugging Fjener removeDeadRobotsFromBoard siden den ikke ble brukt rett Flytter repeterende elementer til variabler
This commit is contained in:
@ -34,6 +34,11 @@ public class Position {
|
||||
return yCoordinate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("X: %d, Y: %d", xCoordinate, yCoordinate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj.getClass() != Position.class) {
|
||||
|
@ -85,14 +85,6 @@ public class Board {
|
||||
return getAllElementsFromGrid(walls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a dead robot from the board over to the dead robot list
|
||||
* @param robot the dead robot
|
||||
*/
|
||||
public void removeDeadRobotFromBoard(Robot robot) {
|
||||
robots.remove(robot.getRobotId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates a robot to the right
|
||||
* @param robotID The id of the robot to rotate
|
||||
@ -208,7 +200,7 @@ public class Board {
|
||||
*/
|
||||
private void killRobot(Robot robot) {
|
||||
robot.setAmountOfLives(robot.getAmountOfLives() - 1);
|
||||
removeDeadRobotFromBoard(robot);
|
||||
robots.remove(robot.getRobotId());
|
||||
deadRobots.add(robot);
|
||||
}
|
||||
|
||||
@ -304,7 +296,6 @@ public class Board {
|
||||
robot.setFacingDirection(Direction.NORTH);
|
||||
robots.put(robot.getRobotId(), robot);
|
||||
}
|
||||
else {deadRobots.remove(robot); }
|
||||
}
|
||||
deadRobots = new ArrayList<>();
|
||||
}
|
||||
|
Reference in New Issue
Block a user