From 586d996e02787778c974c9ef037a6d645fc07299 Mon Sep 17 00:00:00 2001 From: DHTMLGoodies Date: Thu, 24 Dec 2015 01:20:00 +0100 Subject: [PATCH] Fixed problem with fens like 8/7P/8/8/1k15/8/P7/K7 w - - 0 1, i.e. 1k15(and not 1k6) --- FenParser0x88.php | 4 ---- test/ParserTest.php | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/FenParser0x88.php b/FenParser0x88.php index a00a33c..d929608 100644 --- a/FenParser0x88.php +++ b/FenParser0x88.php @@ -118,10 +118,6 @@ class FenParser0x88 } $pos++; } else if ($i < $len - 1 && isset(Board0x88Config::$numbers[$token])) { - $token2 = $this->fenParts['pieces'][$i + 1]; - if (preg_match("/[0-9]/", $token2)) { - $token = $token . $token2; - } $pos += intval($token); } } diff --git a/test/ParserTest.php b/test/ParserTest.php index 31d0ec2..c5b3d3e 100644 --- a/test/ParserTest.php +++ b/test/ParserTest.php @@ -90,7 +90,7 @@ Qe7 28. e4 Nh7 29. h5 Nf8 30. Qb8 g5 31. Qc8 Ne6 32. Bxe6 Qxe6 33. Qxe6 fxe6 $game = $pgnParser->getFirstGame(); $parser = new FenParser0x88(); - $parser->newGame(); + $parser->setFen('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'); $parser->move("g1f3"); $notation = $parser->getNotation(); @@ -106,6 +106,38 @@ Qe7 28. e4 Nh7 29. h5 Nf8 30. Qb8 g5 31. Qc8 Ne6 32. Bxe6 Qxe6 33. Qxe6 fxe6 $this->assertEquals("Nf3", $notation); + } + + + /** + * @test + */ + public function shouldParseProblematic2(){ + $game = '[Event "ProofOfConcept"] +[Site "Exploit"] +[Date "2015.??.??"] +[Round "?"] +[White "N.N."] +[Black "N.N."] +[Result "1-0"] +[Annotator ""] +[SetUp "1"] +[FEN "8/7P/8/8/1k15/8/P7/K7 w - - 0 1"] +[PlyCount "1"] +[EventDate "2015.??.??"] +[EventType "game"] +[EventCountry "GER"] + +1. a3+'; + $pgnParser = new PgnParser(); + $pgnParser->setPgnContent($game); + $game = $pgnParser->getFirstGame(); + + var_dump($game); + + + + } /**