mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-07-26 01:35:28 +02:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
@@ -329,16 +329,18 @@ public class Board {
|
||||
return true;
|
||||
}
|
||||
Position positionInFront = getNewPosition(conveyorBeltPosition, conveyorBeltDirection);
|
||||
Tile tileInFront = getTileOnPosition(positionInFront);
|
||||
//The tile in front of the robot is not a conveyor belt and has something on it stopping the conveyor belt
|
||||
if ((!isValidPosition(positionInFront) && moveIsStoppedByWall(conveyorBeltPosition, positionInFront,
|
||||
conveyorBeltDirection)) || (isValidPosition(positionInFront) &&
|
||||
!isConveyorBelt(getTileOnPosition(positionInFront)) &&
|
||||
hasFrontConflict(conveyorBeltPosition, positionInFront, conveyorBeltDirection))) {
|
||||
return false;
|
||||
}
|
||||
//If a conveyor belt will move the robot outside the map, the move is valid
|
||||
if (!isValidPosition(positionInFront)) {
|
||||
return true;
|
||||
}
|
||||
//The tile in front of the robot is not a conveyor belt and has something on it stopping the conveyor belt
|
||||
if (!isConveyorBelt(tileInFront) &&
|
||||
hasFrontConflict(conveyorBeltPosition, positionInFront, conveyorBeltDirection)) {
|
||||
return false;
|
||||
}
|
||||
Tile tileInFront = getTileOnPosition(positionInFront);
|
||||
//There is another robot trying to enter the same crossing
|
||||
if (hasCrossingConflict(positionInFront, conveyorBeltDirection)) {
|
||||
return false;
|
||||
@@ -564,7 +566,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
|
||||
|
@@ -57,4 +57,11 @@ public interface DrawableGame {
|
||||
* @return A list of all robots to draw
|
||||
*/
|
||||
List<Robot> getRobotsToDraw();
|
||||
|
||||
/**
|
||||
* Gets a list of active players to receive information about player names
|
||||
*
|
||||
* @return A list of players
|
||||
*/
|
||||
List<Player> getPlayers();
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ public class Phase {
|
||||
* @throws InterruptedException If interrupted wile trying to sleep
|
||||
*/
|
||||
public void runPhase(int phaseNumber) throws InterruptedException {
|
||||
sleep();
|
||||
runProgrammingCards(phaseNumber);
|
||||
|
||||
moveAllConveyorBelts();
|
||||
@@ -83,6 +84,7 @@ public class Phase {
|
||||
* @throws InterruptedException If it gets interrupted while trying to sleep
|
||||
*/
|
||||
public void fireAllLasers() throws InterruptedException {
|
||||
sleep();
|
||||
gameBoard.fireAllLasers();
|
||||
sleep();
|
||||
gameBoard.doLaserCleanup();
|
||||
@@ -121,15 +123,16 @@ public class Phase {
|
||||
* @throws InterruptedException If interrupted while sleeping.
|
||||
*/
|
||||
public void rotateCogwheels() throws InterruptedException {
|
||||
sleep();
|
||||
for (BoardElementContainer<Tile> cogwheel : cogwheels) {
|
||||
if (!gameBoard.hasRobotOnPosition(cogwheel.getPosition())) {
|
||||
continue;
|
||||
}
|
||||
sleep();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,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();
|
||||
|
@@ -114,6 +114,11 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
return gameBoard.getAliveRobots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getPlayers() {
|
||||
return new ArrayList<>(this.playerList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameState getGameState() {
|
||||
return gameState;
|
||||
|
Reference in New Issue
Block a user