]> git.sesse.net Git - remoteglot/blobdiff - Board.pm
Fix a castling edge case in Chess960 positions where the kings start on the e-file...
[remoteglot] / Board.pm
index 8565c845c279860abf9e029b2abbc50b5b597398..6fb413ac906ed5670930f3d62750f8519260207f 100644 (file)
--- a/Board.pm
+++ b/Board.pm
@@ -44,8 +44,8 @@ sub make_move {
 
        if ($piece eq 'K') {
                # Convert to Chess960 king-takes-rook.
-               $to_col = 7 if ($move eq 'e1g1');
-               $to_col = 0 if ($move eq 'e1c1');
+               $to_col = 7 if ($move eq 'e1g1' && $board->[$to_row][$to_col] ne 'R');
+               $to_col = 0 if ($move eq 'e1c1' && $board->[$to_row][$to_col] ne 'R');
 
                my $dst_piece = $board->[$to_row][$to_col];
 
@@ -71,8 +71,8 @@ sub make_move {
                }
        } elsif ($piece eq 'k') {
                # Convert to Chess960 king-takes-rook.
-               $to_col = 7 if ($move eq 'e8g8');
-               $to_col = 0 if ($move eq 'e8c8');
+               $to_col = 7 if ($move eq 'e8g8' && $board->[$to_row][$to_col] ne 'r');
+               $to_col = 0 if ($move eq 'e8c8' && $board->[$to_row][$to_col] ne 'r');
 
                my $dst_piece = $board->[$to_row][$to_col];