Games_Chess
[ class tree: Games_Chess ] [ index: Games_Chess ] [ all elements ]

Class: Games_Chess_Standard

Source Location: /Games_Chess-1.0.1/Chess/Standard.php

Class Overview

Games_Chess
   |
   --Games_Chess_Standard

Standard chess game


Author(s):

Methods


Child classes:

Games_Chess_Losers
Losers chess game
Games_Chess_Crazyhouse
Crazyhouse chess game

Inherited Variables

Inherited Methods

Class: Games_Chess

Games_Chess::addPiece()
Add a piece to the chessboard
Games_Chess::blankBoard()
Create a blank chessboard with no pieces on it
Games_Chess::canCastleKingside()
Determine legality of kingside castling
Games_Chess::canCastleQueenside()
Determine legality of queenside castling
Games_Chess::commitTransaction()
Remove any possibility of undo.
Games_Chess::factory()
Games_Chess::gameOver()
Games_Chess::getDiagonalColor()
Games_Chess::getMessage()
Get an error message from the code
Games_Chess::getMoveList()
Get the list of moves in Standard Algebraic Notation
Games_Chess::getPieceLocations()
Get the location of all pieces on the board of a certain color
Games_Chess::getPossibleBishopMoves()
Get all legal Bishop moves (checking of the king is not taken into account)
Games_Chess::getPossibleKingMoves()
Get all legal King moves (checking of the king is not taken into account)
Games_Chess::getPossibleKnightMoves()
Get all legal Knight moves (checking of the king is not taken into account)
Games_Chess::getPossibleMoves()
Get a list of all possible theoretical squares a piece of this nature and color could move to with the current board and game setup.
Games_Chess::getPossiblePawnMoves()
Get all legal Pawn moves (checking of the king is not taken into account)
Games_Chess::getPossibleQueenMoves()
Get all legal Queen moves (checking of the king is not taken into account)
Games_Chess::getPossibleRookMoves()
Get all legal Rook moves (checking of the king is not taken into account)
Games_Chess::getState()
Get the current state of the chess game
Games_Chess::in50MoveDraw()
Determine whether any pawn move or capture has occurred in the past 50 moves
Games_Chess::inBasicDraw()
Determine the presence of a basic draw as defined by FIDE rules
Games_Chess::inCheckMate()
Determine whether a side is in checkmate
Games_Chess::inDraw()
Determines the presence of a forced draw
Games_Chess::inRepetitionDraw()
Determine whether draw by repetition has happened
Games_Chess::inStaleMate()
Determine whether a side is in stalemate
Games_Chess::isError()
Determines whether the data returned from a method is a PEAR-related
Games_Chess::isPromoteMove()
Determine whether moving a piece from one square to another requires
Games_Chess::moveSAN()
Make a move from a Standard Algebraic Notation (SAN) format
Games_Chess::moveSquare()
Move a piece from one square to another, and mark the old square as empty
Games_Chess::raiseError()
Games_Chess::renderFen()
render the FEN notation for the current board
Games_Chess::resetGame()
Create a new game with the starting position, or from the position specified by $fen
Games_Chess::rollbackTransaction()
Undo any changes to state since startTransaction() was first used
Games_Chess::setState()
Set the state of the chess game
Games_Chess::startTransaction()
Begin a chess piece transaction
Games_Chess::toArray()
Generate a representation of the chess board and pieces for use as a direct translation to a visual chess board
Games_Chess::toMove()
Games_Chess::_convertSquareToSAN()
Convert a starting and ending algebraic square into SAN
Games_Chess::_getAllPieceLocations()
Get the location of every piece on the board of color $color
Games_Chess::_getCastleSquares()
Get a list of all the squares a king could castle to on an empty board
Games_Chess::_getDiagonalColor()
Return the color of a square (black or white)
Games_Chess::_getKingSquares()
Get a list of all the squares a king could move to on an empty board
Games_Chess::_getKnightSquares()
Get all the squares a knight could move to on an empty board
Games_Chess::_getQueenSquares()
Get all the squares a queen could go to on a blank board
Games_Chess::_getRookSquares()
Get the set of squares that are diagonals from this square on an empty board.
Games_Chess::_moveAlgebraic()
Move a piece from one square to another, and mark the old square as empty
Games_Chess::_parseMove()
Parse out the segments of a move (minus any annotations)
Games_Chess::_setupStartingPosition()
Set up the board with the starting position
Games_Chess::_validMove()
Validate a move

Class Details

[line 35]
Standard chess game


[ Top ]


Method Detail

addPiece   [line 163]

true|PEAR_Error addPiece( W|B $color, K|Q|R|N|P|B $type, string $square)

Add a piece to the chessboard
  • Throws: GAMES_CHESS_ERROR_INVALIDSQUARE
  • Throws: GAMES_CHESS_ERROR_DUPESQUARE
  • Throws: GAMES_CHESS_ERROR_MULTIPIECE

Overridden in child classes as:

Games_Chess_Crazyhouse::addPiece()
Add a piece to the chessboard

Overrides Games_Chess::addPiece() (Add a piece to the chessboard)

Parameters:

W|B   $color   —  piece color
K|Q|R|N|P|B   $type   —  Piece type
string   $square   —  [a-h][1-8] algebraic location of piece

[ Top ]

blankBoard   [line 46]

void blankBoard( )

Set up a blank chess board

Overridden in child classes as:

Games_Chess_Crazyhouse::blankBoard()
Set up a blank chess board

Overrides Games_Chess::blankBoard() (Create a blank chessboard with no pieces on it)
[ Top ]

inCheck   [line 404]

string|array|false inCheck( W|B $color)

Determine whether one side's king is in check by the other side's pieces
  • Return: square of checking piece(s) or false

Overridden in child classes as:

Games_Chess_Crazyhouse::inCheck()
Determine whether one side's king is in check by the other side's pieces

Parameters:

W|B   $color   —  color of pieces to determine enemy check

[ Top ]

isBishop   [line 780]

boolean isBishop( string $piecename)

Determine whether a piece name is a bishop

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::isBishop()
Determine whether a piece name is a bishop

Parameters:

string   $piecename   — 

[ Top ]

isKing   [line 827]

boolean isKing( string $piecename)

Determine whether a piece name is a king

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::isKing()
Determine whether a piece name is a king

Parameters:

string   $piecename   — 

[ Top ]

isPawn   [line 812]

boolean isPawn( string $piecename)

Determine whether a piece name is a pawn

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::isPawn()
Determine whether a piece name is a pawn

Parameters:

string   $piecename   — 

[ Top ]

isRook   [line 796]

boolean isRook( string $piecename)

Determine whether a piece name is a rook

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::isRook()
Determine whether a piece name is a rook

Parameters:

string   $piecename   — 

[ Top ]

toArray   [line 255]

array toArray( )

Generate a representation of the chess board and pieces for use as a

direct translation to a visual chess board


Overridden in child classes as:

Games_Chess_Crazyhouse::toArray()

Overrides Games_Chess::toArray() (Generate a representation of the chess board and pieces for use as a direct translation to a visual chess board)
[ Top ]

_getAllPieceLocations   [line 359]

void _getAllPieceLocations( W|B $color)

Get the location of every piece on the board of color $color
  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_getAllPieceLocations()
Get the location of every piece on the board of color $color

Overrides Games_Chess::_getAllPieceLocations() (Get the location of every piece on the board of color $color)

Parameters:

W|B   $color   —  color of pieces to check

[ Top ]

_getAllPieceSquares   [line 493]

array _getAllPieceSquares( K|B|N|R|W|P $piece, W|B $color, [string $exclude = null])

Retrieve the locations of all pieces of the same type as $piece
  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_getAllPieceSquares()
Retrieve the locations of all pieces of the same type as $piece

Parameters:

K|B|N|R|W|P   $piece   — 
W|B   $color   — 
string   $exclude   —  [a-h][1-8] optional square of piece to exclude from the listing

[ Top ]

_getColor   [line 888]

void _getColor( $name)

Retrieve the color of a piece from its name

Game-specific method of retrieving the color of a piece

  • Access: protected

Parameters:

   $name   — 

[ Top ]

_getKing   [line 714]

false|string _getKing( [ $color = null])

Get the location of the king

assumes valid color input

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_getKing()
Get the location of the king

Parameters:

   $color   — 

[ Top ]

_getPiece   [line 732]

string|array _getPiece( string $piecename)

Get the location of a piece

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_getPiece()
Get the location of a piece

Parameters:

string   $piecename   — 

[ Top ]

_getPieceTypes   [line 912]

array _getPieceTypes( )

Get a list of all pieces on the board organized by the type of piece, and the color of the square the piece is on.

Used to determine basic draw conditions

  • Return:

    Format:

     array(
       // white pieces
       'W' => array('B' => array('W', 'B'), // all bishops
                    'K' => array('W'),...
                   ),
       // black pieces
       'B' => array('Q' => array('B'), // all queens
                    'K' => array('W'),... // king is on white square

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_getPieceTypes()
Get a list of all pieces on the board organized by the type of piece, and the color of the square the piece is on.

[ Top ]

_getPossibleChecks   [line 381]

array _getPossibleChecks( W|B $color)

Used to determine check

Retrieve all of the moves of the pieces matching the color passed in.

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_getPossibleChecks()
Used to determine check

Parameters:

W|B   $color   — 

[ Top ]

_isKnight   [line 748]

boolean _isKnight( string $piecename)

Determine whether a piece name is a knight

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_isKnight()
Determine whether a piece name is a knight

Parameters:

string   $piecename   — 

[ Top ]

_isQueen   [line 764]

boolean _isQueen( string $piecename)

Determine whether a piece name is a queen

This does NOT take an algebraic square as the argument, but the contents of _board[algebraic square]

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_isQueen()
Determine whether a piece name is a queen

Parameters:

string   $piecename   — 

[ Top ]

_renderFen   [line 311]

string _renderFen( )

Render the current board position into Forsyth-Edwards Notation

This method only renders the board contents, not the castling and other information

  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_renderFen()
Render the current board position into Forsyth-Edwards Notation

[ Top ]

_setupStartingPosition   [line 93]

void _setupStartingPosition( )

Set up a starting position for a new chess game
  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_setupStartingPosition()
Set up a starting position for a new chess game

Overrides Games_Chess::_setupStartingPosition() (Set up the board with the starting position)
[ Top ]

_squareToPiece   [line 468]

false|array _squareToPiece( string $square)

Translate an algebraic coordinate into the color and name of a piece,

or false if no piece is on that square

  • Return: Format array('color' => B|W, 'piece' => P|R|Q|N|K|B)
  • Access: protected

Overridden in child classes as:

Games_Chess_Crazyhouse::_squareToPiece()
Translate an algebraic coordinate into the color and name of a piece,

Parameters:

string   $square   —  [a-h][1-8]

[ Top ]

_takePiece   [line 429]

void _takePiece( string $piece)

Mark a piece as having been taken. No validation is performed
  • Access: protected

Parameters:

string   $piece   —  [a-h][1-8]

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:05:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.