mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
LibChess+Chess: Ensure no pawns have moved when invoking 50 move rule
The 50 and 75 move rules are no longer invoked if a pawn has advanced in the last 50 or 75 moves respectively.
This commit is contained in:
parent
4fb200a546
commit
ccab25e54e
2 changed files with 5 additions and 3 deletions
|
@ -697,7 +697,7 @@ bool ChessWidget::check_game_over(ClaimDrawBehavior claim_draw_behavior)
|
||||||
case Chess::Board::Result::FiftyMoveRule:
|
case Chess::Board::Result::FiftyMoveRule:
|
||||||
if (claim_draw_behavior == ClaimDrawBehavior::Prompt) {
|
if (claim_draw_behavior == ClaimDrawBehavior::Prompt) {
|
||||||
update();
|
update();
|
||||||
auto dialog_result = GUI::MessageBox::show(window(), "50 moves have elapsed without a capture. Claim Draw?"sv, "Claim Draw?"sv,
|
auto dialog_result = GUI::MessageBox::show(window(), "50 moves have elapsed without a capture or pawn advance. Claim Draw?"sv, "Claim Draw?"sv,
|
||||||
GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo);
|
GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo);
|
||||||
|
|
||||||
if (dialog_result != GUI::Dialog::ExecResult::Yes)
|
if (dialog_result != GUI::Dialog::ExecResult::Yes)
|
||||||
|
|
|
@ -774,9 +774,11 @@ Board::Result Board::game_result() const
|
||||||
});
|
});
|
||||||
|
|
||||||
if (are_legal_moves) {
|
if (are_legal_moves) {
|
||||||
if (m_moves_since_capture >= 75 * 2)
|
if (m_moves_since_capture >= 75 * 2 && m_moves_since_pawn_advance >= 75 * 2)
|
||||||
return Result::SeventyFiveMoveRule;
|
return Result::SeventyFiveMoveRule;
|
||||||
if (m_moves_since_capture == 50 * 2)
|
|
||||||
|
if ((m_moves_since_capture >= 50 * 2 && m_moves_since_pawn_advance == 50 * 2)
|
||||||
|
|| (m_moves_since_pawn_advance >= 50 * 2 && m_moves_since_capture == 50 * 2))
|
||||||
return Result::FiftyMoveRule;
|
return Result::FiftyMoveRule;
|
||||||
|
|
||||||
auto repeats = m_previous_states.get(Traits<Board>::hash(*this));
|
auto repeats = m_previous_states.get(Traits<Board>::hash(*this));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue