ChessBrowser
Extension to create interactive chess boards
Loading...
Searching...
No Matches
MediaWiki\Extension\ChessBrowser\ChessParser Class Reference

Public Member Functions

 __construct ( $pgnContent)
 Construct a new ChesParser.
 
 createOutputJson ( $gameNum=0)
 Returns a JSON string for the javascript module.
 
 convertParserOutput ( $moves, $fenParts, $moveObject)
 Convert the parser output into the board, token, ply object used in the javascript module.
 
 createAnnotationJson ( $variationObj, $fenParts, $index)
 Will pass variations to the JS module to insert into the game.
 
 checkSpecialMove ( $to, $from, $token, $fenParts)
 Sets the special move field of the JSON "ply" section.
 
 getFenParts ( $fen)
 Extracts en passant target and color to play from FEN.
 
 getPgnParserOutput ( $gameNum=0)
 Extract needed data from the PGN parser output.
 

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\ChessBrowser\ChessParser::__construct ( $pgnContent)

Construct a new ChesParser.

Parameters
string$pgnContent

Member Function Documentation

◆ checkSpecialMove()

MediaWiki\Extension\ChessBrowser\ChessParser::checkSpecialMove ( $to,
$from,
$token,
$fenParts )

Sets the special move field of the JSON "ply" section.

Since
0.2.0
Parameters
int$to
int$from
string$token
array$fenParts
Returns
array

◆ convertParserOutput()

MediaWiki\Extension\ChessBrowser\ChessParser::convertParserOutput ( $moves,
$fenParts,
$moveObject )

Convert the parser output into the board, token, ply object used in the javascript module.

Parameters
array$movesThe list of moves output by the PgnParser
array$fenPartsThe fen string broken down by getFenParts
array$moveObjectThe movereferences from the PgnParser
Returns
array

◆ createAnnotationJson()

MediaWiki\Extension\ChessBrowser\ChessParser::createAnnotationJson ( $variationObj,
$fenParts,
$index )

Will pass variations to the JS module to insert into the game.

Parameters
array$variationObjlist of variations associated with a move. Organized as a list of lists of moves, so 1. e4 (1. c4 c5) (1.d4) would be: [ [ { 'm': 'c4', 'from': 'c2', 'to': 'c4', 'fen': '...' }, { 'm': 'c5', 'from': 'c7', 'to': 'c5', 'fen': '...' } ], [ { 'm': 'd4', 'from': 'd2', 'to': 'd4', 'fen': '...' } ] ]
array$fenPartsThe starting fen broken down into semantic chunks
int$indexPly of the variation's parent move.
Returns
array

◆ createOutputJson()

MediaWiki\Extension\ChessBrowser\ChessParser::createOutputJson ( $gameNum = 0)

Returns a JSON string for the javascript module.

Since
0.2.0
Parameters
int$gameNumPassed directly to the PGN parsing library
Returns
array

◆ getFenParts()

MediaWiki\Extension\ChessBrowser\ChessParser::getFenParts ( $fen)

Extracts en passant target and color to play from FEN.

Since
0.2.0
Parameters
string$fen
Returns
array

◆ getPgnParserOutput()

MediaWiki\Extension\ChessBrowser\ChessParser::getPgnParserOutput ( $gameNum = 0)

Extract needed data from the PGN parser output.

Since
0.2.0
Parameters
int$gameNumPassed directly to the PGN parsing library
Returns
array

The documentation for this class was generated from the following file: