diff --git a/GameParser.php b/GameParser.php index 4ee75ee..0984234 100755 --- a/GameParser.php +++ b/GameParser.php @@ -37,6 +37,8 @@ class GameParser 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]))) { return; } diff --git a/MoveBuilder.php b/MoveBuilder.php index f1055c5..41b0514 100755 --- a/MoveBuilder.php +++ b/MoveBuilder.php @@ -27,6 +27,7 @@ class MoveBuilder { } 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); } diff --git a/test/ParserTest.php b/test/ParserTest.php index cdc4640..71d75a9 100755 --- a/test/ParserTest.php +++ b/test/ParserTest.php @@ -1042,7 +1042,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1'; // when $validMoves = $parser->getValidMovesAndResult('black'); - var_dump($validMoves); $pLegal = $validMoves['moves']; $knightMoves = $this->getValidMovesForSquare($pLegal, 'e6'); $expectedSquares = array(); @@ -1067,7 +1066,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1'; $validMoves = $parser->getValidMovesAndResult('white'); $pLegal = $validMoves['moves']; $pawnMoves = $this->getValidMovesForSquare($pLegal, 'g2'); - var_dump($pawnMoves); $expectedSquares = array(); // then $this->assertHasSquares($expectedSquares, $pawnMoves); @@ -1166,7 +1164,6 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1'; $parser = new FenParser0x88($fenPawnOng2CheckingKingOng1); // when $checks = $parser->getValidSquaresOnCheck('white'); - var_dump($checks); // then $this->assertEquals(1, count($checks)); $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); $blackKing = $parser->getKing('black'); - var_dump($blackKing); $this->assertEquals(Board0x88Config::$mapping['g8'], $blackKing['s']); $sq = Board0x88Config::$mapping['b3']; $bishop = $parser->getPieceOnSquare($sq); @@ -2218,7 +2214,17 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1'; $this->assertCount($moves, $game["moves"]); } - echo json_encode($games2[0]); + } + + /** + * @test + */ + public function shouldHandleNullMoves(){ + $parser = new PgnParser("pgn/nullmoves.pgn"); + + $game = $parser->getGameByIndex(0); + + } } diff --git a/test/pgn/nullmoves.pgn b/test/pgn/nullmoves.pgn new file mode 100644 index 0000000..55beb38 --- /dev/null +++ b/test/pgn/nullmoves.pgn @@ -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 \ No newline at end of file