MafiaUser

sockMafia User class

Author: Accalia
License: MIT

MafiaUser~MafiaUser

MafiaUser class

Kind: inner class of MafiaUser

new MafiaUser(data, game)

Mafia User constructor. Creates a new MafiaUser instance

Param Type Description
data object Persisted user data
game MafiaGame MafiaGame this user is a part of

mafiaUser.username ⇒ string

Get the username of the MafiaUser

Kind: instance property of MafiaUser
Returns: string - Username of the user

mafiaUser.userslug ⇒ string

Get the case normalized userslug of the user, useful for comparing users.

Kind: instance property of MafiaUser
Returns: string - Userslug of the user

mafiaUser.isAlive ⇒ boolean

Is the user a living player?

Kind: instance property of MafiaUser
Returns: boolean - True if the user is a living player, false otherwise.

mafiaUser.isAlive

set alive status of the User

TODO: this shouldn't be a setter as it does not save status when mutated.

Kind: instance property of MafiaUser

Param Type Description
value boolean True to make the player live, false to make the player dead.

mafiaUser.isModerator ⇒ boolean

Is the user a moderator?

Kind: instance property of MafiaUser
Returns: boolean - true if user is a moderator of the game, false otherwise.

mafiaUser.getProperties([filterTo]) ⇒ array.<string>

Get custom properties associated with the user.

Optionally filter the list to only those properties requested

Kind: instance method of MafiaUser
Returns: array.<string> - Custom properties on the user, with any requested filtering applied

Param Type Description
[filterTo] array.<string> Array or properties to filter results to.

mafiaUser.hasProperty(property) ⇒ boolean

Determine if custom property is associated with the user.

Kind: instance method of MafiaUser
Returns: boolean - true if the user has the property, false otherwise

Param Type Description
property string Array or properties to filter results to.

mafiaUser.addProperty(property) ⇒ Promise.<boolean>

Add a custom property to the user.

Kind: instance method of MafiaUser
Returns: Promise.<boolean> - Resolves true if the property was added, false if it already existed on the user

Param Type Description
property string The property to add to the user

mafiaUser.removeProperty(property) ⇒ Promise.<boolean>

Remove a custom operty from the user

Kind: instance method of MafiaUser
Returns: Promise.<boolean> - Resolves true if property was removed, false if property was not present to remove

Param Type Description
property string the property to remove from the user

mafiaUser.toJSON() ⇒ object

Create a serializeable representation of the DAO object.

Kind: instance method of MafiaUser
Returns: object - A serializeable clone of this action's internal data store.