refactor(core): enhance castling logic to include rook movement and improve safety checks

This commit is contained in:
2026-04-05 19:17:23 +02:00
parent 2cd3ea35f6
commit 4cf39e3e97
7 changed files with 111 additions and 106 deletions
@@ -50,7 +50,7 @@ class PgnParserTest extends AnyFunSuite with Matchers:
test("parse queenside castling O-O-O"):
val pgn = """[Event "Test"]
1. d4 d5 2. Nc3 Nc6 3. Bf4 Bf5 4. O-O-O"""
1. d4 d5 2. Nc3 Nc6 3. Bf4 Bf5 4. Qd2 Qd7 5. O-O-O"""
val game = PgnParser.parsePgn(pgn)
game.isDefined shouldBe true
val lastMove = game.get.moves.last
@@ -71,7 +71,7 @@ class PgnParserTest extends AnyFunSuite with Matchers:
test("parse black queenside castling"):
val pgn = """[Event "Test"]
1. d4 d5 2. Nc3 Nc6 3. Bf4 Bf5 4. O-O-O O-O-O"""
1. d4 d5 2. Nc3 Nc6 3. Bf4 Bf5 4. Qd2 Qd7 5. O-O-O O-O-O"""
val game = PgnParser.parsePgn(pgn)
game.isDefined shouldBe true
val lastMove = game.get.moves.last