Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess
Class King

java.lang.Object
  extended byictk.boardgame.Piece
      extended byictk.boardgame.chess.ChessPiece
          extended byictk.boardgame.chess.King

public class King
extends ChessPiece


Field Summary
static byte INDEX
           
 
Fields inherited from class ictk.boardgame.chess.ChessPiece
BLACK_OFFSET, NULL_PIECE
 
Constructor Summary
King()
           
King(boolean blackness)
           
King(boolean blackness, Square o, ChessBoard _board)
           
 
Method Summary
 Square getKingsideCastleSquare()
          these functions are used so variants can override them
 Square getQueensideCastleSquare()
          these functions are used so variants can override them
 boolean isBlockable(Square target)
           
 boolean isBlockable(Square blocker, ChessPiece target)
          checks to see if another piece may be able to intercede between the piece's origin and destination square
 boolean isCastleableKingside()
          Checks to see if a future move can include a King-side castle.
 boolean isCastleableQueenside()
          can a future move include a Queen-side castle?
 boolean isInCheck()
          is this King currently threatened.
 boolean isKing()
           
 boolean isLegalAttack(Square target)
          same as isLegalDests except for special moves like castle and pawn moves.
 void setCastleableKingside(boolean t)
          sets the castleable bit for the Kingside.
 void setCastleableQueenside(boolean t)
          sets the castleable bit for the Queenside.
 
Methods inherited from class ictk.boardgame.chess.ChessPiece
dump, getBoard, getGuardSquares, getIndex, getLegalDests, getLineOfSight, getLineOfSight, getLineOfSight, getPinnedBy, getSquare, isBishop, isBlack, isCaptured, isGuarding, isGuarding, isKnight, isLegalDest, isPawn, isQueen, isRook, removeLegalDests, setBoard, setCaptured, toChessPiece, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEX

public static final byte INDEX
See Also:
Constant Field Values
Constructor Detail

King

public King()

King

public King(boolean blackness)

King

public King(boolean blackness,
            Square o,
            ChessBoard _board)
Method Detail

getQueensideCastleSquare

public Square getQueensideCastleSquare()
these functions are used so variants can override them


getKingsideCastleSquare

public Square getKingsideCastleSquare()
these functions are used so variants can override them


isInCheck

public boolean isInCheck()
is this King currently threatened. This will also return true if the King is also in checkmate.


isCastleableQueenside

public boolean isCastleableQueenside()
can a future move include a Queen-side castle?


isCastleableKingside

public boolean isCastleableKingside()
Checks to see if a future move can include a King-side castle. King side is always to the right of the white player, and left of the black player.


setCastleableQueenside

public void setCastleableQueenside(boolean t)
sets the castleable bit for the Queenside.

Throws:
java.lang.IllegalStateException - of there's no rook on that side to castle with.

setCastleableKingside

public void setCastleableKingside(boolean t)
sets the castleable bit for the Kingside.

Throws:
java.lang.IllegalStateException - of there's no rook on that side to castle with.

isBlockable

public boolean isBlockable(Square target)

isBlockable

public boolean isBlockable(Square blocker,
                           ChessPiece target)
Description copied from class: ChessPiece
checks to see if another piece may be able to intercede between the piece's origin and destination square

Overrides:
isBlockable in class ChessPiece
Parameters:
blocker - - the proposed square that can block the attack
target - - the piece under attack
Returns:
true - the blocker intercedes the attack

isLegalAttack

public boolean isLegalAttack(Square target)
Description copied from class: ChessPiece
same as isLegalDests except for special moves like castle and pawn moves.

Overrides:
isLegalAttack in class ChessPiece

isKing

public boolean isKing()
Overrides:
isKing in class ChessPiece

Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .