Class TileLayer

java.lang.Object
com.takenoko.layers.tile.TileLayer

public class TileLayer extends Object
The TileLayer class is used to manage the tiles on the board.
  • Field Details

  • Constructor Details

    • TileLayer

      public TileLayer()
      Create a new TileLayer.
    • TileLayer

      public TileLayer(TileLayer tileLayer)
  • Method Details

    • placeTile

      public LayerBambooStack placeTile(Tile tile, PositionVector position, Board board)
      Place a tile on the board. and update the available tiles and the available tile positions.
      Parameters:
      tile - the tile to add to the board
      position - the position of the tile
      board - the board
      Returns:
      the LayerBambooStack at the position of the tile
    • updateAvailableTilePositions

      private void updateAvailableTilePositions(PositionVector position)
      Update the available tile positions after placing a tile.
      Parameters:
      position - the position of the tile to remove
    • isPositionAvailable

      private boolean isPositionAvailable(PositionVector position)
      Check if a position is available. A position is available if: - it is not already occupied by a tile - it has at least 2 neighbors or 1 neighbor is a pond
      Parameters:
      position - the position to check
    • getTiles

      public Map<PositionVector,Tile> getTiles()
      Get the tiles on the board.
      Returns:
      the tiles on the board
    • getAvailableTilePositions

      public List<PositionVector> getAvailableTilePositions()
      Get the available tiles.
      Returns:
      the available tiles
    • getAvailableTiles

      public List<Tile> getAvailableTiles()
      Get the available tiles.
      Returns:
      the list of available tiles
    • getAvailableImprovementPositions

      public List<PositionVector> getAvailableImprovementPositions(Board board)
      Get the positions where an improvement can be placed.
      Returns:
      the positions where an improvement can be placed
    • getTilesWithoutPond

      public Map<PositionVector,Tile> getTilesWithoutPond()
      Get the tile placed on the board but without the pond.
      Returns:
      the tile placed on the board but without the pond.
    • isTile

      public boolean isTile(PositionVector position)
      Check if there is a tile at the given position.
      Parameters:
      position - the position of the tile
      Returns:
      if there is a tile at the position
    • getTileAt

      public Tile getTileAt(PositionVector positionVector)
      Return the tile at the given position.
      Parameters:
      positionVector - the position of the tile
      Returns:
      the tile at the given position
    • copy

      public TileLayer copy()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • applyImprovement

      public void applyImprovement(ImprovementType improvementType, PositionVector positionVector, Board board)