public class Board
extends java.lang.Object
Constructor and Description |
---|
Board(Grid<Tile> tiles,
Grid<Wall> walls,
java.util.List<Robot> robots)
Initializes the board
|
Modifier and Type | Method and Description |
---|---|
boolean |
conveyorBeltCanMove(BoardElementContainer<Tile> conveyorBelt,
int iterations)
Checks whether a given conveyor belt is able to move in its direction
|
void |
doLaserCleanup()
Does necessary cleanup after lasers have been fired
|
void |
executePowerDown()
Sets the damage taken of robots in power down to 0
|
void |
fireAllLasers()
Fires all lasers on the board and kills any robot that has taken to much damage after all lasers have fired.
|
java.util.List<Robot> |
getAliveRobots()
Gets all alive robots from the board
|
java.util.List<Robot> |
getAllRobots()
Gets all robots from the board
|
int |
getBoardHeight()
Gets the height of the board
|
int |
getBoardWidth()
Gets the width of the board
|
int |
getLastFlagVisited(RobotID robotID)
Gets the int corresponding to the flag a robot has last visited
|
Position |
getNewPosition(Position oldPosition,
Direction direction)
Gets the position 1 unit in a specific direction from another position
|
java.util.List<Particle> |
getParticles()
Gets all the particles from the board
|
java.util.List<BoardElementContainer<Tile>> |
getPositionsOfTilesOnBoard(TileType... tiles)
Gets a list of BoardElementContainers, containing all tiles and positions of given tile types
|
java.util.List<BoardElementContainer<Wall>> |
getPositionsOfWallsOnBoard(WallType... walls)
Gets a list of BoardElementContainers, containing all tiles and positions of given wall types
|
boolean |
getPowerDown(RobotID robotID)
Gets the power down status of the robot
|
java.util.List<RobotID> |
getRealDeadRobots()
Gets a list of robots no longer part of the game
|
int |
getRobotDamage(RobotID robot)
Get the damage of a specific robot
|
RobotID |
getRobotOnPosition(Position position)
Returns a robot id for a robot on a specific position if such a robot exists
|
Tile |
getTileOnPosition(Position position)
Gets the tile on a specific position
|
java.util.List<Tile> |
getTiles()
Gets all the tiles from the board
|
java.util.List<Wall> |
getWalls()
Gets all the walls from the board
|
boolean |
hasRobotOnPosition(Position position)
Checks whether there exists a robot on a specific position
|
boolean |
hasTouchedFlagThisTurn(RobotID robotID)
Checks a boolean for if the robot has touched a flag this turn
|
boolean |
isConveyorBelt(Tile tile)
Checks whether a given tile is a conveyor belt
|
boolean |
isRobotAlive(RobotID robot)
Checks if a specific robot is currently alive on the board
|
boolean |
isValidPosition(Position position)
Checks whether a given position is valid
|
boolean |
moveRobot(RobotID robotID,
Direction direction)
Moves a robot one unit in a specified direction
|
void |
moveRobotForward(RobotID robotID)
Moves a robot one unit forward according to the direction it's currently facing
|
void |
repairRobotOnTile(RobotID robotID)
Removes one damage for a given robot given that it has taken som damage before
|
void |
respawnRobots()
Moves all dead robots to their backups and makes them part of the board again, and if a robot has no lives
it will be removed from the game.
|
void |
reverseRobot(RobotID robotID)
Moves a robot one unit backwards according to the direction it's currently facing
|
void |
rotateRobotLeft(RobotID robotID)
Rotates a robot to the right
|
void |
rotateRobotRight(RobotID robotID)
Rotates a robot to the left
|
void |
setBackupPositionOfRobot(RobotID robotID,
Position position)
Sets the backup position of a given robot to a given position
|
void |
setHasTouchedFlagThisTurn(RobotID robotID,
boolean hasTouched)
Sets a boolean for if the robot has touched a flag this turn
|
void |
setPowerDown(RobotID robotID,
java.lang.Boolean powerDown)
Sets the power down status of the robot
|
void |
teleportRobot(RobotID robotID,
Position newPosition)
Teleports a robot to some position without verification
Be quite careful about using this method.
|
void |
updateRobotBackups()
Updates backup position of all robots on a repair tile
|
void |
updateRobotFlag(RobotID robotID,
BoardElementContainer<Tile> flag)
Updates the flag of the robot if it stands on the correct flag.
|
public java.util.List<RobotID> getRealDeadRobots()
public int getBoardHeight()
public int getBoardWidth()
public java.util.List<Robot> getAliveRobots()
public java.util.List<Robot> getAllRobots()
public java.util.List<Tile> getTiles()
public java.util.List<Wall> getWalls()
public java.util.List<Particle> getParticles()
public void rotateRobotLeft(RobotID robotID)
robotID
- The id of the robot to rotatepublic void rotateRobotRight(RobotID robotID)
robotID
- The id of the robot to rotatepublic void moveRobotForward(RobotID robotID)
robotID
- The robot to movepublic void reverseRobot(RobotID robotID)
robotID
- The robot to movepublic void setPowerDown(RobotID robotID, java.lang.Boolean powerDown)
robotID
- The robot id of the robotpowerDown
- The status of the power downpublic void setBackupPositionOfRobot(RobotID robotID, Position position)
robotID
- The robot to change backup position forposition
- The robot's new backup positionpublic boolean getPowerDown(RobotID robotID)
robotID
- The robot id of the robotpublic void repairRobotOnTile(RobotID robotID)
robotID
- the ID of the robotpublic void executePowerDown()
public int getRobotDamage(RobotID robot)
robot
- The RobotID of a robotpublic boolean moveRobot(RobotID robotID, Direction direction)
robotID
- Id of the robot to movedirection
- The direction to move the robotpublic boolean isConveyorBelt(Tile tile)
tile
- The tile to checkpublic void teleportRobot(RobotID robotID, Position newPosition)
Be quite careful about using this method. No validation will me done. The robot will magically disappear from one position and appear on another, hence the name. This method should only be used when the new position has been confirmed available.
robotID
- The id of the robot to teleportnewPosition
- The position the robot should teleport topublic boolean conveyorBeltCanMove(BoardElementContainer<Tile> conveyorBelt, int iterations)
conveyorBelt
- The conveyor belt to moveiterations
- The number of recursive calls already executedpublic void respawnRobots()
public void updateRobotBackups()
public RobotID getRobotOnPosition(Position position)
position
- The position to checkpublic boolean isRobotAlive(RobotID robot)
robot
- the ID of the robot you want to checkpublic void updateRobotFlag(RobotID robotID, BoardElementContainer<Tile> flag)
robotID
- The RobotID of a robotflag
- BoardElementContainer of the flag we checkpublic Position getNewPosition(Position oldPosition, Direction direction)
oldPosition
- The old/current position of the elementdirection
- The direction to move the elementpublic void fireAllLasers()
public void doLaserCleanup()
public Tile getTileOnPosition(Position position)
position
- The position to get a tile frompublic java.util.List<BoardElementContainer<Tile>> getPositionsOfTilesOnBoard(TileType... tiles)
tiles
- The tiles you want all positions forpublic java.util.List<BoardElementContainer<Wall>> getPositionsOfWallsOnBoard(WallType... walls)
walls
- The walls you want all positions forpublic boolean hasRobotOnPosition(Position position)
position
- The position to checkpublic boolean isValidPosition(Position position)
position
- The position to testpublic int getLastFlagVisited(RobotID robotID)
robotID
- The robot to be checkedpublic void setHasTouchedFlagThisTurn(RobotID robotID, boolean hasTouched)
robotID
- The robot to be checkedhasTouched
- If the robot has touched a flag this turnpublic boolean hasTouchedFlagThisTurn(RobotID robotID)
robotID
- The robot to be checked