King
King piece.
A king is a piece which can move of one square in any direction.
Value parameters
- c
-
The color of the piece.
- p
-
The position of the piece.
Attributes
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Available movements of the king.
Available movements of the king.
The king can go in any directions for one square. The king can also castle with one of its rooks, if it has the ability to do so.
Value parameters
- enemiesPieces
-
The enemies pieces.
- friendlyPieces
-
The allies pieces.
Attributes
- Returns
-
The list of available movements.
- Definition Classes
The king is checked if it is in any enemies pieces movements range.
The king is checked if it is in any enemies pieces movements range.
Value parameters
- enemiesPieces
-
Enemies pieces.
- friendlyPieces
-
Allies pieces.
Attributes
- Returns
-
true if the king is in check, false otherwise.
The king cannot move into check.
The king cannot move into check.
This function need to be overwritten because the king is moving.
Value parameters
- enemiesPieces
-
Enemies pieces.
- friendlyKing
-
Useless.
- friendlyPieces
-
Allies pieces.
- targetPosition
-
The target position for the king.
Attributes
- Returns
-
true if the movement is valid, false otherwise.
- Todo
-
find a way to remove friendlyKing and keeping it simple to use.
- Definition Classes
Overriding the toString method.
Overriding the toString method.
Neutral piece will be printed as blank space.
Attributes
- Returns
-
The blank space
- Definition Classes
-
Piece -> Any
Verify if the castle move is a valid one.
Verify if the castle move is a valid one.
This function verifies if the target position is correct for castleing.
It first verify if the king is checked, and if any of the square it has to move are under attack.
If not, it verifies if there is no pieces between the king and the targeted position.
Value parameters
- enemiesPieces
-
The enemies pieces.
- friendlyPieces
-
The allies pieces.
- targetPosition
-
The position on which casteling.
Attributes
- Returns
-
true if the move is valid, false otherwise.
Inherited methods
Says if a piece is able to castle.
Says if a piece is able to castle.
Attributes
- Returns
-
true if the piece can castle, false otherwise.
- Inherited from:
- Castleable
Disable the right to castle for this piece.
The color of the piece.
Move a piece.
Move a piece.
This function moves a piece by moving its given position.
Value parameters
- newColumn
-
The new position column
- newRow
-
The new position row
Attributes
- Inherited from:
- Piece
Move a piece.
Move a piece.
This function moves a piece by moving its given position.
Value parameters
- newPos
-
The new position
Attributes
- Inherited from:
- Piece
Inherited fields
Movements for long range pieces.
Movements for long range pieces.
Returns a list containing all the squares in the given direction from the piece Position until it reaches either the end of the board or a piece.
If the last square is an enemy piece, keep it to the list (because it can be captured)
Attributes
- Inherited from:
- Piece