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:

text
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 playersMatchWaiting in spec
1solo0
21v10
31v11
42v20
52v21

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

  1. The 1st player goes to blue and the 2nd to red: they are the captains.
  2. The following ones wait in spec, without interrupting the match.
  3. 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.
  4. If only one candidate is left, they join on their own, with no pick.
text
Ana (blue), type the number of the player you want to pick:
Available: 1 - Carla, 2 - Diego

With 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:

  1. The whole losing team goes to the back of the queue in spec.
  2. The winner always stays on blue: if red won, all of them are moved to blue.
  3. 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):

text
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: Ana

When 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

SituationWhat happens
!afk in specThe player becomes AFK: not picked and doesn't fill teams
!afk againLeaves AFK and goes to the back of the queue
!afk during a match, by someone playingRefused: whoever is playing can't go AFK
!afk between matches, by someone who was on the fieldGoes to spec as AFK and the spot is filled
12 s without moving or chatting, in a matchOnly 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

CommandWho uses itWhat it does
!afkany playerToggles AFK
<n> (just the number)captain on turnPicks player no. n from the list (!pick <n> is still accepted)
!win blue · !win redplayer on the fieldReports the winner
!start · !stopplayer on the fieldStarts or stops the match (!stop holds the restart until the next !start)
!pingany playerReplies 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, !stop and !win from 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.