Class Piece

java.lang.Object
com.amirhn.Pieces.Piece
Direct Known Subclasses:
Bishop, King, Knight, Pawn, Queen, Rook

public abstract class Piece extends Object
The type Piece.
  • Field Details

    • type

      public final PieceType type
      The Type.
    • color

      public final Color color
      The Color.
    • location

      protected Location location
      The Location.
    • moves

      protected int moves
      The Moves.
  • Constructor Details

    • Piece

      public Piece(PieceType type, Color color, Location location)
      Instantiates a new Piece.
      Parameters:
      type - the type
      color - the color
      location - the location
  • Method Details

    • generate

      public static Piece generate(PieceType pieceType, Color color, Location location)
      Generate piece.
      Parameters:
      pieceType - the piece type
      color - the color
      location - the location
      Returns:
      the piece
    • generate

      public static Piece generate(char fen, Location location)
      Generate piece.
      Parameters:
      fen - the fen
      location - the location
      Returns:
      the piece
    • getLocation

      public Location getLocation()
      Gets location.
      Returns:
      the location
    • setLocation

      public void setLocation(Location location)
      Sets location.
      Parameters:
      location - the location
    • setLocationBack

      public void setLocationBack(Location location)
      Sets location back.
      Parameters:
      location - the location
    • removeLocation

      public void removeLocation()
      Remove location.
    • hasMoved

      public boolean hasMoved()
      Has moved boolean.
      Returns:
      the boolean
    • equals

      public boolean equals(Object o)
      Equals boolean.
      Overrides:
      equals in class Object
      Parameters:
      o - the o
      Returns:
      the boolean
    • hashCode

      public int hashCode()
      Hash code int.
      Overrides:
      hashCode in class Object
      Returns:
      the int
    • toString

      public String toString()
      To string string.
      Overrides:
      toString in class Object
      Returns:
      the string
    • isAllowedToMove

      public boolean isAllowedToMove(Chess chess)
      Is allowed to move boolean.
      Parameters:
      chess - the chess
      Returns:
      the boolean
    • getAllowedMoves

      public List<Move> getAllowedMoves(Chess chess)
      Gets allowed moves.
      Parameters:
      chess - the chess
      Returns:
      the allowed moves
    • canBeCapturedBy

      public boolean canBeCapturedBy(Piece piece)
      Can be captured by boolean.
      Parameters:
      piece - the piece
      Returns:
      the boolean
    • getSymbol

      public char getSymbol()
      Gets symbol.
      Returns:
      the symbol
    • getThreatenedLocations

      public abstract List<Location> getThreatenedLocations(Board board)
      Gets threatened locations.
      Parameters:
      board - the board
      Returns:
      the threatened locations
    • getNaturalMoves

      public List<Move> getNaturalMoves(Board board)
      Gets natural moves.
      Parameters:
      board - the board
      Returns:
      the natural moves
    • copy

      public Piece copy()
      Copy piece.
      Returns:
      the piece