nvzqz / Sage

A cross-platform chess library for Swift
Apache License 2.0
373 stars 43 forks source link

castling rights on rook capture. closes nvzqz/Sage#8 #13

Closed captainsano closed 7 years ago

nvzqz commented 7 years ago

This does not restore rook castling rights if the capture is undone.

Also, the if let _ = capture?.kind.isRook { part passes for any capture. Instead do:

if let capture = capture, capture.kind.isRook {
    ...
}
captainsano commented 7 years ago

Made the change with if let ... _undoMove seems to already restore the castling rights. What do you mean by undoing the capture?

nvzqz commented 7 years ago

Sorry, I should've specified. It's been a while since I looked through the code for the project. You're right. I forgot that castling rights were retained in history.

It also may look cleaner to use the isWhite and isBlack properties of Color.

One last thing, the tests on Xcode 7.3 fail to compile: https://travis-ci.org/nvzqz/Sage/jobs/185092484

captainsano commented 7 years ago

Done, build passing now!