ChessPiece
in package
Table of Contents
Constants
Properties
Methods
- __construct() : mixed
- getLetterForPiece() : string
- getPieceForLetter() : self::*
- getPieceLetter() : string
- getPieceSymbol() : string
- getPossibleMoves() : array<string|int, array{: int, : int}>
- 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
$pieceID
public
int
$pieceID
$x
public
int
$x
$y
public
int
$y
Methods
__construct()
public
__construct(Colour $colour, int $pieceID, int $x, int $y) : mixed
Parameters
- $colour : Colour
- $pieceID : int
- $x : int
- $y : int
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, array{: int, : int}>
Parameters
- $board : Board
- $attackingCheck : bool = false
Return values
array<string|int, array{: int, : int}>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, int $x, int $y) : bool
Parameters
- $board : Board
- $x : int
- $y : int
Return values
boolisSafeMove()
public
isSafeMove(Board $board, int $toX, int $toY) : bool
Parameters
- $board : Board
- $toX : int
- $toY : int
Return values
booladdMove()
private
addMove(int $toX, int $toY, Board $board, array<int, array{: int, : int}> &$moves[, bool $attackingCheck = true ]) : bool
Parameters
- $toX : int
- $toY : int
- $board : Board
- $moves : array<int, array{: int, : int}>
- $attackingCheck : bool = true