24/7 room
Teams, captains and picking
The PickController rules: always-equal teams, captains, champion rotation, AFK and commands.
The 24/7 room's PickController builds and rotates the teams. Everything is computed from maxTeamSize (N), and the central goal is that no match ever starts unbalanced (no 2v1, 3v1 or 3v4).
The golden rule: always-equal teams
Before each match, the controller works out how many teams to use and how big they are:
teams used = min(number of teams in the mode, available players)
size m = min(N, ⌊available players / teams used⌋)Whoever is left over waits in spec. Some examples with football (2 teams) and N = 2:
| Available players | Match | Waiting in spec |
|---|---|---|
| 1 | solo | 0 |
| 2 | 1v1 | 0 |
| 3 | 1v1 | 1 |
| 4 | 2v2 | 0 |
| 5 | 2v2 | 1 |
Before sending each startGame, the controller also checks the room's real teams against the expected ones. If someone changed team at the last moment, it fixes it and tries again instead of starting wrong.
Captains and picking
- The 1st player goes to blue and the 2nd to red: they are the captains.
- The following ones wait in spec, without interrupting the match.
- When spec fills the teams, the match stops and the captain of the team with fewer players (tie: blue) picks by typing the player's number in chat, with no command, within 30 s. With no answer, the first on the list is picked.
- If only one candidate is left, they join on their own, with no pick.
Ana (blue), type the number of the player you want to pick:
Available: 1 - Carla, 2 - DiegoWith N = 3 and 6 players, the captains alternate: blue, red, blue, and the last candidate joins on their own.
End of match: the winner stays on blue
At the end of each match, a player on the field reports the winner with !win blue or !win red (with no answer in 20 s, blue stays). Then:
- The whole losing team goes to the back of the queue in spec.
- The winner always stays on blue: if red won, all of them are moved to blue.
- The first in the queue becomes red's captain and picks the rest from the players in spec.
Example with N = 2 and one extra player waiting (Eva):
blue: Ana, Carla red: Bruno, Diego spec: Eva
> red wins
blue: Bruno, Diego red: Eva (captain) spec: Ana, Carla
> Eva types: 2 (Carla)
blue: Bruno, Diego red: Eva, Carla spec: AnaWhen someone leaves mid-match
The match stops so it never carries on unbalanced. If there are people in spec, they fill the spot (with a captain's pick, if there is a choice). With no replacement, the teams are rebalanced: whoever exceeds the size goes back to the front of the queue and the match restarts, for example as 1v1.
AFK
| Situation | What happens |
|---|---|
!afk in spec | The player becomes AFK: not picked and doesn't fill teams |
!afk again | Leaves AFK and goes to the back of the queue |
!afk during a match, by someone playing | Refused: whoever is playing can't go AFK |
!afk between matches, by someone who was on the field | Goes to spec as AFK and the spot is filled |
| 12 s without moving or chatting, in a match | Only warned; goes AFK at the end of the match |
The bot's messages follow the format o jogador X agora está afk! and o jogador X saiu do afk!.
Commands
| Command | Who uses it | What it does |
|---|---|---|
!afk | any player | Toggles AFK |
<n> (just the number) | captain on turn | Picks player no. n from the list (!pick <n> is still accepted) |
!win blue · !win red | player on the field | Reports the winner |
!start · !stop | player on the field | Starts or stops the match (!stop holds the restart until the next !start) |
!ping | any player | Replies Pong! |
Safeguards
- Locked teams. The bot calls
room.lockTeams(): players don't switch teams on their own. - Reversion as a backup. If someone still leaves a team or joins one on their own, the controller reverts it or treats it as a leave.
- Commands only from players.
!start,!stopand!winfrom spectators are refused. - Other modes. In 4-team modes (classic, arrows...), the first team is fixed and the others rotate every match, with the same equal-size rules.
How this is tested
The controller runs against a fake room that mimics the server (echoed team changes, asynchronous match start and end). Besides dozens of scenarios, a fuzz runs hundreds of random sequences of joins, leaves, !afk, picks, !win, team changes and commands, and checks at every match start that the teams are equal, don't exceed N and have no AFK on the field, and that at the end every player is on the team the controller recorded.