Skip to content

Remove players from multiplayer room on leave if they have no stats or buzzes#454

Merged
geoffrey-wu merged 2 commits intomainfrom
copilot/remove-players-on-leave
Mar 8, 2026
Merged

Remove players from multiplayer room on leave if they have no stats or buzzes#454
geoffrey-wu merged 2 commits intomainfrom
copilot/remove-players-on-leave

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

Players who join and immediately leave (never buzzing or hearing a completed tossup) were kept as offline "ghost" entries in the room's player list. These should be fully removed rather than retained as offline.

Changes

  • Player.js: Add buzzes field (reset in clearStats()) and hasActivity() method — returns true if any of tuh, buzzes, powers, tens, zeroes, or negs are non-zero
  • TossupRoom.js: Increment player.buzzes on each buzz
  • Room.js: leave() now branches on player.hasActivity():
    • No activity → delete from players and teams, emit { type: 'leave', remove: true }
    • Has activity → existing offline behavior unchanged
  • MultiplayerTossupBonusClient.js: Client leave() handler removes the DOM element and player state when remove: true; otherwise falls through to existing offline styling
// Room.js
leave (userId) {
  if (!this.players[userId]) { return; }
  const player = this.players[userId];
  const username = player.username;
  delete this.sockets[userId];
  if (!player.hasActivity()) {
    delete this.players[userId];
    delete this.teams[userId];
    this.emitMessage({ type: 'leave', userId, username, remove: true });
  } else {
    player.online = false;
    this.emitMessage({ type: 'leave', userId, username });
  }
}

On reconnect after removal, the player is treated as isNew and gets a fresh entry — no special handling needed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove players from multiplayer room on leave if they record no stats and no buzzes</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

… and no buzzes

Co-authored-by: geoffrey-wu <42471355+geoffrey-wu@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove players from multiplayer room on leave if no stats or buzzes Remove players from multiplayer room on leave if they have no stats or buzzes Mar 1, 2026
@geoffrey-wu geoffrey-wu marked this pull request as ready for review March 8, 2026 21:20
@geoffrey-wu geoffrey-wu merged commit 1884e66 into main Mar 8, 2026
@geoffrey-wu geoffrey-wu deleted the copilot/remove-players-on-leave branch March 8, 2026 21:20
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.

Remove players from multiplayer room on leave if they record no stats and no buzzes

2 participants