Documentation

ChessGame
in package

Table of Contents

Constants

END_CANCEL  : int = 1
END_RESIGN  : int = 0

Properties

$CACHE_CHESS_GAMES  : array<int, self>
$blackPlayerID  : int
$board  : Board
$chessGameID  : int
$endDate  : int|null
$gameID  : int
$lastMove  : Loc}|null
$moves  : array<string|int, string>
$startDate  : int
$whitePlayerID  : int
$winnerPlayerID  : int

Methods

__construct()  : mixed
getBlackPlayer()  : Player
getBlackPlayerID()  : int
getBoard()  : Board
getChessGame()  : self
getChessGameID()  : int
getColourForPlayerID()  : Colour
getColourPlayer()  : Player
getColourPlayerID()  : int
getCurrentTurnColour()  : Colour
getCurrentTurnPlayer()  : Player
getCurrentTurnPlayerID()  : int
getGameID()  : int
getLastMove()  : Loc}|null
getMoves()  : array<string|int, string>
getNPCMoveGames()  : array<string|int, self>
getOngoingPlayerGames()  : array<string|int, self>
getPlayGameHREF()  : string
getResignHREF()  : string
getStandardGame()  : array<string|int, ChessPiece>
getStartDate()  : int
getWhitePlayer()  : Player
getWhitePlayerID()  : int
getWinnerPlayerID()  : int
hasEnded()  : bool
hasWinner()  : bool
insertNewGame()  : void
isCastling()  : Loc}|false
isCurrentTurn()  : bool
isLastMoveSquare()  : bool
Determines if a board square is part of the last move (returns true for both the 'To' and 'From' squares).
isNPCGame()  : bool
isPlayer()  : bool
Is the given player ID one of the two players of this game?
resign()  : self::END_*
setDraw()  : void
setWinner()  : void
tryAlgebraicMove()  : void
tryMove()  : string
createMove()  : string
updateEndedGame()  : void

Constants

Properties

$CACHE_CHESS_GAMES

protected static array<int, self> $CACHE_CHESS_GAMES = []

$blackPlayerID read-only

private int $blackPlayerID

$chessGameID read-only

private int $chessGameID

$lastMove

private Loc}|null $lastMove = null

$moves

private array<string|int, string> $moves

$whitePlayerID read-only

private int $whitePlayerID

Methods

__construct()

public __construct(int $chessGameID) : mixed
Parameters
$chessGameID : int

getBlackPlayerID()

public getBlackPlayerID() : int
Return values
int

getChessGame()

public static getChessGame(int $chessGameID[, bool $forceUpdate = false ]) : self
Parameters
$chessGameID : int
$forceUpdate : bool = false
Return values
self

getChessGameID()

public getChessGameID() : int
Return values
int

getColourForPlayerID()

public getColourForPlayerID(int $playerID) : Colour
Parameters
$playerID : int
Return values
Colour

getColourPlayerID()

public getColourPlayerID(Colour $colour) : int
Parameters
$colour : Colour
Return values
int

getCurrentTurnPlayerID()

public getCurrentTurnPlayerID() : int
Return values
int

getGameID()

public getGameID() : int
Return values
int

getLastMove()

public getLastMove() : Loc}|null
Return values
Loc}|null

getMoves()

public getMoves() : array<string|int, string>
Return values
array<string|int, string>

getNPCMoveGames()

public static getNPCMoveGames([bool $forceUpdate = false ]) : array<string|int, self>
Parameters
$forceUpdate : bool = false
Return values
array<string|int, self>

getOngoingPlayerGames()

public static getOngoingPlayerGames(Player $player) : array<string|int, self>
Parameters
$player : Player
Return values
array<string|int, self>

getPlayGameHREF()

public getPlayGameHREF() : string
Return values
string

getResignHREF()

public getResignHREF() : string
Return values
string

getStartDate()

public getStartDate() : int
Return values
int

getWhitePlayerID()

public getWhitePlayerID() : int
Return values
int

getWinnerPlayerID()

public getWinnerPlayerID() : int
Return values
int

hasEnded()

public hasEnded() : bool
Return values
bool

hasWinner()

public hasWinner() : bool
Return values
bool

insertNewGame()

public static insertNewGame(int $startDate, Player $whitePlayer, Player $blackPlayer) : void
Parameters
$startDate : int
$whitePlayer : Player
$blackPlayer : Player

isCastling()

public static isCastling(Loc $loc, Loc $toLoc) : Loc}|false
Parameters
$loc : Loc
$toLoc : Loc
Return values
Loc}|false

isCurrentTurn()

public isCurrentTurn(int $playerID) : bool
Parameters
$playerID : int
Return values
bool

isLastMoveSquare()

Determines if a board square is part of the last move (returns true for both the 'To' and 'From' squares).

public isLastMoveSquare(Loc $loc) : bool
Parameters
$loc : Loc
Return values
bool

isNPCGame()

public isNPCGame() : bool
Return values
bool

isPlayer()

Is the given player ID one of the two players of this game?

public isPlayer(int $playerID) : bool
Parameters
$playerID : int
Return values
bool

resign()

public resign(int $playerID) : self::END_*
Parameters
$playerID : int
Return values
self::END_*

tryAlgebraicMove()

public tryAlgebraicMove(string $move) : void
Parameters
$move : string

Algebraic notation like "b2b4"

tryMove()

public tryMove(Loc $loc, Loc $toLoc, Colour $forColour, int $pawnPromotionPiece) : string
Parameters
$loc : Loc
$toLoc : Loc
$forColour : Colour
$pawnPromotionPiece : int
Return values
string

createMove()

private createMove(int $pieceID, Loc $startLoc, Loc $endLoc, int|null $pieceTaken, string|null $checking, Colour $playerColour, Castling|null $castling, bool $enPassant, int|null $promotionPieceID, bool $draw) : string
Parameters
$pieceID : int
$startLoc : Loc
$endLoc : Loc
$pieceTaken : int|null
$checking : string|null
$playerColour : Colour
$castling : Castling|null
$enPassant : bool
$promotionPieceID : int|null
$draw : bool
Return values
string

updateEndedGame()

private updateEndedGame(int $winnerPlayerID) : void
Parameters
$winnerPlayerID : int

        
On this page

Search results