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

Class: Games_Chess_Crazyhouse

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

Class Overview

Games_Chess
   |
   --Games_Chess_Standard
      |
      --Games_Chess_Crazyhouse

Crazyhouse chess game


Author(s):

Methods


Inherited Variables

Inherited Methods

Class: Games_Chess_Standard

Games_Chess_Standard::addPiece()
Add a piece to the chessboard
Games_Chess_Standard::blankBoard()
Set up a blank chess board
Games_Chess_Standard::inCheck()
Determine whether one side's king is in check by the other side's pieces
Games_Chess_Standard::isBishop()
Determine whether a piece name is a bishop
Games_Chess_Standard::isKing()
Determine whether a piece name is a king
Games_Chess_Standard::isPawn()
Determine whether a piece name is a pawn
Games_Chess_Standard::isRook()
Determine whether a piece name is a rook
Games_Chess_Standard::toArray()
Generate a representation of the chess board and pieces for use as a
Games_Chess_Standard::_getAllPieceLocations()
Get the location of every piece on the board of color $color
Games_Chess_Standard::_getAllPieceSquares()
Retrieve the locations of all pieces of the same type as $piece
Games_Chess_Standard::_getColor()
Retrieve the color of a piece from its name
Games_Chess_Standard::_getKing()
Get the location of the king
Games_Chess_Standard::_getPiece()
Get the location of a piece
Games_Chess_Standard::_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.
Games_Chess_Standard::_getPossibleChecks()
Used to determine check
Games_Chess_Standard::_isKnight()
Determine whether a piece name is a knight
Games_Chess_Standard::_isQueen()
Determine whether a piece name is a queen
Games_Chess_Standard::_renderFen()
Render the current board position into Forsyth-Edwards Notation
Games_Chess_Standard::_setupStartingPosition()
Set up a starting position for a new chess game
Games_Chess_Standard::_squareToPiece()
Translate an algebraic coordinate into the color and name of a piece,
Games_Chess_Standard::_takePiece()
Mark a piece as having been taken. No validation is performed

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 41]
Crazyhouse chess game

A captured piece may be placed on the board as your own piece! Note that FEN is incapable of setting up a game mid-swing - no record of captured pieces is possible. If requested, a future version may extend the FEN standard to allow this, particularly if ICC follows the same standard



[ Top ]


Method Detail

addPiece   [line 1028]

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

Overrides Games_Chess_Standard::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 108]

void blankBoard( )

Set up a blank chess board

Overrides Games_Chess_Standard::blankBoard() (Set up a blank chess board)
[ Top ]

in50MoveDraw   [line 1196]

false in50MoveDraw( )

50 move draw is not allowed in crazyhouse

Overrides Games_Chess::in50MoveDraw() (Determine whether any pawn move or capture has occurred in the past 50 moves)
[ Top ]

inBasicDraw   [line 1178]

false inBasicDraw( )

Basic draw is impossible in crazyhouse, because it is always possible

to place another piece


Overrides Games_Chess::inBasicDraw() (Determine the presence of a basic draw as defined by FIDE rules)
[ Top ]

inCheck   [line 975]

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

Overrides Games_Chess_Standard::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 ]

inRepetitionDraw   [line 1187]

false inRepetitionDraw( )

Repetition draw is not allowed in crazyhouse

Overrides Games_Chess::inRepetitionDraw() (Determine whether draw by repetition has happened)
[ Top ]

isBishop   [line 735]

boolean isBishop( string $piece)

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]


Overrides Games_Chess_Standard::isBishop() (Determine whether a piece name is a bishop)

Parameters:

string   $piece     

[ Top ]

isKing   [line 700]

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

Overrides Games_Chess_Standard::isKing() (Determine whether a piece name is a king)

Parameters:

string   $piecename     

[ Top ]

isPawn   [line 771]

boolean isPawn( string $piece)

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]


Overrides Games_Chess_Standard::isPawn() (Determine whether a piece name is a pawn)

Parameters:

string   $piece     

[ Top ]

isRook   [line 753]

boolean isRook( string $piece)

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]


Overrides Games_Chess_Standard::isRook() (Determine whether a piece name is a rook)

Parameters:

string   $piece     

[ Top ]

moveSAN   [line 288]

true|PEAR_Error moveSAN( string $move)

Make a move from a Standard Algebraic Notation (SAN) format

SAN is just a normal chess move like Na4, instead of the English Notation, like NR4


Overrides Games_Chess::moveSAN() (Make a move from a Standard Algebraic Notation (SAN) format)

Parameters:

string   $move     

[ Top ]

toArray   [line 995]

void toArray( )


Overrides Games_Chess_Standard::toArray() (Generate a representation of the chess board and pieces for use as a)
[ Top ]

_getAllPieceLocations   [line 907]

void _getAllPieceLocations( W|B $color)

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

Overrides Games_Chess_Standard::_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 434]

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

Overrides Games_Chess_Standard::_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 ]

_getKing   [line 638]

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

Get the location of the king

assumes valid color input

  • Access: protected

Overrides Games_Chess_Standard::_getKing() (Get the location of the king)

Parameters:

   $color     

[ Top ]

_getPiece   [line 662]

string|array _getPiece( string $piece)

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

Overrides Games_Chess_Standard::_getPiece() (Get the location of a piece)

Parameters:

string   $piece     

[ Top ]

_getPieceTypes   [line 862]

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

Overrides Games_Chess_Standard::_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 887]

array _getPossibleChecks( W|B $color)

Used to determine check

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

  • Access: protected

Overrides Games_Chess_Standard::_getPossibleChecks() (Used to determine check)

Parameters:

W|B   $color     

[ Top ]

_isKnight   [line 681]

boolean _isKnight( string $piece)

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

Overrides Games_Chess_Standard::_isKnight() (Determine whether a piece name is a knight)

Parameters:

string   $piece     

[ Top ]

_isQueen   [line 717]

boolean _isQueen( string $piece)

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

Overrides Games_Chess_Standard::_isQueen() (Determine whether a piece name is a queen)

Parameters:

string   $piece     

[ Top ]

_renderFen   [line 927]

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

Overrides Games_Chess_Standard::_renderFen() (Render the current board position into Forsyth-Edwards Notation)
[ Top ]

_setupStartingPosition   [line 169]

void _setupStartingPosition( )

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

Overrides Games_Chess_Standard::_setupStartingPosition() (Set up a starting position for a new chess game)
[ Top ]

_squareToPiece   [line 409]

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

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

Parameters:

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

[ Top ]


Documentation generated on Sun, 17 Jun 2007 02:00:49 -0400 by phpDocumentor 1.3.2. PEAR Logo Copyright © PHP Group 2004.