Class

IHLManager

ihlManager~IHLManager()

Class representing the inhouse league manager.

Constructor

new IHLManager()

Creates an inhouse league manager.

View Source lib/ihlManager.js, line 192

Methods

attachListeners()

Bind all events to their corresponding event handler functions

View Source lib/ihlManager.js, line 1140

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.

View Source lib/ihlManager.js, line 456

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.

View Source lib/ihlManager.js, line 1121

Null if the bot left the lobby or a string containing the error reason.

null | string

async clearAllLobbyQueues(inhouseState)

Clear all lobby queues.

Parameters:
Name Type Description
inhouseState module:ihl.InhouseState

The inhouse queue to clear.

View Source lib/ihlManager.js, line 440

async clearLobbyQueue(lobbyState)

Clear a lobby queue.

Parameters:
Name Type Description
lobbyState module:lobby.LobbyState

The lobby queue to clear.

View Source lib/ihlManager.js, line 429

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.

View Source lib/ihlManager.js, line 343

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.

View Source lib/ihlManager.js, line 328

getBot(botId) → {module:dotaBot.DotaBot}

Gets a bot.

Parameters:
Name Type Description
botId number

The bot id.

View Source lib/ihlManager.js, line 1015

module:dotaBot.DotaBot

getBotBySteamId(steamId64) → {module:dotaBot.DotaBot}

Gets a bot by steam id.

Parameters:
Name Type Description
steamId64 number

The bot steam id.

View Source lib/ihlManager.js, line 1025

module:dotaBot.DotaBot

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.

View Source lib/ihlManager.js, line 226

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.

View Source lib/ihlManager.js, line 389

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.

View Source lib/ihlManager.js, line 372

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.

View Source lib/ihlManager.js, line 418

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.

View Source lib/ihlManager.js, line 402

async loadBot(bot) → {module:dotaBot.DotaBot}

Start a dota bot.

Parameters:
Name Type Description
bot module:db.Bot

The bot model.

View Source lib/ihlManager.js, line 1063

module:dotaBot.DotaBot

async loadBotById(botId) → {module:dotaBot.DotaBot}

Start a dota bot by id.

Parameters:
Name Type Description
botId number

The bot id.

View Source lib/ihlManager.js, line 1039

module:dotaBot.DotaBot

async loadBotBySteamId(steamId64) → {module:dotaBot.DotaBot}

Start a dota bot by steam id.

Parameters:
Name Type Description
steamId64 number

The bot steam id.

View Source lib/ihlManager.js, line 1051

module:dotaBot.DotaBot

async onBotAvailable()

Runs lobbies waiting for bots.

View Source lib/ihlManager.js, line 629

async onBotLobbyLeft()

Set bot idle then call onBotAvailable to run lobbies waiting for bots.

View Source lib/ihlManager.js, line 640

async onClientReady()

Discord client ready handler.

View Source lib/ihlManager.js, line 282

async onCreateLobbyQueue(_lobbyState)

Creates a queue lobby.

Parameters:
Name Type Description
_lobbyState module:lobby.LobbyState

The lobby state to create the queue from.

View Source lib/ihlManager.js, line 544

async onDiscordMemberLeave(member)

Discord user left guild handler.

Parameters:
Name Type Description
member external:discordjs.GuildMember

The member that left.

View Source lib/ihlManager.js, line 315

async onDiscordMessage(msg)

Discord message handler.

Parameters:
Name Type Description
msg external:discordjs.Message

The discord message.

View Source lib/ihlManager.js, line 301

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

View Source lib/ihlManager.js, line 741

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

View Source lib/ihlManager.js, line 769

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.

View Source lib/ihlManager.js, line 586

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.

View Source lib/ihlManager.js, line 617

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.

View Source lib/ihlManager.js, line 601

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

View Source lib/ihlManager.js, line 846

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

View Source lib/ihlManager.js, line 832

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.

View Source lib/ihlManager.js, line 871

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.

View Source lib/ihlManager.js, line 860

async onLobbySwapTeams(lobbyState)

Swap teams in the dota lobby.

Parameters:
Name Type Description
lobbyState module:lobby.LobbyState

An inhouse lobby state.

View Source lib/ihlManager.js, line 815

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.

View Source lib/ihlManager.js, line 651

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

View Source lib/ihlManager.js, line 938

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

View Source lib/ihlManager.js, line 905

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.

View Source lib/ihlManager.js, line 883

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

View Source lib/ihlManager.js, line 921

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.

View Source lib/ihlManager.js, line 664

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

View Source lib/ihlManager.js, line 677

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

View Source lib/ihlManager.js, line 711

async onSetBotStatus(steamId64, status)

Sets a bot status.

Parameters:
Name Type Description
steamId64 string

Bot steam id.

status string

Bot status.

View Source lib/ihlManager.js, line 574

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.

View Source lib/ihlManager.js, line 561

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.

View Source lib/ihlManager.js, line 786

module:lobby.lobbyState

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.

View Source lib/ihlManager.js, line 965

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.

View Source lib/ihlManager.js, line 1002

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.

View Source lib/ihlManager.js, line 466

async removeBot(botId)

Remove a dota bot.

Parameters:
Name Type Description
botId number

The bot id.

View Source lib/ihlManager.js, line 1099

async runLobbiesForInhouse(inhouseState)

Runs all lobbies for an inhouse.

Parameters:
Name Type Description
inhouseState module:ihl.inhouseState

The inhouse state.

View Source lib/ihlManager.js, line 354

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.

View Source lib/ihlManager.js, line 496

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.

View Source lib/ihlManager.js, line 481