From a73c64bbe21044c6c9f7032abbb952995e36ec4a Mon Sep 17 00:00:00 2001 From: Marcel Pol Date: Tue, 16 Feb 2021 16:15:24 +0100 Subject: [PATCH 1/2] Support castling move with NAG in FenParser. --- FenParser0x88.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FenParser0x88.php b/FenParser0x88.php index 3a93199..93ff5e3 100755 --- a/FenParser0x88.php +++ b/FenParser0x88.php @@ -1259,10 +1259,10 @@ function getFromAndToByNotation($notation) case 0x03: case 0x0B: - if ($notation === 'O-O') { + if (substr($notation, 0, 3) === 'O-O' && substr($notation, 0, 3) !== 'O-O') { $foundPieces[] = ($offset + 4); $ret['to'] = $offset + 6; - } else if ($notation === 'O-O-O') { + } else if (substr($notation, 0, 5) === 'O-O-O') { $foundPieces[] = ($offset + 4); $ret['to'] = $offset + 2; } else { @@ -1411,7 +1411,7 @@ function getToSquareByNotation($notation) function getPieceTypeByNotation($notation, $color = null) { - if ($notation === 'O-O-O' || $notation === 'O-O') { + if (substr($notation, 0, 5) === 'O-O-O' || substr($notation, 0, 3) === 'O-O') { $pieceType = 'K'; } else { $token = substr($notation, 0, 1); @@ -1812,4 +1812,5 @@ private function getNewFen() class FenParser0x88Exception extends Exception{ -} \ No newline at end of file +} + From d782df9e10facf0e947f32187ecfd62d475a8998 Mon Sep 17 00:00:00 2001 From: Marcel Pol Date: Tue, 16 Feb 2021 16:39:20 +0100 Subject: [PATCH 2/2] Fix silly mistake, don't know how it got there :) --- FenParser0x88.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FenParser0x88.php b/FenParser0x88.php index 93ff5e3..cb70eca 100755 --- a/FenParser0x88.php +++ b/FenParser0x88.php @@ -1259,7 +1259,7 @@ function getFromAndToByNotation($notation) case 0x03: case 0x0B: - if (substr($notation, 0, 3) === 'O-O' && substr($notation, 0, 3) !== 'O-O') { + if (substr($notation, 0, 3) === 'O-O' && substr($notation, 0, 5) !== 'O-O-O') { $foundPieces[] = ($offset + 4); $ret['to'] = $offset + 6; } else if (substr($notation, 0, 5) === 'O-O-O') {