mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-01 07:39:35 +01:00
Splitter opp moveConveyorBelts for bedre leselighet
This commit is contained in:
parent
ee753764eb
commit
49ee7dc896
@ -263,11 +263,24 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
Tile nextTile = gameBoard.getTileOnPosition(newPosition);
|
||||
|
||||
Direction currentDirection = conveyorBeltTile.getDirection();
|
||||
Direction nextDirection = nextTile.getDirection();
|
||||
RobotID robot = gameBoard.getRobotOnPosition(conveyorBeltPosition);
|
||||
|
||||
//TODO: Check whether the robot is able to move before moving. Alternatively: Save position and direction
|
||||
// of each robot and revert if a collision is found.
|
||||
doConveyorBeltMovement(robot, currentDirection, nextTile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a robot standing on a conveyor belt
|
||||
* @param robot The id of the robot to move
|
||||
* @param currentDirection The direction of the conveyor belt the robot is standing on
|
||||
* @param nextTile The tile the robot is moving to
|
||||
* @throws InterruptedException If disturbed during sleep
|
||||
*/
|
||||
private void doConveyorBeltMovement(RobotID robot, Direction currentDirection, Tile nextTile)
|
||||
throws InterruptedException {
|
||||
Direction nextDirection = nextTile.getDirection();
|
||||
sleep();
|
||||
gameBoard.moveRobot(robot, currentDirection);
|
||||
if (testPredicate(conveyorBelts, (container) -> container.getObject() == nextTile)) {
|
||||
@ -280,7 +293,6 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks all flags for robots. Tries to update the flag of the robot.
|
||||
|
Loading…
x
Reference in New Issue
Block a user