fix: update move validation to check for king safety (#13)
Build & Test (NowChessSystems) TeamCity build finished

Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
2026-04-01 09:07:06 +02:00
parent 13bfc16cfe
commit e5e20c566e
3 changed files with 25 additions and 2 deletions
@@ -75,7 +75,7 @@ object GameController:
case None => MoveResult.NoPiece
case Some(piece) if piece.color != turn => MoveResult.WrongColor
case Some(_) =>
if !MoveValidator.isLegal(board, history, from, to) then MoveResult.IllegalMove
if !GameRules.legalMoves(board, history, turn).contains(from -> to) then MoveResult.IllegalMove
else if MoveValidator.isPromotionMove(board, from, to) then
MoveResult.PromotionRequired(from, to, board, history, board.pieceAt(to), turn)
else applyNormalMove(board, history, turn, from, to)