fix: NCS-32 Queenside Castle doesn't care about pieces in the way (#23)
Build & Test (NowChessSystems) TeamCity build finished

Reviewed-on: #23
Co-authored-by: Janis <janis.e.20@gmx.de>
Co-committed-by: Janis <janis.e.20@gmx.de>
This commit was merged in pull request #23.
This commit is contained in:
2026-04-07 20:32:48 +02:00
committed by Janis
parent 1b16adcc72
commit fe8e3c0539
2 changed files with 31 additions and 2 deletions
@@ -163,6 +163,12 @@ object DefaultRules extends RuleSet:
CastlingMove("e8", "c8", "d8", "a8", MoveType.CastleQueenside))
moves.toList
private def queensideBSquare(kingToAlg: String): List[String] =
kingToAlg match
case "c1" => List("b1")
case "c8" => List("b8")
case _ => List.empty
private def addCastleMove(
context: GameContext,
moves: scala.collection.mutable.ListBuffer[Move],
@@ -170,7 +176,8 @@ object DefaultRules extends RuleSet:
castlingMove: CastlingMove
): Unit =
if castlingRight then
val clearSqs = List(castlingMove.middleAlg, castlingMove.kingToAlg).flatMap(Square.fromAlgebraic)
val clearSqs = (List(castlingMove.middleAlg, castlingMove.kingToAlg) ++ queensideBSquare(castlingMove.kingToAlg))
.flatMap(Square.fromAlgebraic)
if squaresEmpty(context.board, clearSqs) then
for
kf <- Square.fromAlgebraic(castlingMove.kingFromAlg)