updates null moves
This commit is contained in:
@@ -37,6 +37,8 @@ class GameParser
|
|||||||
|
|
||||||
private function parseAMove(&$move)
|
private function parseAMove(&$move)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!isset($move[CHESS_JSON::MOVE_NOTATION]) || (isset($move[CHESS_JSON::FEN]) && isset($move[CHESS_JSON::MOVE_FROM]) && isset($move[CHESS_JSON::MOVE_TO]))) {
|
if (!isset($move[CHESS_JSON::MOVE_NOTATION]) || (isset($move[CHESS_JSON::FEN]) && isset($move[CHESS_JSON::MOVE_FROM]) && isset($move[CHESS_JSON::MOVE_TO]))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ class MoveBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function isChessMove($move){
|
private function isChessMove($move){
|
||||||
|
if($move == '--')return true;
|
||||||
return preg_match("/([PNBRQK]?[a-h]?[1-8]?x?[a-h][1-8](?:\=[PNBRQK])?|O(-?O){1,2})[\+#]?(\s*[\!\?]+)?/s", $move);
|
return preg_match("/([PNBRQK]?[a-h]?[1-8]?x?[a-h][1-8](?:\=[PNBRQK])?|O(-?O){1,2})[\+#]?(\s*[\!\?]+)?/s", $move);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1042,7 +1042,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1';
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
$validMoves = $parser->getValidMovesAndResult('black');
|
$validMoves = $parser->getValidMovesAndResult('black');
|
||||||
var_dump($validMoves);
|
|
||||||
$pLegal = $validMoves['moves'];
|
$pLegal = $validMoves['moves'];
|
||||||
$knightMoves = $this->getValidMovesForSquare($pLegal, 'e6');
|
$knightMoves = $this->getValidMovesForSquare($pLegal, 'e6');
|
||||||
$expectedSquares = array();
|
$expectedSquares = array();
|
||||||
@@ -1067,7 +1066,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1';
|
|||||||
$validMoves = $parser->getValidMovesAndResult('white');
|
$validMoves = $parser->getValidMovesAndResult('white');
|
||||||
$pLegal = $validMoves['moves'];
|
$pLegal = $validMoves['moves'];
|
||||||
$pawnMoves = $this->getValidMovesForSquare($pLegal, 'g2');
|
$pawnMoves = $this->getValidMovesForSquare($pLegal, 'g2');
|
||||||
var_dump($pawnMoves);
|
|
||||||
$expectedSquares = array();
|
$expectedSquares = array();
|
||||||
// then
|
// then
|
||||||
$this->assertHasSquares($expectedSquares, $pawnMoves);
|
$this->assertHasSquares($expectedSquares, $pawnMoves);
|
||||||
@@ -1166,7 +1164,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1';
|
|||||||
$parser = new FenParser0x88($fenPawnOng2CheckingKingOng1);
|
$parser = new FenParser0x88($fenPawnOng2CheckingKingOng1);
|
||||||
// when
|
// when
|
||||||
$checks = $parser->getValidSquaresOnCheck('white');
|
$checks = $parser->getValidSquaresOnCheck('white');
|
||||||
var_dump($checks);
|
|
||||||
// then
|
// then
|
||||||
$this->assertEquals(1, count($checks));
|
$this->assertEquals(1, count($checks));
|
||||||
$this->assertEquals($this->getNumericSquare('f2'), $checks[0]);
|
$this->assertEquals($this->getNumericSquare('f2'), $checks[0]);
|
||||||
@@ -1219,7 +1216,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1';
|
|||||||
$parser = new FenParser0x88($fenBishopOnB3CheckingKingOnG7);
|
$parser = new FenParser0x88($fenBishopOnB3CheckingKingOnG7);
|
||||||
|
|
||||||
$blackKing = $parser->getKing('black');
|
$blackKing = $parser->getKing('black');
|
||||||
var_dump($blackKing);
|
|
||||||
$this->assertEquals(Board0x88Config::$mapping['g8'], $blackKing['s']);
|
$this->assertEquals(Board0x88Config::$mapping['g8'], $blackKing['s']);
|
||||||
$sq = Board0x88Config::$mapping['b3'];
|
$sq = Board0x88Config::$mapping['b3'];
|
||||||
$bishop = $parser->getPieceOnSquare($sq);
|
$bishop = $parser->getPieceOnSquare($sq);
|
||||||
@@ -2218,7 +2214,17 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1';
|
|||||||
$this->assertCount($moves, $game["moves"]);
|
$this->assertCount($moves, $game["moves"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($games2[0]);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function shouldHandleNullMoves(){
|
||||||
|
$parser = new PgnParser("pgn/nullmoves.pgn");
|
||||||
|
|
||||||
|
$game = $parser->getGameByIndex(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
test/pgn/nullmoves.pgn
Normal file
9
test/pgn/nullmoves.pgn
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Event "4th match"]
|
||||||
|
[Site "London"]
|
||||||
|
[Date "1834.??.??"]
|
||||||
|
[Round "62"]
|
||||||
|
[White "McDonnell,A"]
|
||||||
|
[Black "De La Bourdonnais,L"]
|
||||||
|
[Result "0-1"]
|
||||||
|
|
||||||
|
1.e4 -- 2.Nf3 -- 3.Nc3
|
Reference in New Issue
Block a user