mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
parent
cf8c04dc17
commit
417681d1e2
@ -329,6 +329,9 @@ public class Board {
|
||||
return true;
|
||||
}
|
||||
Position positionInFront = getNewPosition(conveyorBeltPosition, conveyorBeltDirection);
|
||||
if (!isValidPosition(positionInFront)) {
|
||||
return true;
|
||||
}
|
||||
Tile tileInFront = getTileOnPosition(positionInFront);
|
||||
//If a conveyor belt will move the robot outside the map, the move is valid
|
||||
if (!isValidPosition(positionInFront)) {
|
||||
@ -564,7 +567,7 @@ public class Board {
|
||||
* @param position The position to test
|
||||
* @return True if the position is valid. False otherwise
|
||||
*/
|
||||
private boolean isValidPosition(Position position) {
|
||||
public boolean isValidPosition(Position position) {
|
||||
return position.getXCoordinate() >= 0
|
||||
&& position.getXCoordinate() < boardWidth
|
||||
&& position.getYCoordinate() >= 0
|
||||
|
@ -128,10 +128,11 @@ public class Phase {
|
||||
if (!gameBoard.hasRobotOnPosition(cogwheel.getPosition())) {
|
||||
continue;
|
||||
}
|
||||
RobotID robotAtCogwheel = gameBoard.getRobotOnPosition(cogwheel.getPosition());
|
||||
if (cogwheel.getElement().getTileType() == TileType.COGWHEEL_RIGHT) {
|
||||
gameBoard.rotateRobotRight(gameBoard.getRobotOnPosition(cogwheel.getPosition()));
|
||||
gameBoard.rotateRobotRight(robotAtCogwheel);
|
||||
} else {
|
||||
gameBoard.rotateRobotLeft(gameBoard.getRobotOnPosition(cogwheel.getPosition()));
|
||||
gameBoard.rotateRobotLeft(robotAtCogwheel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,7 +270,7 @@ public class Phase {
|
||||
Map<RobotID, Position> newPositions, Map<RobotID, Boolean> moveNormally) {
|
||||
RobotID robotAtConveyorBelt = gameBoard.getRobotOnPosition(conveyorBeltPosition);
|
||||
Position newPosition = gameBoard.getNewPosition(conveyorBeltPosition, conveyorBeltDirection);
|
||||
if (gameBoard.isConveyorBelt(gameBoard.getTileOnPosition(newPosition))) {
|
||||
if (gameBoard.isValidPosition(newPosition) && gameBoard.isConveyorBelt(gameBoard.getTileOnPosition(newPosition))) {
|
||||
newPositions.put(robotAtConveyorBelt, newPosition);
|
||||
moveNormally.put(robotAtConveyorBelt, false);
|
||||
Direction newDirection = gameBoard.getTileOnPosition(newPosition).getDirection();
|
||||
|
Loading…
x
Reference in New Issue
Block a user