ChessPiece
in package
Table of Contents
Constants
Properties
Methods
- __construct() : mixed
- getLetterForPiece() : string
- getPieceForLetter() : self::*
- getPieceLetter() : string
- getPieceSymbol() : string
- getPossibleMoves() : array<string|int, Loc>
- getSymbolForPiece() : string
- isAttacking() : bool
- Check if the piece is attacking a specific square
- isSafeMove() : bool
- addMove() : bool
Constants
BISHOP
public
mixed
BISHOP
= 4
KING
public
mixed
KING
= 1
KNIGHT
public
mixed
KNIGHT
= 5
PAWN
public
mixed
PAWN
= 6
QUEEN
public
mixed
QUEEN
= 2
ROOK
public
mixed
ROOK
= 3
Properties
$colour read-only
public
Colour
$colour
$loc
public
Loc
$loc
$pieceID
public
int
$pieceID
Methods
__construct()
public
__construct(Colour $colour, int $pieceID, Loc $loc) : mixed
Parameters
getLetterForPiece()
public
static getLetterForPiece(int $pieceID, Colour $colour) : string
Parameters
- $pieceID : int
- $colour : Colour
Return values
stringgetPieceForLetter()
public
static getPieceForLetter(string $letter) : self::*
Parameters
- $letter : string
Return values
self::*getPieceLetter()
public
getPieceLetter() : string
Return values
stringgetPieceSymbol()
public
getPieceSymbol() : string
Return values
stringgetPossibleMoves()
public
getPossibleMoves(Board $board[, bool $attackingCheck = false ]) : array<string|int, Loc>
Parameters
- $board : Board
- $attackingCheck : bool = false
Return values
array<string|int, Loc>getSymbolForPiece()
public
static getSymbolForPiece(int $pieceID, Colour $colour) : string
Parameters
- $pieceID : int
- $colour : Colour
Return values
stringisAttacking()
Check if the piece is attacking a specific square
public
isAttacking(Board $board, Loc $loc) : bool
Parameters
Return values
boolisSafeMove()
public
isSafeMove(Board $board, Loc $toLoc) : bool
Parameters
Return values
booladdMove()
private
addMove(int $dx, int $dy, Board $board, array<int, Loc> &$moves[, bool $attackingCheck = true ]) : bool