Interface PieceCollection

All Known Implementing Classes:
CompoundPieceCollection, DefaultPieceCollection, LayeredPieceCollection.Collection, SimplePieceCollection

public interface PieceCollection
Manages a collection of GamePieces in a Map
  • Method Summary

    Modifier and Type Method Description
    void add​(GamePiece p)
    Adds a piece
    boolean canMerge​(GamePiece p1, GamePiece p2)
    Return true if the two pieces can be merged into a single stack
    void clear()
    Remove all pieces
    GamePiece[] getAllPieces()
    Return all pieces in the collection, regardless of visibility
    GamePiece[] getPieces()
    Return all currently-visible pieces in the collection as a read-only array
    int indexOf​(GamePiece p)
    Returns the index of a piece.
    void moveToBack​(GamePiece p)
    Reposition a piece to the back of all others in the same layer
    void moveToFront​(GamePiece p)
    Reposition a piece to the front of all others in the same layer
    void remove​(GamePiece p)
    Removes the piece
  • Method Details

    • moveToFront

      void moveToFront​(GamePiece p)
      Reposition a piece to the front of all others in the same layer
    • moveToBack

      void moveToBack​(GamePiece p)
      Reposition a piece to the back of all others in the same layer
    • getPieces

      GamePiece[] getPieces()
      Return all currently-visible pieces in the collection as a read-only array
    • getAllPieces

      GamePiece[] getAllPieces()
      Return all pieces in the collection, regardless of visibility
    • canMerge

      boolean canMerge​(GamePiece p1, GamePiece p2)
      Return true if the two pieces can be merged into a single stack
    • indexOf

      int indexOf​(GamePiece p)
      Returns the index of a piece. When painting the map, pieces are drawn in order of index
    • remove

      void remove​(GamePiece p)
      Removes the piece
    • add

      void add​(GamePiece p)
      Adds a piece
    • clear

      void clear()
      Remove all pieces