Compare commits

..

2 Commits

Author SHA1 Message Date
Janis fe8e3c0539 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>
2026-04-07 20:32:48 +02:00
TeamCity 1b16adcc72 ci: bump version with Build-33 2026-04-07 18:02:38 +00:00
6 changed files with 47 additions and 5 deletions
+5
View File
@@ -1,2 +1,7 @@
## (2026-04-06)
## (2026-04-07)
## (2026-04-07)
### Features
* NCS-30 FEN Parser using ParserCombinators ([#21](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/21)) ([b4bc72f](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/b4bc72f7e49f94d6e1bc805c68680e5fe8ef8e36))
+2 -2
View File
@@ -1,3 +1,3 @@
MAJOR=0
MINOR=0
PATCH=2
MINOR=1
PATCH=0
@@ -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)
@@ -52,7 +52,7 @@ class DefaultRulesTest extends AnyFunSuite with Matchers:
val moves = rules.allLegalMoves(context)
// King must move; e2 should be valid but d1 might be blocked by rook if still on same file
moves.filter(m => m.from == Square(File.E, Rank.R1)).nonEmpty shouldBe true
moves.exists(m => m.from == Square(File.E, Rank.R1)) shouldBe true
test("king cannot move to square attacked by opponent"):
// FEN: white king e1, black rook e2 defended by black king e3
@@ -109,6 +109,28 @@ class DefaultRulesTest extends AnyFunSuite with Matchers:
val castles = moves.filter(m => m.moveType == MoveType.CastleKingside)
castles.isEmpty shouldBe true
test("castling queenside is illegal when knight blocks on b8"):
// Black king e8, black rook a8, black knight b8 (blocks queenside path)
val board = Board(Map(
Square(File.A, Rank.R8) -> Piece(Color.Black, PieceType.Rook),
Square(File.B, Rank.R8) -> Piece(Color.Black, PieceType.Knight),
Square(File.E, Rank.R8) -> Piece(Color.Black, PieceType.King),
Square(File.A, Rank.R1) -> Piece(Color.White, PieceType.Rook),
Square(File.E, Rank.R1) -> Piece(Color.White, PieceType.King)
))
val context = GameContext(
board = board,
turn = Color.Black,
castlingRights = CastlingRights(whiteKingSide = true, whiteQueenSide = true, blackKingSide = true, blackQueenSide = true),
enPassantSquare = None,
halfMoveClock = 0,
moves = List.empty
)
val moves = rules.allLegalMoves(context)
val castles = moves.filter(m => m.moveType == MoveType.CastleQueenside)
castles.isEmpty shouldBe true
// ── En passant legality ──────────────────────────────────────────
test("en passant is legal when en passant square is set"):
+8
View File
@@ -41,3 +41,11 @@
* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
## (2026-04-07)
### Features
* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
+1 -1
View File
@@ -1,3 +1,3 @@
MAJOR=0
MINOR=6
MINOR=7
PATCH=0