Skip to content

Commit

Permalink
further refactoring of slot null checks to optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
VINXIS committed Oct 3, 2024
1 parent eeeaebd commit c514efc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BanchoLobby, BanchoLobbyPlayer } from "bancho.js";

export default function areAllPlayersInAssignedSlots (mpLobby: BanchoLobby, playersPlaying: BanchoLobbyPlayer[] | undefined) {
return !playersPlaying || playersPlaying.every(p => mpLobby.slots.some(s => s !== null && s.user.id === p.user.id));
return !playersPlaying || playersPlaying.every(p => mpLobby.slots.some(s => s?.user.id === p.user.id));
}
6 changes: 3 additions & 3 deletions BanchoBot/functions/tournaments/matchup/runMatchup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,12 @@ async function runMatchupListeners (matchup: Matchup, mpLobby: BanchoLobby, mpCh
if (
(
matchup.stage!.stageType === StageType.Qualifiers &&
matchup.teams!.some(team => !mpLobby.slots.some(m => m !== null && m.user.id.toString() === team.captain.osu.userID))
matchup.teams!.some(team => !mpLobby.slots.some(m => m?.user.id.toString() === team.captain.osu.userID))
) ||
(
matchup.stage!.stageType !== StageType.Qualifiers &&
!mpLobby.slots.some(m => m !== null && m.user.id.toString() === matchup.team1!.captain.osu.userID) &&
!mpLobby.slots.some(m => m !== null && m.user.id.toString() === matchup.team2!.captain.osu.userID)
!mpLobby.slots.some(m => m?.user.id.toString() === matchup.team1!.captain.osu.userID) &&
!mpLobby.slots.some(m => m?.user.id.toString() === matchup.team2!.captain.osu.userID)
)
) {
await mpChannel.sendMessage(`${newPlayer.user.username} waiting for all ${matchup.stage!.tournament.matchupSize === 1 ? "players" : "captains"} to be here before matchup starts`);
Expand Down

0 comments on commit c514efc

Please sign in to comment.