diff -u b/lib/Drupal/pgn/Serializer/Encoder/PgnEncoder.php b/lib/Drupal/pgn/Serializer/Encoder/PgnEncoder.php --- b/lib/Drupal/pgn/Serializer/Encoder/PgnEncoder.php +++ b/lib/Drupal/pgn/Serializer/Encoder/PgnEncoder.php @@ -25,8 +25,6 @@ * {@inheritdoc} */ public function encode($data, $format, array $context = array()) { - static $decisive = array('1-0', '0-1'); - $movetext = ''; foreach($data as $number => $move) { $movetext .= $number . '. ' . $move[0] . ' '; @@ -35,11 +33,7 @@ } } $last_move = end($data); - $last_half = end($last_move); - if (strpos($last_half, '#')) { - $decisive_index = count($last_move) - 1; - } - $result = !isset($decisive_index) ? '*' : $decisive[$decisive_index]; + $result = $last_move['result']; $movetext .= $result; $pgn = array( diff -u b/tests/Drupal/pgn/Tests/PgnEncoderUnitTest.php b/tests/Drupal/pgn/Tests/PgnEncoderUnitTest.php --- b/tests/Drupal/pgn/Tests/PgnEncoderUnitTest.php +++ b/tests/Drupal/pgn/Tests/PgnEncoderUnitTest.php @@ -52,15 +52,15 @@ return array( array( array( - 1=> array('e4', 'f5'), - 2 => array('Qh5+'), + 1 => array('e4', 'f5'), + 2 => array('Qh5+', 'result' => '*'), ), 'e4f5Dh5.pgn', ), array( array( 1 => array('f3', 'e5'), - 2 => array('g4', 'Dh4#'), + 2 => array('g4', 'Dh4#', 'result' => '0-1'), ), 'fools_mate.pgn', ), @@ -68,7 +68,7 @@ array( 1 => array('e4', 'g5'), 2 => array('Qf3', 'f5'), - 3 => array('Qh5#'), + 3 => array('Qh5#', 'result' => '1-0'), ), 'e4g5Df3f5Dh5.pgn', ),