Constructor
Methods
attachListeners()
Bind all events to their corresponding event handler functions
async banInhouseQueue(inhouseState, user, timeout, discordUser)
Bans a user from the inhouse queue.
Parameters:
Name | Type | Description |
---|---|---|
inhouseState |
module:ihl.InhouseState | The inhouse to dequeue. |
user |
module:db.User | The player to ban. |
timeout |
number | Duration of ban in minutes. |
discordUser |
external:discordjs.User | A discord.js user. |
async botLeaveLobby(lobbyState) → {null|string}
Disconnect a dota bot from its lobby. The bot should eventually emit EVENT_BOT_LOBBY_LEFT.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.lobbyState | The lobby for the bot. |
Null if the bot left the lobby or a string containing the error reason.
async clearAllLobbyQueues(inhouseState)
Clear all lobby queues.
Parameters:
Name | Type | Description |
---|---|---|
inhouseState |
module:ihl.InhouseState | The inhouse queue to clear. |
async clearLobbyQueue(lobbyState)
Clear a lobby queue.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | The lobby queue to clear. |
async createChallengeLobby(inhouseState, captain1, captain2, challenge)
Creates and runs a challenge lobby.
Parameters:
Name | Type | Description |
---|---|---|
inhouseState |
module:ihl.inhouseState | The inhouse state. |
captain1 |
module:db.User | The first lobby captain. |
captain2 |
module:db.User | The second lobby captain. |
challenge |
module:db.Challenge | The challenge between the two captains. |
async createNewLeague(guild)
Creates a new inhouse in a discord guild.
Parameters:
Name | Type | Description |
---|---|---|
guild |
external:discordjs.Guild | The discord guild for the inhouse. |
getBot(botId) → {module:dotaBot.DotaBot}
Gets a bot.
Parameters:
Name | Type | Description |
---|---|---|
botId |
number | The bot id. |
getBotBySteamId(steamId64) → {module:dotaBot.DotaBot}
Gets a bot by steam id.
Parameters:
Name | Type | Description |
---|---|---|
steamId64 |
number | The bot steam id. |
async init(client)
Initializes the inhouse league manager with a discord client and loads inhouse states for each league.
Parameters:
Name | Type | Description |
---|---|---|
client |
external:Client | A discord.js client. |
async joinAllLobbyQueues(inhouseState, user, discordUser)
Adds a user to all lobby queues.
Parameters:
Name | Type | Description |
---|---|---|
inhouseState |
module:ihl.InhouseState | The inhouse to queue. |
user |
module:db.User | The user to queue. |
discordUser |
external:discordjs.User | A discord.js user. |
async joinLobbyQueue(lobbyState, user, discordUser)
Adds a user to a lobby queue.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | The lobby to join. |
user |
module:db.User | The user to queue. |
discordUser |
external:discordjs.User | A discord.js user. |
async leaveAllLobbyQueues(inhouseState, user, discordUser)
Removes a user from all lobby queues.
Parameters:
Name | Type | Description |
---|---|---|
inhouseState |
module:ihl.InhouseState | The inhouse to dequeue. |
user |
module:db.User | The user to dequeue. |
discordUser |
external:discordjs.User | A discord.js user. |
async leaveLobbyQueue(lobbyState, user, discordUser)
Removes a user from a lobby queue.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | The lobby to join. |
user |
module:db.User | The user to dequeue. |
discordUser |
external:discordjs.User | A discord.js user. |
async loadBot(bot) → {module:dotaBot.DotaBot}
Start a dota bot.
Parameters:
Name | Type | Description |
---|---|---|
bot |
module:db.Bot | The bot model. |
async loadBotById(botId) → {module:dotaBot.DotaBot}
Start a dota bot by id.
Parameters:
Name | Type | Description |
---|---|---|
botId |
number | The bot id. |
async loadBotBySteamId(steamId64) → {module:dotaBot.DotaBot}
Start a dota bot by steam id.
Parameters:
Name | Type | Description |
---|---|---|
steamId64 |
number | The bot steam id. |
async onBotLobbyLeft()
Set bot idle then call onBotAvailable to run lobbies waiting for bots.
async onClientReady()
Discord client ready handler.
async onCreateLobbyQueue(_lobbyState)
Creates a queue lobby.
Parameters:
Name | Type | Description |
---|---|---|
_lobbyState |
module:lobby.LobbyState | The lobby state to create the queue from. |
async onDiscordMemberLeave(member)
Discord user left guild handler.
Parameters:
Name | Type | Description |
---|---|---|
member |
external:discordjs.GuildMember | The member that left. |
async onDiscordMessage(msg)
Discord message handler.
Parameters:
Name | Type | Description |
---|---|---|
msg |
external:discordjs.Message | The discord message. |
async onDraftMember(lobbyState, user, faction)
Checks if a player is draftable and fires an event representing the result. If the player is draftable, checks for STATE_DRAFTING_PLAYERS lobby state and runs the lobby state.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
user |
module:db.User | The picked user |
faction |
number | The picking faction |
async onForceLobbyDraft(lobbyState, captain1, captain2)
Force lobby into player draft with assigned captains.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
captain1 |
module:db.User | The captain 1 user |
captain2 |
module:db.User | The captain 2 user |
async onLeagueTicketAdd(league, leagueid, name)
Associates a league with a ticket.
Parameters:
Name | Type | Description |
---|---|---|
league |
module:db.League | The league to add the ticket to. |
leagueid |
number | The ticket league id. |
name |
string | The ticket name. |
async onLeagueTicketRemove(league, leagueid)
Removes a ticket from a league.
Parameters:
Name | Type | Description |
---|---|---|
league |
module:db.League | The league to remove the ticket from. |
leagueid |
number | The ticket league id. |
async onLeagueTicketSet(league, leagueid) → {module:db.Ticket}
Sets the league ticket.
Parameters:
Name | Type | Description |
---|---|---|
league |
module:db.League | The league to set the ticket to. |
leagueid |
number | The ticket league id. |
async onLobbyInvite(lobbyState, user)
Invites a player to the dota lobby.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
user |
module:db.User | The player to invite |
async onLobbyKick(lobbyState, user)
Kicks a player from the dota lobby.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
user |
module:db.User | The player to kick |
async onLobbyKill(lobbyState)
Puts a lobby state in STATE_PENDING_KILL and runs lobby.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
async onLobbyReady(dotaLobbyId)
Runs a lobby state when the lobby is ready (all players have joined and are in the right team slot). Checks for STATE_WAITING_FOR_PLAYERS lobby state
Parameters:
Name | Type | Description |
---|---|---|
dotaLobbyId |
string | A dota lobby id. |
async onLobbySwapTeams(lobbyState)
Swap teams in the dota lobby.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
async onLobbyTimedOut(lobbyState)
Runs a lobby state when its ready up timer has expired. Checks for STATE_CHECKING_READY lobby state
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
async onMatchNoStats(lobby)
Handles match tracker match no stats event. Sends match no stats message. Puts lobby into STATE_MATCH_NO_STATS state
Parameters:
Name | Type | Description |
---|---|---|
lobby |
module:db.Lobby | A lobby database model |
async onMatchOutcome(dotaLobbyId, matchOutcome, members)
Handles match outcome bot event. Updates lobby winner and player stats. Sends match stats message. Puts lobby into STATE_MATCH_STATS state
Parameters:
Name | Type | Description |
---|---|---|
dotaLobbyId |
string | A dota lobby id. |
matchOutcome |
external:Dota2.schema.EMatchOutcome | The dota match outcome |
members |
Array.<external:Dota2.schema.CDOTALobbyMember> | Array of dota lobby members |
async onMatchSignedOut(matchId)
Handles match signed out bot event. Updates STATE_MATCH_IN_PROGRESS lobby state to STATE_MATCH_ENDED
Parameters:
Name | Type | Description |
---|---|---|
matchId |
number | A dota match id. |
async onMatchStats(lobby)
Handles match tracker match stats event. Sends match stats message. Puts lobby into STATE_MATCH_STATS state
Parameters:
Name | Type | Description |
---|---|---|
lobby |
module:db.Lobby | A lobby database model |
async onPlayerReady(lobbyState, user)
Runs a lobby state when a player has readied up and update their player ready state. Checks for STATE_CHECKING_READY lobby state
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
user |
module:db.User | An inhouse user. |
async onSelectionPick(_lobbyState, captain, pick)
Updates a lobby state with a captain pick selection
Parameters:
Name | Type | Description |
---|---|---|
_lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
captain |
module:db.User | The captain user |
pick |
number | The selected pick |
async onSelectionSide(_lobbyState, captain, side)
Updates a lobby state with a captain side selection
Parameters:
Name | Type | Description |
---|---|---|
_lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
captain |
module:db.User | The captain user |
side |
number | The selected faction |
async onSetBotStatus(steamId64, status)
Sets a bot status.
Parameters:
Name | Type | Description |
---|---|---|
steamId64 |
string | Bot steam id. |
status |
string | Bot status. |
async onSetLobbyState(_lobbyState, state)
Sets a lobby state.
Parameters:
Name | Type | Description |
---|---|---|
_lobbyState |
module:lobby.LobbyState | The lobby state being changed. |
state |
string | The state to set the lobby to. |
async onStartDotaLobby(_lobbyState, _dotaBot) → {module:lobby.lobbyState}
Start a dota lobby if all players are in the lobby and on the correct teams.
Parameters:
Name | Type | Description |
---|---|---|
_lobbyState |
module:lobby.lobbyState | The lobby state to check. |
_dotaBot |
module:lobby.lobbyState | The bot to check. |
async processEventQueue()
Processes the inhouse manager event queue until it is empty. Events are actions to perform (mostly on lobby states or something that resolves to a lobby state). An event consists of a function, the arguments to call it with, and the resolve and reject callbacks of the Promise wrapping the action. When the action is executed, resolve with the returned value or reject if an error was thrown. The queue blocks while processing an action, so only 1 can be processed at a time.
async queueEvent(fn, …args)
Adds a lobby processing function and its arguments to the queue. When the queue is processed the function will be executed with its arguments.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
fn |
eventCallback | A lobby processing event function. |
|
args |
* |
<repeatable> |
A list of arguments the lobby processing event function will be called with. |
registerLobbyTimeout(lobbyState)
Creates and registers a ready up timer for a lobby state.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
async removeBot(botId)
Remove a dota bot.
Parameters:
Name | Type | Description |
---|---|---|
botId |
number | The bot id. |
async runLobbiesForInhouse(inhouseState)
Runs all lobbies for an inhouse.
Parameters:
Name | Type | Description |
---|---|---|
inhouseState |
module:ihl.inhouseState | The inhouse state. |
async runLobby(_lobbyState, states)
Processes and executes a lobby state if it matches any of the given states. If no states to match against are given, the lobby state is run by default.
Parameters:
Name | Type | Description |
---|---|---|
_lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |
states |
Array.<string> | A list of valid lobby states. |
unregisterLobbyTimeout(lobbyState)
Clears and unregisters the ready up timer for a lobby state.
Parameters:
Name | Type | Description |
---|---|---|
lobbyState |
module:lobby.LobbyState | An inhouse lobby state. |