Overview
AutoRefQualifiersStage handles the automated refereeing logic for Qualifier Lobbies. It manages a linear flow of maps with no picks/bans, cycling through the entire map pool sequentially.
Namespace: ss.Internal.Management.Server.AutoRef
Class Definition
State Machine
State Enum
State Descriptions
| State | Description |
|---|---|
Idle | Cooldown/loading state between maps |
WaitingForStart | Map loaded, timer active, waiting for players to ready up |
Playing | Map in progress, waiting for completion |
MatchFinished | All maps in the pool have been played |
MatchOnHold | Panic mode - automation paused |
State Transition Diagram
Key Methods
StartAsync()
Initializes the qualifier room and connects to Bancho.- Loads
QualifierRoomfrom database bymatchId - Validates referee credentials
- Loads round configuration and map pool
- Retrieves list of players assigned to this room
- Connects to Bancho IRC
- Creates tournament lobby
StopAsync()
Saves match state and closes the lobby.MpLinkId: osu! match ID for score tracking
HandleIrcMessage()
Core event loop that drives the state machine.- Parse IRC messages from BanchoBot
- Detect lobby creation and extract MP link ID
- Handle
!panicemergency protocol - Detect match completion
- Process admin commands (prefix:
>) - Drive state transitions via
TryStateChange()
ExecuteAdminCommand()
Processes referee commands.| Command | Syntax | Description |
|---|---|---|
>finish | >finish | Closes the lobby |
>invite | >invite | Invites all assigned players to the lobby |
>setmap | >setmap [slot] | Manually sets a map (requires Idle state) |
>start | >start | Engages automation and starts qualifier flow |
>stop | >stop | Stops automation |
StartQualifiersFlow()
Initializes the qualifier lifecycle.- Resets
currentMapIndexto 0 - Sets state to
Idle - Calls
PrepareNextQualifierMap()to load first map
PrepareNextQualifierMap()
Iterates to the next map in the pool and prepares it for play.- Checks if all maps have been played
- If finished, transitions to
MatchFinishedstate - Otherwise, loads next map by
BeatmapID - Applies mods based on slot prefix (e.g.,
NM,HD,HR) - Adds
NF(No Fail) mod - Starts 120-second ready timer
- Transitions to
WaitingForStart
TryStateChange()
The state machine brain - evaluates Bancho messages and transitions states.Idle State
WaitingForStart State
Playing State
Map Pool Iteration
The qualifier flow is fully linear:- Start:
>startcommand setscurrentMapIndex = 0 - Load Map:
PrepareNextQualifierMap()loads map at current index - Play Map: Players ready up, timer expires, or all ready → map starts
- Complete Map: Match finishes → increment
currentMapIndex - Cooldown: 10-second delay before loading next map
- Repeat: Go to step 2 until all maps are played
- Finish: When
currentMapIndex >= MapPool.Count, transitions toMatchFinished
Timer Management
Qualifiers use different timers than elimination matches:| Event | Timer Duration | Command |
|---|---|---|
| Map ready phase | 120 seconds | !mp timer 120 |
| Match start delay | 10 seconds | !mp start 10 |
| Map cooldown | 10 seconds | Task.Delay(10000) |
| Panic recovery | 10 seconds | !mp timer 10 |
Panic Protocol
Identical to elimination matches: Trigger: Anyone types!panic
>panic_over
Player Invitations
The>invite command iterates through all players assigned to the room:
- Loaded from database during
StartAsync() - Query:
Players.Where(p => p.QualifierRoomId == matchId).Select(p => p.User.OsuID) - Stored in
List<int> usersInRoom
Lobby Settings
Qualifiers use Head-to-Head mode:- Team Mode: 0 (Head-to-Head)
- Win Condition: 3 (ScoreV2)
- Slots: 16 (allows multiple players simultaneously)
Cooldown System
After each map, a 10-second cooldown prevents immediate transitions:- Gives players time to review scores
- Prevents spamming Bancho with rapid map changes
- Allows for brief discussions between maps
Internal Fields
Differences from Elimination Automaton
| Feature | Qualifiers | Elimination |
|---|---|---|
| Team Mode | Head-to-Head (0) | TeamVs (2) |
| Map Selection | Linear (full pool) | Pick/Ban phases |
| Player Count | Multiple (1-16) | Two teams |
| State Complexity | Simple (4 states) | Complex (13 states) |
| Timeout System | None | Per-team tactical timeouts |
| Win Condition | Complete all maps | Best-of-N |
| Map Order | Sequential | Player-chosen |
| Timer Duration | 120 seconds | 90 seconds |