diff --git a/lib/src/model/common/node.dart b/lib/src/model/common/node.dart index 75c7ed8b93..8916702bac 100644 --- a/lib/src/model/common/node.dart +++ b/lib/src/model/common/node.dart @@ -192,9 +192,13 @@ abstract class Node { bool prepend = false, }) { final pos = nodeAt(path).position; - final (newPos, newSan) = pos.makeSan(convertAltCastlingMove(move) ?? move); + final isKingMove = + move is NormalMove && pos.board.roleAt(move.from) == Role.king; + final convertedMove = + isKingMove ? convertAltCastlingMove(move) ?? move : move; + final (newPos, newSan) = pos.makeSan(convertedMove); final newNode = Branch( - sanMove: SanMove(newSan, convertAltCastlingMove(move) ?? move), + sanMove: SanMove(newSan, convertedMove), position: newPos, ); return addNodeAt(path, newNode, prepend: prepend); diff --git a/pubspec.lock b/pubspec.lock index 2298a70746..408b72e001 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -769,26 +769,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: cdd14e3836065a1f6302a236ec8b5f700695c803c57ae11a1c84df31e6bcf831 + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.3" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9b2ef90589911d665277464e0482b209d39882dffaaf4ef69a3561a3354b2ebc" + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: fd3cd66cb2bcd7b50dcd3b413af49d78051f809c8b3f6e047962765c15a0d23d + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.0.1" linkify: dependency: "direct main" description: @@ -833,10 +833,10 @@ packages: dependency: "direct main" description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index dc28061d2c..64d78e16d0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Lichess mobile app V2 publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 0.7.4+000704 # see README.md for details about versioning +version: 0.7.5+000705 # see README.md for details about versioning environment: sdk: ">=3.3.0 <4.0.0" diff --git a/test/model/common/node_test.dart b/test/model/common/node_test.dart index 4261e32f8d..f0ee966732 100644 --- a/test/model/common/node_test.dart +++ b/test/model/common/node_test.dart @@ -506,6 +506,16 @@ void main() { ); }); }); + test('only convert king moves in altCastlingMove', () { + const pgn = + '1. e4 e5 2. Bc4 Qh4 3. Nf3 Qxh2 4. Ke2 Qxh1 5. Qe1 Qh5 6. Qh1'; + final root = Root.fromPgnGame(PgnGame.parsePgn(pgn)); + final initialPng = root.makePgn(); + final previousUciPath = root.mainlinePath.penultimate; + final move = Move.fromUci('e1g1'); + root.addMoveAt(previousUciPath, move!); + expect(root.makePgn(), isNot(initialPng)); + }); }); }