Class: Main

Main

Class that represents a game server

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
Source:

Methods

addBot()

Adds a bot
Source:

addBots(num)

Adds server bots
Parameters:
Name Type Description
num Number Amount of bots to add
Source:

addChat(player, msg)

Adds a chat entry
Parameters:
Name Type Description
player Player Player who chatted
msg String Msg to chat
Source:

addClient(client)

Adds a client to the server
Parameters:
Name Type Description
client Player Player to add to the server
Source:

addFood(n)

Adds food cells
Parameters:
Name Type Description
n Number Amount of food cells to add
Source:

addMinion(player)

Adds a single minion for a player
Parameters:
Name Type Description
player Player Player to give the minion to
Source:

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
Source:

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
Source:

canEject(client) → {Boolean}

Checks whether a player can eject mass or not
Parameters:
Name Type Description
client Player Player to check
Source:
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
Deprecated:
  • Is not functional
Source:

checkFood()

Checks if there is enough food cells
Source:

clearIntervals() → {Number}

Clears all intervals
Source:
Returns:
The count of intervals removed
Type
Number

clearTimeouts() → {Number}

Clears all timeouts
Source:
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
Source:
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
Source:

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
Source:
Returns:
Formated node
Type
Object

getChatName(player) → {String|Boolean}

Gets a player's chatname
Parameters:
Name Type Description
player Player Player to get chatname
Source:
Returns:
- Returns the chatname
Type
String | Boolean

getGlobal() → {GlobalData}

Gets global data
Source:
Returns:
Returns the globaldata object
Type
GlobalData

onRemove()

Called when the server is removed
Source:

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
Source:
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
Source:

removeBot(bot)

Removes a bot
Parameters:
Name Type Description
bot Bot Bot to remove
Source:

removeBots(ids)

Removes bots from a list of ids
Parameters:
Name Type Description
ids Array array of botids
Source:

removeChat(id) → {Boolean}

Removes a chat entry
Parameters:
Name Type Description
id Number Id of chat entry to remove
Source:
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
Source:

removeMinion(bot)

Removes a minion
Parameters:
Name Type Description
bot Minion Minion to remove
Source:

removeNode(cell)

Removes a node from the game
Parameters:
Name Type Description
cell Node Node to remove
Source:

reset()

Removes all nodes in the game
Source:

sendClientPacket(player)

Sends a player's client instructions
Parameters:
Name Type Description
player Player Player to send data to
Source:

sendPrevChat(player)

Sends the chat log to the client
Parameters:
Name Type Description
player Player player to send chat log
Source:

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
Source:
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
Source:
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
Source:

spawn(player)

Spawns a player into the game
Parameters:
Name Type Description
player Player Player to spawn
Source:

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
Source:
Returns:
Split item
Type
Node