fix: NCS-32 Queenside Castle doesn't care about pieces in the way
Build & Test (NowChessSystems) TeamCity build finished
Build & Test (NowChessSystems) TeamCity build finished
This commit is contained in:
@@ -163,6 +163,12 @@ object DefaultRules extends RuleSet:
|
|||||||
CastlingMove("e8", "c8", "d8", "a8", MoveType.CastleQueenside))
|
CastlingMove("e8", "c8", "d8", "a8", MoveType.CastleQueenside))
|
||||||
moves.toList
|
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(
|
private def addCastleMove(
|
||||||
context: GameContext,
|
context: GameContext,
|
||||||
moves: scala.collection.mutable.ListBuffer[Move],
|
moves: scala.collection.mutable.ListBuffer[Move],
|
||||||
@@ -170,11 +176,8 @@ object DefaultRules extends RuleSet:
|
|||||||
castlingMove: CastlingMove
|
castlingMove: CastlingMove
|
||||||
): Unit =
|
): Unit =
|
||||||
if castlingRight then
|
if castlingRight then
|
||||||
// For queenside, also check the square between king destination and rook start
|
val clearSqs = (List(castlingMove.middleAlg, castlingMove.kingToAlg) ++ queensideBSquare(castlingMove.kingToAlg))
|
||||||
val extraSqs = if castlingMove.kingToAlg == "c1" then List("b1")
|
.flatMap(Square.fromAlgebraic)
|
||||||
else if castlingMove.kingToAlg == "c8" then List("b8")
|
|
||||||
else List.empty
|
|
||||||
val clearSqs = (List(castlingMove.middleAlg, castlingMove.kingToAlg) ++ extraSqs).flatMap(Square.fromAlgebraic)
|
|
||||||
if squaresEmpty(context.board, clearSqs) then
|
if squaresEmpty(context.board, clearSqs) then
|
||||||
for
|
for
|
||||||
kf <- Square.fromAlgebraic(castlingMove.kingFromAlg)
|
kf <- Square.fromAlgebraic(castlingMove.kingFromAlg)
|
||||||
|
|||||||
Reference in New Issue
Block a user