Table of Contents
- API Reference
- MafiaOnlineAPI.ChatMessage
- ChatMessage.ChatMessage#isHistory() ⇒ boolean
- ChatMessage.ChatMessage#getSender() ⇒ User
- ChatMessage.ChatMessage#getText() ⇒ string
- ChatMessage.ChatMessage#getSentTimestamp() ⇒ number
- ChatMessage.ChatMessage#getType() ⇒ string
- MafiaOnlineAPI.PlayerMiniProfile
- PlayerMiniProfile.PlayerMiniProfile#getID() ⇒ number
- PlayerMiniProfile.PlayerMiniProfile#getName() ⇒ string
- PlayerMiniProfile.PlayerMiniProfile#isAlive() ⇒ boolean
- PlayerMiniProfile.PlayerMiniProfile#isMale() ⇒ boolean
- PlayerMiniProfile.PlayerMiniProfile#isFemale() ⇒ boolean
- PlayerMiniProfile.PlayerMiniProfile#getSex() ⇒ number
- MafiaOnlineAPI.MafiaRoom
- MafiaRoom.MafiaRoom#getID() ⇒ string
- MafiaRoom.MafiaRoom#getName() ⇒ string
- MafiaRoom.MafiaRoom#getMinimumLevel() ⇒ number
- MafiaRoom.MafiaRoom#isPasswordProtected() ⇒ boolean
- MafiaRoom.MafiaRoom#join()
- MafiaRoom.MafiaRoom#leave()
- MafiaOnlineAPI.MafiaUser
- MafiaUser.MafiaUser#getID() ⇒ number
- MafiaUser.MafiaUser#getName() ⇒ string
- MafiaUser.MafiaUser#getExperience() ⇒ number
- MafiaUser.MafiaUser#getLastOnlineDate() ⇒ Date
- MafiaUser.MafiaUser#getLevel() ⇒ number
- MafiaUser.MafiaUser#getReputation() ⇒ number
- MafiaUser.MafiaUser#getPlayedGames() ⇒ object
- MafiaUser.MafiaUser#getLocale() ⇒ string
- MafiaUser.MafiaUser#isMale() ⇒ boolean
- MafiaUser.MafiaUser#isFemale() ⇒ boolean
- MafiaUser.MafiaUser#getSex() ⇒ number
- MafiaOnlineAPI.MafiaOnlineAPIAccount#getUser() ⇒ Promise.<MafiaUser>
- MafiaOnlineAPI.MafiaOnlineAPIAccount#setNickname(nickname) ⇒ Promise.<boolean>
- MafiaOnlineAPI.MafiaOnlineAPIAccount#setLocale(locale) ⇒ object
- MafiaOnlineAPI.MafiaOnlineAPIAuth#signOut() ⇒ Promise.<object>
- MafiaOnlineAPI.MafiaOnlineAPIAuth#verifyEmail() ⇒ Promise.<object>
- MafiaOnlineAPI.MafiaOnlineAPIBase#close() ⇒ Promise
- MafiaOnlineAPI.MafiaOnlineAPIChat#joinGlobalChat(callback) ⇒ function
- MafiaOnlineAPI.MafiaOnlineAPIChat#sendToGlobalChat(content, messageStyle)
- MafiaOnlineAPI.MafiaOnlineAPIChat#_manageChat(events) ⇒ function
- MafiaOnlineAPI.MafiaOnlineAPIRooms#startRoomMonitoring(callback) ⇒ function
- MafiaOnlineAPI.MafiaOnlineAPIRooms#joinRoom(room, [password])
- MafiaOnlineAPI.MafiaOnlineAPIRooms#leaveRoom(room)
- REST API
API Reference
Mafia Online API
- mafiaonline
- .ChatMessage
- .ChatMessage#isHistory() ⇒
boolean - .ChatMessage#getSender() ⇒
User - .ChatMessage#getText() ⇒
string - .ChatMessage#getSentTimestamp() ⇒
number - .ChatMessage#getType() ⇒
string
- .ChatMessage#isHistory() ⇒
- .PlayerMiniProfile
- .PlayerMiniProfile#getID() ⇒
number - .PlayerMiniProfile#getName() ⇒
string - .PlayerMiniProfile#isAlive() ⇒
boolean - .PlayerMiniProfile#isMale() ⇒
boolean - .PlayerMiniProfile#isFemale() ⇒
boolean - .PlayerMiniProfile#getSex() ⇒
number
- .PlayerMiniProfile#getID() ⇒
- .MafiaRoom
- .MafiaRoom#getID() ⇒
string - .MafiaRoom#getName() ⇒
string - .MafiaRoom#getMinimumLevel() ⇒
number - .MafiaRoom#isPasswordProtected() ⇒
boolean - .MafiaRoom#join()
- .MafiaRoom#leave()
- .MafiaRoom#getID() ⇒
- .MafiaUser
- .MafiaUser#getID() ⇒
number - .MafiaUser#getName() ⇒
string - .MafiaUser#getExperience() ⇒
number - .MafiaUser#getLastOnlineDate() ⇒
Date - .MafiaUser#getLevel() ⇒
number - .MafiaUser#getReputation() ⇒
number - .MafiaUser#getPlayedGames() ⇒
object - .MafiaUser#getLocale() ⇒
string - .MafiaUser#isMale() ⇒
boolean - .MafiaUser#isFemale() ⇒
boolean - .MafiaUser#getSex() ⇒
number
- .MafiaUser#getID() ⇒
- .MafiaOnlineAPIAccount#getUser() ⇒
Promise.<MafiaUser> - .MafiaOnlineAPIAccount#setNickname(nickname) ⇒
Promise.<boolean> - .MafiaOnlineAPIAccount#setLocale(locale) ⇒
object - .MafiaOnlineAPIAuth#signOut() ⇒
Promise.<object> - .MafiaOnlineAPIAuth#verifyEmail() ⇒
Promise.<object> - .MafiaOnlineAPIBase#close() ⇒
Promise - .MafiaOnlineAPIChat#joinGlobalChat(callback) ⇒
function - .MafiaOnlineAPIChat#sendToGlobalChat(content, messageStyle)
- .MafiaOnlineAPIChat#_manageChat(events) ⇒
function - .MafiaOnlineAPIRooms#startRoomMonitoring(callback) ⇒
function - .MafiaOnlineAPIRooms#joinRoom(room, [password])
- .MafiaOnlineAPIRooms#leaveRoom(room)
- .ChatMessage
MafiaOnlineAPI.ChatMessage
Message in chat
Kind: static class of mafiaonline
- .ChatMessage
- .ChatMessage#isHistory() ⇒
boolean - .ChatMessage#getSender() ⇒
User - .ChatMessage#getText() ⇒
string - .ChatMessage#getSentTimestamp() ⇒
number - .ChatMessage#getType() ⇒
string
- .ChatMessage#isHistory() ⇒
ChatMessage.ChatMessage#isHistory() ⇒ boolean
Check if message is historic (sent before joining)
Kind: static method of ChatMessage
Returns: boolean -
True if message is historic
ChatMessage.ChatMessage#getSender() ⇒ User
Get sender of message, User class instance
Kind: static method of ChatMessage
Returns: User -
Sender of message
ChatMessage.ChatMessage#getText() ⇒ string
Get text content of message
Kind: static method of ChatMessage
Returns: string -
Clear text of message
ChatMessage.ChatMessage#getSentTimestamp() ⇒ number
Get timestamp of message send in unix timestamp format (seconds since epoch)
Kind: static method of ChatMessage
Returns: number -
Time when message was sent
ChatMessage.ChatMessage#getType() ⇒ string
Returns type of message, one of 'clear_text', 'join', 'left', 'game_started', 'mafia_in_chat', 'mafia_choosing_victim', 'civilian_in_chat', 'civilian_voting', 'civilian_vote', 'clear_text', '[unknown]', 'player_killed', 'civilian_vote', 'no_one_killed', 'civilians_won', 'mafia_won', 'dead_player_last_message'
Kind: static method of ChatMessage
Returns: string -
Type of message in chat
MafiaOnlineAPI.PlayerMiniProfile
Player's mini profile. Used in room.getPlayers()
Kind: static class of mafiaonline
- .PlayerMiniProfile
- .PlayerMiniProfile#getID() ⇒
number - .PlayerMiniProfile#getName() ⇒
string - .PlayerMiniProfile#isAlive() ⇒
boolean - .PlayerMiniProfile#isMale() ⇒
boolean - .PlayerMiniProfile#isFemale() ⇒
boolean - .PlayerMiniProfile#getSex() ⇒
number
- .PlayerMiniProfile#getID() ⇒
PlayerMiniProfile.PlayerMiniProfile#getID() ⇒ number
Get in-game ID of user
Kind: static method of PlayerMiniProfile
Returns: number -
User ID
PlayerMiniProfile.PlayerMiniProfile#getName() ⇒ string
Get user nickname
Kind: static method of PlayerMiniProfile
Returns: string -
User nickname
PlayerMiniProfile.PlayerMiniProfile#isAlive() ⇒ boolean
Returns true if player is alive in the game
Kind: static method of PlayerMiniProfile
Returns: boolean -
Is player alive
PlayerMiniProfile.PlayerMiniProfile#isMale() ⇒ boolean
Check if user sex is male
Kind: static method of PlayerMiniProfile
Returns: boolean -
True if user is male, false otherwise
PlayerMiniProfile.PlayerMiniProfile#isFemale() ⇒ boolean
Check if user sex is female
Kind: static method of PlayerMiniProfile
Returns: boolean -
True if user is female, false otherwise
PlayerMiniProfile.PlayerMiniProfile#getSex() ⇒ number
Get user sex
Kind: static method of PlayerMiniProfile
Returns: number -
0 if user is male, 0 if user is female
MafiaOnlineAPI.MafiaRoom
Room of Mafia Online
Kind: static class of mafiaonline
- .MafiaRoom
- .MafiaRoom#getID() ⇒
string - .MafiaRoom#getName() ⇒
string - .MafiaRoom#getMinimumLevel() ⇒
number - .MafiaRoom#isPasswordProtected() ⇒
boolean - .MafiaRoom#join()
- .MafiaRoom#leave()
- .MafiaRoom#getID() ⇒
MafiaRoom.MafiaRoom#getID() ⇒ string
Get ID of room
Kind: static method of MafiaRoom
Returns: string -
ID of room
MafiaRoom.MafiaRoom#getName() ⇒ string
Get room name
Kind: static method of MafiaRoom
Returns: string -
Name of room
MafiaRoom.MafiaRoom#getMinimumLevel() ⇒ number
Get minimum level required to join the room
Kind: static method of MafiaRoom
Returns: number -
Minimum level for room
MafiaRoom.MafiaRoom#isPasswordProtected() ⇒ boolean
Returns true is room is password protected
Kind: static method of MafiaRoom
MafiaRoom.MafiaRoom#join()
Enters the room
Kind: static method of MafiaRoom
MafiaRoom.MafiaRoom#leave()
Leaves the room
Kind: static method of MafiaRoom
MafiaOnlineAPI.MafiaUser
User of Mafia Online
Kind: static class of mafiaonline
- .MafiaUser
- .MafiaUser#getID() ⇒
number - .MafiaUser#getName() ⇒
string - .MafiaUser#getExperience() ⇒
number - .MafiaUser#getLastOnlineDate() ⇒
Date - .MafiaUser#getLevel() ⇒
number - .MafiaUser#getReputation() ⇒
number - .MafiaUser#getPlayedGames() ⇒
object - .MafiaUser#getLocale() ⇒
string - .MafiaUser#isMale() ⇒
boolean - .MafiaUser#isFemale() ⇒
boolean - .MafiaUser#getSex() ⇒
number
- .MafiaUser#getID() ⇒
MafiaUser.MafiaUser#getID() ⇒ number
Get in-game ID of user
Kind: static method of MafiaUser
Returns: number -
User ID
MafiaUser.MafiaUser#getName() ⇒ string
Get user nickname
Kind: static method of MafiaUser
Returns: string -
User nickname
MafiaUser.MafiaUser#getExperience() ⇒ number
Get user experience
Kind: static method of MafiaUser
Returns: number -
User experience
MafiaUser.MafiaUser#getLastOnlineDate() ⇒ Date
Get user last date of online
Kind: static method of MafiaUser
Returns: Date -
Date of online
MafiaUser.MafiaUser#getLevel() ⇒ number
Get user level
Kind: static method of MafiaUser
Returns: number -
User level
MafiaUser.MafiaUser#getReputation() ⇒ number
Get user reputation
Kind: static method of MafiaUser
Returns: number -
User reputation
MafiaUser.MafiaUser#getPlayedGames() ⇒ object
Get information about played games
Kind: static method of MafiaUser
Returns: object -
Object with stats
MafiaUser.MafiaUser#getLocale() ⇒ string
Get language of user
Kind: static method of MafiaUser
Returns: string -
User locale
MafiaUser.MafiaUser#isMale() ⇒ boolean
Check if user sex is male
Kind: static method of MafiaUser
Returns: boolean -
True if user is male, false otherwise
MafiaUser.MafiaUser#isFemale() ⇒ boolean
Check if user sex is female
Kind: static method of MafiaUser
Returns: boolean -
True if user is female, false otherwise
MafiaUser.MafiaUser#getSex() ⇒ number
Get user sex
Kind: static method of MafiaUser
Returns: number -
0 if user is male, 0 if user is female
MafiaOnlineAPI.MafiaOnlineAPIAccount#getUser() ⇒ Promise.<MafiaUser>
Get authorized User
Kind: static method of mafiaonline
Returns: Promise.<MafiaUser> -
Instance of User class
MafiaOnlineAPI.MafiaOnlineAPIAccount#setNickname(nickname) ⇒ Promise.<boolean>
Set nickname of authorized user
Kind: static method of mafiaonline
Returns: Promise.<boolean> -
True if nickname set successfully
| Param | Type | Description |
|---|---|---|
| nickname | string |
New nickname of user |
MafiaOnlineAPI.MafiaOnlineAPIAccount#setLocale(locale) ⇒ object
Set server language. Mustn't change frequently (once in 6 hours)
Kind: static method of mafiaonline
Returns: object -
Response from server
| Param | Type | Description |
|---|---|---|
| locale | string |
One of 'ru', 'en' |
MafiaOnlineAPI.MafiaOnlineAPIAuth#signOut() ⇒ Promise.<object>
Sign out from account and delete session
Kind: static method of mafiaonline
Returns: Promise.<object> -
Response from REST API
See: REST API
MafiaOnlineAPI.MafiaOnlineAPIAuth#verifyEmail() ⇒ Promise.<object>
Send verification email
Kind: static method of mafiaonline
Returns: Promise.<object> -
Response from REST API
See: REST API
MafiaOnlineAPI.MafiaOnlineAPIBase#close() ⇒ Promise
Closes current socket and cleans up all stuff. Does not delete session, use signOut() before close()!
Kind: static method of mafiaonline
MafiaOnlineAPI.MafiaOnlineAPIChat#joinGlobalChat(callback) ⇒ function
Subscribe to global public chat
Kind: static method of mafiaonline
Returns: function -
Unsubscribe function
| Param | Type | Description |
|---|---|---|
| callback | function |
Callback function, that gets called everytime a new message sent by someone in chat with message argument. It is strongly recommended that you check msg.isHistory() before interacting with it, because when you join chat, server sends you a lot of history messages (that were sent before you joined). |
MafiaOnlineAPI.MafiaOnlineAPIChat#sendToGlobalChat(content, messageStyle)
Send message to global chat. Must join global chat first using joinGlobalChat(). Must verify email in order to be able to send more than one message.
Kind: static method of mafiaonline
| Param | Type | Default | Description |
|---|---|---|---|
| content | string |
Text content of message |
|
| messageStyle | number |
0 |
Style of message (VIP-only) |
MafiaOnlineAPI.MafiaOnlineAPIChat#_manageChat(events) ⇒ function
Chat manager that handles new messages
Kind: static method of mafiaonline
Returns: function -
Unsubscribe function
| Param | Type | Description |
|---|---|---|
| events | object |
Events object as first arg |
| events.onMessage | function |
Callback with message class as argument |
| events.onUserListUpdate | function |
Callback with array of users |
| events.onLeave | function |
Called on unsubscribing. Must be as simple, as possible |
MafiaOnlineAPI.MafiaOnlineAPIRooms#startRoomMonitoring(callback) ⇒ function
Get rooms list and subscribe for changes
Kind: static method of mafiaonline
Returns: function -
Function to unsubscribe
| Param | Description |
|---|---|
| callback | Callback that gets called with argument of type Room |
MafiaOnlineAPI.MafiaOnlineAPIRooms#joinRoom(room, [password])
Join room. You can also call join() method directly on Room instance
Kind: static method of mafiaonline
| Param | Type | Description |
|---|---|---|
| room | Room |
Room instance. Must be obtained from monitoring by calling startRoomMonitoring() function |
| [password] | string |
Optional. Password in clear text, hashing is done on library side |
MafiaOnlineAPI.MafiaOnlineAPIRooms#leaveRoom(room)
Leave room. You can also call leave() method directly on Room instance
Kind: static method of mafiaonline
| Param | Type | Description |
|---|---|---|
| room | Room |
Room instance. Must be obtained from monitoring by calling startRoomMonitoring() function |
REST API
This method uses HTTP REST API.