Chess: Fix draw claim check being too aggressive
This commit is contained in:
parent
a0c5a8e459
commit
d91d00d431
@ -2892,10 +2892,7 @@ function realchess.fields(pos, _, fields, sender)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local halfmoveClock = meta:get_int("halfmoveClock")
|
local halfmoveClock = meta:get_int("halfmoveClock")
|
||||||
if halfmoveClock == 99 then
|
if halfmoveClock >= 100 then
|
||||||
meta:set_string("drawClaim", "50_move_rule")
|
|
||||||
update_formspec(meta)
|
|
||||||
elseif halfmoveClock >= 100 then
|
|
||||||
meta:set_string("gameResult", "draw")
|
meta:set_string("gameResult", "draw")
|
||||||
meta:set_string("gameResultReason", "50_move_rule")
|
meta:set_string("gameResultReason", "50_move_rule")
|
||||||
add_special_to_moves_list(meta, "draw")
|
add_special_to_moves_list(meta, "draw")
|
||||||
@ -2906,7 +2903,8 @@ function realchess.fields(pos, _, fields, sender)
|
|||||||
end
|
end
|
||||||
minetest.log("action", "[xdecor] Chess: A game between "..playerWhite.." and "..playerBlack.." ended in a draw because "..claimer.." has invoked the 50-move rule")
|
minetest.log("action", "[xdecor] Chess: A game between "..playerWhite.." and "..playerBlack.." ended in a draw because "..claimer.." has invoked the 50-move rule")
|
||||||
else
|
else
|
||||||
send_message(claimer, S("Your draw claim is invalid!"), botColor)
|
meta:set_string("drawClaim", "50_move_rule")
|
||||||
|
update_formspec(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -2939,7 +2937,7 @@ function realchess.fields(pos, _, fields, sender)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local positions, first_p = get_positions_history(meta)
|
local positions, first_p = get_positions_history(meta)
|
||||||
local maxRepeatedPositions, lastOccurred = count_repeated_positions(positions, first_p)
|
local _, lastOccurred = count_repeated_positions(positions, first_p)
|
||||||
if lastOccurred >= 3 then
|
if lastOccurred >= 3 then
|
||||||
meta:set_string("gameResult", "draw")
|
meta:set_string("gameResult", "draw")
|
||||||
meta:set_string("gameResultReason", "same_position_3")
|
meta:set_string("gameResultReason", "same_position_3")
|
||||||
@ -2950,11 +2948,9 @@ function realchess.fields(pos, _, fields, sender)
|
|||||||
send_message(other, S("@1 has drawn the game by invoking the threefold repetition rule.", claimer), botColor)
|
send_message(other, S("@1 has drawn the game by invoking the threefold repetition rule.", claimer), botColor)
|
||||||
end
|
end
|
||||||
minetest.log("action", "[xdecor] Chess: A game between "..playerWhite.." and "..playerBlack.." ended in a draw because "..claimer.." has invoked the threefold repetition rule")
|
minetest.log("action", "[xdecor] Chess: A game between "..playerWhite.." and "..playerBlack.." ended in a draw because "..claimer.." has invoked the threefold repetition rule")
|
||||||
elseif maxRepeatedPositions == 2 then
|
else
|
||||||
meta:set_string("drawClaim", "same_position_3")
|
meta:set_string("drawClaim", "same_position_3")
|
||||||
update_formspec(meta)
|
update_formspec(meta)
|
||||||
else
|
|
||||||
send_message(claimer, S("Your draw claim is invalid!"), botColor)
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user