Skip to content

Fix confetti firing for non-unanimous votes (#16)#17

Open
martijn wants to merge 2 commits into
mainfrom
claude/open-issue-wgey38
Open

Fix confetti firing for non-unanimous votes (#16)#17
martijn wants to merge 2 commits into
mainfrom
claude/open-issue-wgey38

Conversation

@martijn

@martijn martijn commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Fixes #16.

The bug

Confetti celebrated whenever the votes that had arrived on a client so far happened to match. Because votes and the "show votes" signal are delivered independently over SignalR, a client could process the reveal before a differing vote (e.g. someone voting 1) arrived, briefly see an apparently unanimous set, and fire confetti for a round that was not unanimous.

The fix

Decide the celebration once, authoritatively, at reveal time.

  • The player who clicks Show votes computes unanimity against their own state — they have the full picture — and the result rides along on the VotesShown event as a ShowConfetti flag.
  • Every client simply honours that flag, so confetti can no longer fire on one client for a round another client saw as non-unanimous. The local race is gone.

Lock the round after reveal.

  • VoteCast events are dropped once votes have been shown, so a late or post-reveal vote can no longer alter a locked round.
  • GameReset clears ShowConfetti so the next round starts clean.

Unanimity ignores abstentions.

  • GameState.IsUnanimous() returns true when more than one player cast a numeric vote and all such votes match. Players who abstained — did not vote (Pending) or picked a non-numeric option (☕️/❓) — are ignored. So 2,2,2,1,(abstain) → no confetti, while 2,2,2,(abstain) → confetti.

Tests

  • GameStateExtensionsTests — unanimity, the reported 2,2,2,1,abstained case, abstentions ignored, all-abstain, single player.
  • GameAggregateTests — post-reveal votes dropped, ShowConfetti propagation, reset clears it.

Note: I was unable to build or run the test suite in the authoring environment (the .NET 10 SDK isn't installed and egress to the SDK host is blocked). Please rely on CI / a local dotnet test run to confirm.

https://claude.ai/code/session_01Di2fXRK9wbnM52f9QJDay9

claude added 2 commits June 13, 2026 11:40
Confetti celebrated whenever the non-pending votes that had arrived so far
all matched. Because votes and the "show votes" signal are delivered
independently over SignalR, a client could process the reveal before a
differing vote (e.g. someone voting 1) arrived, see an apparently
unanimous set, and fire confetti for a round that was not unanimous.

Only celebrate once the round is fully settled: every player must have
cast the same numeric vote. A pending vote (not voted yet, or still in
transit) now blocks the celebration, so a late differing vote can no
longer trigger a false positive. The check is re-evaluated on every
render while votes are shown, so a unanimous result that settles just
after the reveal still celebrates.

Extracted the logic into a testable GameState.IsUnanimous extension and
added unit tests covering the reported scenario.
Make the celebration decision authoritative instead of letting each
client re-evaluate against its own, possibly incomplete, state:

- The player who reveals the votes computes unanimity (which they can do
  reliably since they have the full picture) and the result rides along
  on the VotesShown event as a ShowConfetti flag. Every client simply
  honours that flag, so confetti can no longer fire on one client for a
  round that was not unanimous.
- VoteCast events are now dropped once votes have been shown, so a late
  or post-reveal vote can't change a locked round.

IsUnanimous goes back to ignoring abstentions (no vote / Coffee /
Question): with the decision made once by the revealer there is no race
to guard against, so abstaining no longer suppresses the celebration.

Added GameAggregate tests for dropping post-reveal votes and for the
ShowConfetti flag, and updated the unanimity tests accordingly.
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.

Confetti triggers for vote that is not unanimous

2 participants