Skip to content

Instantly share code, notes, and snippets.

@tommy-mor
Created November 30, 2025 22:09
Show Gist options
  • Select an option

  • Save tommy-mor/eea1e4b12e9c31f574a59ddafd3b0239 to your computer and use it in GitHub Desktop.

Select an option

Save tommy-mor/eea1e4b12e9c31f574a59ddafd3b0239 to your computer and use it in GitHub Desktop.

Based on the code analysis, the Playoff system in this codebase is a season-bound, manually seeded bracket system with a built-in Map Ban/Pick phase.

Unlike the automated Swiss-style matchmaking used for the regular season, Playoffs require specific Administrative intervention to move from one round to the next.

Here is the full lifecycle of a Playoff:

1. Configuration (Admin Side)

Before playoffs start, an Admin must configure the season.

  • Route: /manage_playoffs (in routes/adminDashboard.js)
  • Action: The admin selects a Season and defines:
    • Format: "Tournament" or "Rounds".
    • Num Rounds: (e.g., 3 for Quarter/Semi/Finals).
    • Double Elimination: Yes/No (stored as 0 or 1).
  • Database: This creates a row in the playoffs table linking to the seasons table.

2. Match Creation / Seeding (Round 1)

The system does not automatically seed teams based on standings. An Admin must manually create the bracket matchups.

  • Route: /admin/create_match_set (in routes/adminMatches.ts)
  • UI: In the Admin panel > Create Matches tab.
  • Process:
    1. Admin toggles "Playoff Match" checkbox.
    2. Selects the Region, Season, and Playoff Round (e.g., "Upper Round 1").
    3. Selects Best of Series (Bo1, Bo3, Bo5, Bo7).
    4. Selects a Map Ban Pool.
    5. Crucial Step: The Admin manually selects Home Team vs Away Team from dropdowns for every match in that round.
  • Output: Creates rows in the matches table with playoffId populated and status = 0 (Unplayed). It also creates placeholder rows in the games table (e.g., 3 games for a Bo3) with arenaId set to null (TBD).

3. The Map Veto Phase (User Side)

Before the match is played, teams must determine which maps (Arenas) they will play.

  • Route: /match_page/:matchid/map-action (in routes/matches.ts)
  • Logic:
    • The system checks match_map_bans to see whose turn it is.
    • Bo3 Pattern: Away Ban → Home Ban → Home Pick → Away Pick → Away Ban → Home Pick.
    • Bo5 Pattern: Away Ban → Home Ban → Home Pick → Away Pick → Away Ban → Home Pick → Away Pick → Home Pick.
  • Effect: When a team Picks a map, the system updates the games table.
    • Example: If Team A picks "Badlands" as the 1st pick, the system updates Game 1 in the database to set arenaId to the ID for Badlands.

4. Playing & Reporting Scores

  • Route: /match_page/:matchid/update-scores
  • Process:
    • Teams play the maps determined in the Veto phase.
    • Scores are reported per map (Game).
  • Winner Calculation:
    • The system tallies the wins. If a team wins 2 maps in a Bo3, they are declared the winner.
    • If a match is finished (e.g., 2-0 in a Bo3), the system automatically marks the unplayed 3rd game as null/void.
  • Database Update: The matches table is updated with winnerId, winnerScore (series score, e.g., 2), and loserScore (e.g., 1).

5. Advancement (Admin Side)

There is no automatic bracket advancement. The code does not automatically move the winner of Match A to Match C.

  • Logic:
    1. The Admin views the results of "Upper Round 1".
    2. The Admin goes back to Create Match Set.
    3. The Admin changes the dropdown to "Upper Round 2".
    4. The Admin manually selects the winning teams from the previous round to face each other.
    5. This process repeats for Semi-Finals and Grand Finals.

Special Case: World Championships

There is a separate, distinct system for "World Championships" located in routes/worldChampionships.ts. This seems to be a newer or specialized implementation separate from the standard Season/League loop.

  • Separate Tables: Uses championship, championship_match, championship_participant.
  • UI: Uses a specific view WorldChampionship.ejs with tabs for Day 1 / Day 2 / Qualifiers.
  • Logic: It allows for more complex visual representations (groups stages, specific bracket rendering) but still relies heavily on Admin input to set winners and create specific match instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment