[board] When loading a FEN string, start with no castling rights

The default value of the castle::Rights struct is with all rights granted. When
loading a FEN string, start with none and add to it.
This commit is contained in:
Eryn Wells 2025-06-18 08:26:29 -07:00
parent 9972ce94d0
commit 933924d37a

View file

@ -229,9 +229,8 @@ impl FromFenStr for Board {
let castling_rights = fields
.next()
.ok_or(FromFenStrError::MissingField(Field::CastlingRights))?;
if castling_rights == "-" {
board.revoke_all_castling_rights();
} else {
board.revoke_all_castling_rights();
if castling_rights != "-" {
for ch in castling_rights.chars() {
match ch {
'K' => board.grant_castling_right(Color::White, Wing::KingSide),