fix(chess): flag flag-fall on a running clock in PlayerClock::time_out() - #944
Open
abdulwaarith0 wants to merge 1 commit into
Open
Conversation
time_out() checked the raw remaining_time field, which is only decremented on stop(). While a clock is_running, elapsed time is not yet reflected there, so a player who sits on a running clock past zero on their own turn was never reported as flagged. Route time_out() through get_real_time_remaining(), which already accounts for the running clock, so on-the-move flag-fall is detected. Adds unit tests for the stopped, running-past-zero, and running-with-time-left cases. Closes OpenKnight-Foundation#941
Contributor
Author
|
Heads up for reviewers: the failing Test Backend job is a pre-existing breakage on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PlayerClock::time_out()checked the rawremaining_timefield, which is only decremented onstop(). While a clockis_running, elapsed time is not yet reflected inremaining_time, so a player who sits on a running clock past zero on their own turn was never reported as flagged — exactly the case flag-detection must catch.The clock already has
get_real_time_remaining(), which subtracts the running elapsed time. This routestime_out()through it:Tests
Added unit tests in
time_control.rs:remaining_timeis zeroremaining_timeis still non-zero; detection must come from real remaining time)All three pass locally.
Closes #941