mirror of
https://github.com/SleepingInsomniac/lx_chess_cr
synced 2024-11-16 19:49:34 +01:00
Fix castling check when converting move to SAN
This commit is contained in:
parent
a66bf70a65
commit
eafa4e0fbb
1 changed files with 16 additions and 3 deletions
|
@ -153,7 +153,20 @@ module LxChess
|
|||
end
|
||||
|
||||
checkmate = check ? tmp_move(from, to) { checkmate?(next_turn(turn)) } : false
|
||||
castling = piece.king? ? to - from : nil
|
||||
|
||||
castles_k = false
|
||||
castles_q = false
|
||||
|
||||
if piece.king?
|
||||
dist = (to - from)
|
||||
if dist.abs == 2
|
||||
if dist.positive?
|
||||
castles_k = true
|
||||
else
|
||||
castles_q = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Notation.new(
|
||||
square: @board.cord(to),
|
||||
|
@ -165,8 +178,8 @@ module LxChess
|
|||
en_passant: en_passant,
|
||||
check: check && !checkmate,
|
||||
checkmate: checkmate,
|
||||
castles_k: castling && castling.positive? || false,
|
||||
castles_q: castling && castling.negative? || false
|
||||
castles_k: castles_k,
|
||||
castles_q: castles_q
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue