Skip to content

feat: distinct response message for already-cited words#26

Merged
FlorentPoinsaut merged 3 commits intomainfrom
copilot/add-duplicate-word-handling
Mar 8, 2026
Merged

feat: distinct response message for already-cited words#26
FlorentPoinsaut merged 3 commits intomainfrom
copilot/add-duplicate-word-handling

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

When a player submits a word already guessed earlier in the same round, the bot responds with a distinct message and the duplicate word is excluded from the leaderboard and overlay.

Changes

  • game/state.py: Added already_cited: bool to GuessResult. submit_guess() checks whether the normalized word already exists in _history before appending. If the word was already cited, it is not appended to _history, preventing duplicates from appearing in top_guesses() and the overlay leaderboard.

  • bot/bot.py: New branch in guess handler for the already_cited case:

    • With score: 'chien' has already been suggested (50% similarity).
    • Without score: 'chien' has already been suggested.
    • is_found still takes priority — winning guesses always show the win message.
  • Tests: TestAlreadyCited (7 tests) in test_game_state.py covering first-guess, same/different user, normalisation, duplicate exclusion from history, and new-game reset. TestGameStateLeaderboard updated with a dedicated test verifying already-cited words are excluded from top_guesses(). Three new tests in test_commands.py covering bot responses for scored, unscored, and winning already-cited words.

# Example flow
gs.submit_guess("alice", "chien")  # → already_cited=False, appended to history
result = gs.submit_guess("bob", "chien")
result.already_cited  # → True, NOT appended to history
# bot sends: "'chien' has already been suggested (50% similarity)."
# "chien" appears only once in top_guesses() / overlay

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add handling for already mentioned words feat: distinct response message for already-cited words Mar 6, 2026
@FlorentPoinsaut FlorentPoinsaut marked this pull request as ready for review March 6, 2026 15:13
Copilot AI and others added 2 commits March 8, 2026 20:59
- Add `already_cited` flag to `GuessResult` in game/state.py
- Detect duplicate normalized words in `submit_guess()` before appending
- Send a specific message in bot.py when a word was already suggested
- Add `TestAlreadyCited` tests in test_game_state.py (7 tests)
- Add 3 new tests in test_commands.py for the already-cited bot response

Co-authored-by: FlorentPoinsaut <1256948+FlorentPoinsaut@users.noreply.github.com>
@FlorentPoinsaut FlorentPoinsaut force-pushed the copilot/add-duplicate-word-handling branch from 01fc049 to 4276c7a Compare March 8, 2026 20:59
@FlorentPoinsaut
Copy link
Member

@copilot Les mots dupliqués sont quand même ajoutés au TOP GUESSES de l'overlay alors qu'ils ne devraient pas y être ajoutés

Already-cited words are no longer appended to _history, so they
no longer appear in top_guesses() and the overlay leaderboard.

- game/state.py: skip _history.append() when already_cited=True
- tests: assert duplicates NOT appended; fix test_top_guesses_respects_n
  to use distinct words; add test_already_cited_word_excluded_from_top_guesses

Co-authored-by: FlorentPoinsaut <1256948+FlorentPoinsaut@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot Les mots dupliqués sont quand même ajoutés au TOP GUESSES de l'overlay alors qu'ils ne devraient pas y être ajoutés

Corrigé dans le commit 51387a1. Les mots déjà cités ne sont plus ajoutés à _history, donc ils n'apparaissent plus dans top_guesses() ni dans l'overlay.

@FlorentPoinsaut FlorentPoinsaut merged commit 2693753 into main Mar 8, 2026
2 checks passed
@FlorentPoinsaut FlorentPoinsaut deleted the copilot/add-duplicate-word-handling branch March 8, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants