PlayerManager

Keeps track of all active players in game

Constructor

new PlayerManager()

Listens to Events:
  • PlayerManager#event:save
  • PlayerManager#event:updateTick
Properties:
Name Type Description
players Map
events EventManager

Player events

Implements:

Extends

  • EventEmitter

Methods

addListener(behaviorName, listener)

Parameters:
Name Type Description
behaviorName string
listener function

addPlayer(player)

Parameters:
Name Type Description
player Player

exists(name) → {boolean}

Parameters:
Name Type Description
name string
Returns:
boolean

filter(fn) → {array}

Parameters:
Name Type Description
fn function

Filter function

Returns:
array

getBroadcastTargets() → {Array.<Character>}

Used by Broadcaster

Returns:
Array.<Character>

getPlayer(name) → {Player}

Parameters:
Name Type Description
name string
Returns:
Player

getPlayersAsArray() → {array}

Returns:
array

keyify(player) → {string}

Turn player into a key used by this class's map

Parameters:
Name Type Description
player Player
Returns:
string

loadPlayer(state, account, username, force) → {Player}

Load a player for an account

Parameters:
Name Type Description
state GameState
account Account
username string
force boolean

true to force reload from storage

Returns:
Player

removePlayer(player, killSocket)

Parameters:
Name Type Description
player Player
killSocket boolean

true to also force close the player's socket

saveAll(playerCallback)

Parameters:
Name Type Description
playerCallback function

callback after save of each player

Fires:

tickAll()

Fires: