Constructor
new Main(isMain, id, name, scname, globalData, config, log, child, debug)
Creates a game server
Parameters:
Name | Type | Description |
---|---|---|
isMain |
Boolean | Tells if the server is the main server |
id |
Number | Id of server |
name |
String | Name of server |
scname |
String | Screen name of server |
globalData |
GlobalData | Global data object |
config |
Object | Object of server's config |
log |
function | Log function |
child |
Child | The assigned child process |
debug |
function | The debug function |
Methods
addBot()
Adds a bot
addBots(num)
Adds server bots
Parameters:
Name | Type | Description |
---|---|---|
num |
Number | Amount of bots to add |
addChat(player, msg)
Adds a chat entry
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player who chatted |
msg |
String | Msg to chat |
addClient(client)
Adds a client to the server
Parameters:
Name | Type | Description |
---|---|---|
client |
Player | Player to add to the server |
addFood(n)
Adds food cells
Parameters:
Name | Type | Description |
---|---|---|
n |
Number | Amount of food cells to add |
addMinion(player)
Adds a single minion for a player
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to give the minion to |
addMinions(player, num)
Adds minions for a player
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to give minions to |
num |
Number | Amount of minions to give |
broadcast(msg, name, color)
Broadcays a chat message
Parameters:
Name | Type | Description |
---|---|---|
msg |
String | Message to send |
name |
String | Name to send as |
color |
Object | Color to send as |
canEject(client) → {Boolean}
Checks whether a player can eject mass or not
Parameters:
Name | Type | Description |
---|---|---|
client |
Player | Player to check |
Returns:
Whether player can eject or not
- Type
- Boolean
changeMode(mode)
Changes the gamemode
Parameters:
Name | Type | Description |
---|---|---|
mode |
Number | Gamemode id to switch to |
checkFood()
Checks if there is enough food cells
clearIntervals() → {Number}
Clears all intervals
Returns:
The count of intervals removed
- Type
- Number
clearTimeouts() → {Number}
Clears all timeouts
Returns:
The count of timeouts removed
- Type
- Number
ejectCheck(cell) → {Boolean}
Checks a playercell if it has requirements to eject
Parameters:
Name | Type | Description |
---|---|---|
cell |
Node | Playercell to check |
Returns:
Whether the cell can eject or not
- Type
- Boolean
ejectMass(player)
Ejects mass from a player
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to eject mass |
formatNode(node, player) → {Object}
Formats a node to be sent
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | Node to be sent |
player |
Player | Player that it is being sent to |
Returns:
Formated node
- Type
- Object
getChatName(player) → {String|Boolean}
Gets a player's chatname
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to get chatname |
Returns:
- Returns the chatname
- Type
- String | Boolean
getGlobal() → {GlobalData}
Gets global data
Returns:
Returns the globaldata object
- Type
- GlobalData
onRemove()
Called when the server is removed
parseChatCommand(player, msg) → {Boolean}
Parses a chat command
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player that is issueing the command |
msg |
String | String of command |
Returns:
Returns whether the command was executed or not
- Type
- Boolean
pause(vopt)
Pauses/unpauses the server
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
v |
Boolean |
<optional> |
State to set |
removeBot(bot)
Removes a bot
Parameters:
Name | Type | Description |
---|---|---|
bot |
Bot | Bot to remove |
removeBots(ids)
Removes bots from a list of ids
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array | array of botids |
removeChat(id) → {Boolean}
Removes a chat entry
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | Id of chat entry to remove |
Returns:
Returns whether it was sucessful or not
- Type
- Boolean
removeClient(client)
Removes a player from the server
Parameters:
Name | Type | Description |
---|---|---|
client |
Player | Player to remove |
removeMinion(bot)
Removes a minion
Parameters:
Name | Type | Description |
---|---|---|
bot |
Minion | Minion to remove |
removeNode(cell)
Removes a node from the game
Parameters:
Name | Type | Description |
---|---|---|
cell |
Node | Node to remove |
reset()
Removes all nodes in the game
sendClientPacket(player)
Sends a player's client instructions
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to send data to |
sendPrevChat(player)
Sends the chat log to the client
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | player to send chat log |
setInterval(func, time) → {Interval}
Sets an interval so it can be removed when the server shuts down
Parameters:
Name | Type | Description |
---|---|---|
func |
function | The function to call at a interval |
time |
Number | The interval time |
Returns:
The interval created from this function
- Type
- Interval
setTimeout(func, time) → {Timeout}
Sets an timeout so it can be removed when the server shuts down
Parameters:
Name | Type | Description |
---|---|---|
func |
function | The function to call at after the timeout |
time |
Number | The time to wait for the function to be called |
Returns:
The timeout created from this function
- Type
- Timeout
shootBullet(player)
Shoots a bullet from a player
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to shoot bullet |
spawn(player)
Spawns a player into the game
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | Player to spawn |
splitPlayerCell(cell, angle, speed, decay) → {Node}
Splits a player cell
Parameters:
Name | Type | Description |
---|---|---|
cell |
Node | Playercell to split |
angle |
Number | Angle to split |
speed |
Number | Speed to split |
decay |
Number | Time for split movement decay |
Returns:
Split item
- Type
- Node