fix(wordgame): correct scoring, game-end on correct guess, and concurrent guess race#189
Merged
Conversation
- fix: letter bonus dedup no longer blocks position bonus for repeated letters - fix: guessing the word no longer sets bonus_guess_at (game is won, no bonus needed) - fix: add per-thread asyncio locks so concurrent guesses re-read fresh Config state, preventing double-scoring on claimed_positions - refactor: _process_guess now reads game state fresh under lock instead of using caller-provided snapshot
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.
Fixes #188
Summary
Three bugs in the wordgame cog:
bonus_guess_atset, so they received a bonus guess DM 5 minutes later and could keep guessing.claimed_positions, so two players could each earn position bonus for the same(letter, position)pair.seen_letterscontinuealso skipped the position-bonus check for repeated letters in the same guess (e.g. the secondpinpoppywould neither earn a letter bonus nor a position bonus, losing 1 pt).Changes
wordgame/game.py— decouple letter bonus dedup from position bonus check; both are now evaluated independently per characterwordgame/wordgame.py— add per-threadasyncio.Lock;_process_guessnow acquires the lock and re-reads fresh Config state before scoring; skipbonus_guess_atwhen word is guessed correctlyTesting
python -m py_compile wordgame/game.py wordgame/wordgame.pypoppy= 10 pts max