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

This commit is contained in:
2026-04-07 20:28:40 +02:00
parent ed540e38d6
commit a02b1bedc7
@@ -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,11 +176,8 @@ object DefaultRules extends RuleSet:
castlingMove: CastlingMove
): Unit =
if castlingRight then
// For queenside, also check the square between king destination and rook start
val extraSqs = if castlingMove.kingToAlg == "c1" then List("b1")
else if castlingMove.kingToAlg == "c8" then List("b8")
else List.empty
val clearSqs = (List(castlingMove.middleAlg, castlingMove.kingToAlg) ++ extraSqs).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)