Browse Source

Fixed problem with fens like 8/7P/8/8/1k15/8/P7/K7 w - - 0 1, i.e. 1k15(and not 1k6)

master
DHTMLGoodies 6 years ago
parent
commit
586d996e02
  1. 4
      FenParser0x88.php
  2. 34
      test/ParserTest.php

4
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);
}
}

34
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);
}
/**

Loading…
Cancel
Save