# Check for grand finals reset if is_grand_finals(match) and match.bracket == "losers": if winner_id == lb_champion and wb_champion_exists: create_reset_match() class DoubleElimGenerator constructor(players) this.players = players; this.wbMatches = []; this.lbMatches = []; this.gfMatch = null; this.resetMatch = null; this.generate(); generate() let size = 1; while (size < this.players.length) size <<= 1; const padded = [...this.players, ...Array(size - this.players.length).fill(null)];
def report_winner(match_id, winner_id): match = get_match(match_id) match.winner_id = winner_id if match.bracket == "winners": next_match = match.next_match slot = match.next_match_slot # "player1" or "player2" set_player_in_match(next_match, slot, winner_id) double elimination tournament generator
def _build(self): # Build WB round 1 r1 = [] for i in range(0, self.size, 2): r1.append([self.players[i] if i < len(self.players) else None, self.players[i+1] if i+1 < len(self.players) else None]) self.wb[0] = r1 # Check for grand finals reset if is_grand_finals(match)