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)) {
|
||||
RobotID otherRobotID = getRobotOnPosition(newPosition);
|
||||
if (otherRobotID != null && !moveRobot(otherRobotID, direction)) {
|
||||
//The other robot can't be shoved. Give up.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Some tiles may kill the robot if stepped on.
|
||||
if (killRobotIfStepsOnDangerousTile(robot, newPosition)) {
|
||||
return true;
|
||||
}
|
||||
robot.setPosition(newPosition);
|
||||
//Some tiles may kill the robot if stepped on.
|
||||
killRobotIfStepsOnDangerousTile(robot, newPosition);
|
||||
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
|
||||
* @param robot The robot attempting to move
|
||||
* @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());
|
||||
if (tileRobotStepsOn == null) {
|
||||
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();
|
||||
if (tileTypeRobotStepsOn == TileType.HOLE || tileTypeRobotStepsOn == TileType.DEATH_TILE) {
|
||||
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
|
||||
*/
|
||||
private static class TextureConverterContainer {
|
||||
private int xNorth;
|
||||
private int yNorth;
|
||||
private int xEast;
|
||||
private int yEast;
|
||||
private int xSouth;
|
||||
private int ySouth;
|
||||
private int xWest;
|
||||
private int yWest;
|
||||
private final int xNorth;
|
||||
private final int yNorth;
|
||||
private final int xEast;
|
||||
private final int yEast;
|
||||
private final int xSouth;
|
||||
private final int ySouth;
|
||||
private final int xWest;
|
||||
private final int yWest;
|
||||
|
||||
TextureConverterContainer(int xNorth, int yNorth, int xEast, int yEast, int xSouth, int ySouth,
|
||||
int xWest, int yWest) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user