keep a string of moves/comments when parsing PGN.
This commit is contained in:
@@ -11,6 +11,7 @@ class CHESS_JSON {
|
|||||||
const MOVE_ACTIONS = 'actions';
|
const MOVE_ACTIONS = 'actions';
|
||||||
const MOVE_VARIATIONS = 'variations';
|
const MOVE_VARIATIONS = 'variations';
|
||||||
const MOVE_MOVES = 'moves';
|
const MOVE_MOVES = 'moves';
|
||||||
|
const MOVE_MOVES_STRING = 'movesStr';
|
||||||
const MOVE_CAPTURE = 'capture';
|
const MOVE_CAPTURE = 'capture';
|
||||||
const MOVE_PROMOTE_TO = 'promoteTo';
|
const MOVE_PROMOTE_TO = 'promoteTo';
|
||||||
const MOVE_CASTLE = 'castle';
|
const MOVE_CASTLE = 'castle';
|
||||||
@@ -29,10 +30,12 @@ class CHESS_JSON {
|
|||||||
const PGN_KEY_ACTION_CLR_ARROW = "cal";
|
const PGN_KEY_ACTION_CLR_ARROW = "cal";
|
||||||
|
|
||||||
|
|
||||||
protected static $jsKeys = array('MOVE_FROM', 'MOVE_TO', 'MOVE_NOTATION', 'FEN','MOVE_COMMENT',
|
protected static $jsKeys = array(
|
||||||
'MOVE_ACTION', 'MOVE_VARIATIONS', 'MOVE_MOVES','MOVE_CAPTURE','MOVE_PROMOTE_TO','MOVE_CASTLE',
|
'MOVE_FROM', 'MOVE_TO', 'MOVE_NOTATION', 'FEN',
|
||||||
'GAME_METADATA', 'GAME_EVENT', 'GAME_WHITE','GAME_BLACK', 'GAME_ECO',
|
'MOVE_COMMENT', 'MOVE_ACTION', 'MOVE_VARIATIONS', 'MOVE_MOVES',
|
||||||
|
'MOVE_MOVES_STRING', 'MOVE_CAPTURE', 'MOVE_PROMOTE_TO', 'MOVE_CASTLE',
|
||||||
|
'GAME_METADATA', 'GAME_EVENT', 'GAME_WHITE', 'GAME_BLACK',
|
||||||
|
'GAME_ECO',
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function toJavascript(){
|
public static function toJavascript(){
|
||||||
@@ -42,4 +45,4 @@ class CHESS_JSON {
|
|||||||
}
|
}
|
||||||
return 'ludo.CHESS_JSON_KEY = ' . json_encode($ret) .';';
|
return 'ludo.CHESS_JSON_KEY = ' . json_encode($ret) .';';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@ class PgnGameParser{
|
|||||||
|
|
||||||
public function getParsedData(){
|
public function getParsedData(){
|
||||||
$this->gameData = $this->getMetadata();
|
$this->gameData = $this->getMetadata();
|
||||||
|
$this->gameData[CHESS_JSON::MOVE_MOVES_STRING] = $this->getMoveString();
|
||||||
$this->gameData[CHESS_JSON::MOVE_MOVES] = $this->getMoves();
|
$this->gameData[CHESS_JSON::MOVE_MOVES] = $this->getMoves();
|
||||||
return $this->gameData;
|
return $this->gameData;
|
||||||
}
|
}
|
||||||
@@ -140,4 +141,4 @@ class PgnGameParser{
|
|||||||
$gameData = preg_replace("/(\s+)/", " ", $gameData);
|
$gameData = preg_replace("/(\s+)/", " ", $gameData);
|
||||||
return trim($gameData);
|
return trim($gameData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user