From: Damian Hofmann Date: Sun, 7 Jun 2020 02:01:48 +0000 (+0200) Subject: Chess: Fix queen-side castling X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=16adad0cd7a0e5ca685bd80a0f0cfafcc2fb0011;p=xdecor.git Chess: Fix queen-side castling When castling queen side, the king moves two squares to the left, not three as this implementation used previously. This resolves issue #120. --- diff --git a/src/chess.lua b/src/chess.lua index be7fc96..4529955 100644 --- a/src/chess.lua +++ b/src/chess.lua @@ -1096,7 +1096,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player if thisMove == "white" then if from_y == 7 and to_y == 7 then - if to_x == 1 then + if to_x == 2 then local castlingWhiteL = meta:get_int("castlingWhiteL") local idx57 = inv:get_stack(from_list, 57):get_name() @@ -1108,7 +1108,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player end inv:set_stack(from_list, 57, "") - inv:set_stack(from_list, 59, "realchess:rook_white_1") + inv:set_stack(from_list, 60, "realchess:rook_white_1") check = false end elseif to_x == 6 then @@ -1130,7 +1130,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player end elseif thisMove == "black" then if from_y == 0 and to_y == 0 then - if to_x == 1 then + if to_x == 2 then local castlingBlackL = meta:get_int("castlingBlackL") local idx1 = inv:get_stack(from_list, 1):get_name() @@ -1142,7 +1142,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player end inv:set_stack(from_list, 1, "") - inv:set_stack(from_list, 3, "realchess:rook_black_1") + inv:set_stack(from_list, 4, "realchess:rook_black_1") check = false end elseif to_x == 6 then