Skip to content

fix(referee): broadcast pvp_win only once per match - #505

Open
ChronoFinale wants to merge 1 commit into
Balatro-Multiplayer:mqttfrom
ChronoFinale:pr/pvp-win-once
Open

fix(referee): broadcast pvp_win only once per match#505
ChronoFinale wants to merge 1 commit into
Balatro-Multiplayer:mqttfrom
ChronoFinale:pr/pvp-win-once

Conversation

@ChronoFinale

@ChronoFinale ChronoFinale commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

The win jingle and win screen could fire multiple times at match end when stray duplicate events re-broadcast pvp_win. Guard the win broadcast with a match_over flag so it fires exactly once.

Rebased onto current mqtt — re-expressed onto the new N-player referee's consolidated check_alive_win path. Test: luajit tests/test_referee_match_over.lua — green.

Closes #488

Testing

  • Loaded up match, played until lost, verified no win screen firing multiple times (not the easiest thing to test)

The host referee re-ran try_resolve_round on every play_hand it received
(both players, including the host's own loopback, plus stray sends like
play_hand(chips,0) and play_hand(0,0) near match end). Once a player's
lives hit 0, lose_life was blocked from decrementing further but the
pvp_win broadcast had no match-over guard, so it re-fired on every
subsequent resolution attempt. Each broadcast loops back through
action_win_game/action_lose_game and replays the win jingle and screen.

Add a match_over flag to MP.REF, set the first time any pvp_win broadcast
site fires (round resolution, survival furthest-blind win, fail_round,
fail_timer, fail_pvp_timer) and reset on MP.referee_reset. Also make
action_win_game/action_lose_game idempotent against MP.GAME.won/lost as a
second line of defense against duplicate winGame/loseGame dispatches.
@ChronoFinale
ChronoFinale marked this pull request as ready for review July 23, 2026 22:51
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.

1 participant