java.lang.Object
app.chess.AbstractChessPiece
- All Implemented Interfaces:
Piece
Internal game implementation of a chess piece
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChessPieceColor
protected boolean
protected boolean
protected ChessPieceKind
protected Field
protected boolean
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractChessPiece
(AbstractChessPiece toCopy) protected
AbstractChessPiece
(Field position, ChessPieceKind kind, ChessPieceColor color) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
getColor()
getKind()
int
boolean
isAlive()
(package private) void
kill()
void
void
overwriteState
(AbstractChessPiece toCopy) This function effectively copies all state from another piece.void
toString()
wrap()
Wraps this piece into ChessPiece that can be publicly exposed
-
Field Details
-
wasMoved
protected boolean wasMoved -
isBlack
protected boolean isBlack -
isAlive
protected boolean isAlive -
position
-
kind
-
color
-
-
Constructor Details
-
AbstractChessPiece
-
AbstractChessPiece
-
-
Method Details
-
overwriteState
This function effectively copies all state from another piece.
Please, use it with caution under acceptable circumstances.
Passing incompatible pieces might result in an exception. -
getPosition
- Specified by:
getPosition
in interfacePiece
- Returns:
- position this piece is located at
-
isAlive
public boolean isAlive() -
getPlayer
public int getPlayer() -
getKind
-
getColor
-
toString
-
kill
void kill() -
move
-
resetMoved
public void resetMoved() -
enPassantable
public boolean enPassantable() -
canParticipateInCastling
public boolean canParticipateInCastling() -
getPotentialMoves
- Returns:
- A list of ChessMoves that are potentially valid (i.e. the caller needs to check if king's safety is ok and whether path to the given field isn't obstructed
-
wrap
Wraps this piece into ChessPiece that can be publicly exposed- Returns:
- wrapped piece
-