mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Opprydding i Board og TextureConverterUtil
This commit is contained in:
parent
fbbfed1932
commit
4a1e974538
@ -132,14 +132,13 @@ public class Board {
|
|||||||
if (hasRobotOnPosition(newPosition)) {
|
if (hasRobotOnPosition(newPosition)) {
|
||||||
RobotID otherRobotID = getRobotOnPosition(newPosition);
|
RobotID otherRobotID = getRobotOnPosition(newPosition);
|
||||||
if (otherRobotID != null && !moveRobot(otherRobotID, direction)) {
|
if (otherRobotID != null && !moveRobot(otherRobotID, direction)) {
|
||||||
|
//The other robot can't be shoved. Give up.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Some tiles may kill the robot if stepped on.
|
|
||||||
if (killRobotIfStepsOnDangerousTile(robot, newPosition)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
robot.setPosition(newPosition);
|
robot.setPosition(newPosition);
|
||||||
|
//Some tiles may kill the robot if stepped on.
|
||||||
|
killRobotIfStepsOnDangerousTile(robot, newPosition);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,9 +175,8 @@ public class Board {
|
|||||||
* Checks the tile the robot is about to step on and kills it if the tile is dangerous
|
* Checks the tile the robot is about to step on and kills it if the tile is dangerous
|
||||||
* @param robot The robot attempting to move
|
* @param robot The robot attempting to move
|
||||||
* @param newPosition The position the robot is attempting to move to
|
* @param newPosition The position the robot is attempting to move to
|
||||||
* @return True if the robot was killed by the tile
|
|
||||||
*/
|
*/
|
||||||
private boolean killRobotIfStepsOnDangerousTile(Robot robot, Position newPosition) {
|
private void killRobotIfStepsOnDangerousTile(Robot robot, Position newPosition) {
|
||||||
Tile tileRobotStepsOn = tiles.getElement(newPosition.getXCoordinate(), newPosition.getYCoordinate());
|
Tile tileRobotStepsOn = tiles.getElement(newPosition.getXCoordinate(), newPosition.getYCoordinate());
|
||||||
if (tileRobotStepsOn == null) {
|
if (tileRobotStepsOn == null) {
|
||||||
throw new IllegalArgumentException("The game board is missing a tile. This should not happen.");
|
throw new IllegalArgumentException("The game board is missing a tile. This should not happen.");
|
||||||
@ -186,9 +184,7 @@ public class Board {
|
|||||||
TileType tileTypeRobotStepsOn = tileRobotStepsOn.getTileType();
|
TileType tileTypeRobotStepsOn = tileRobotStepsOn.getTileType();
|
||||||
if (tileTypeRobotStepsOn == TileType.HOLE || tileTypeRobotStepsOn == TileType.DEATH_TILE) {
|
if (tileTypeRobotStepsOn == TileType.HOLE || tileTypeRobotStepsOn == TileType.DEATH_TILE) {
|
||||||
killRobot(robot);
|
killRobot(robot);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,14 +173,14 @@ public final class TextureConverterUtil {
|
|||||||
* This class serves as a temporary container for texture region coordinates
|
* This class serves as a temporary container for texture region coordinates
|
||||||
*/
|
*/
|
||||||
private static class TextureConverterContainer {
|
private static class TextureConverterContainer {
|
||||||
private int xNorth;
|
private final int xNorth;
|
||||||
private int yNorth;
|
private final int yNorth;
|
||||||
private int xEast;
|
private final int xEast;
|
||||||
private int yEast;
|
private final int yEast;
|
||||||
private int xSouth;
|
private final int xSouth;
|
||||||
private int ySouth;
|
private final int ySouth;
|
||||||
private int xWest;
|
private final int xWest;
|
||||||
private int yWest;
|
private final int yWest;
|
||||||
|
|
||||||
TextureConverterContainer(int xNorth, int yNorth, int xEast, int yEast, int xSouth, int ySouth,
|
TextureConverterContainer(int xNorth, int yNorth, int xEast, int yEast, int xSouth, int ySouth,
|
||||||
int xWest, int yWest) {
|
int xWest, int yWest) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user