Home Reference Source

Function

Static Public Summary
public

addExperience(event: string, socket: *, room: string, player: string)

Adds experience to a given player.

public

Attempts to connect to the server.

public

bindHandler(id: string, handlerMethod: function)

Binds handlerMethod to onclick event for element id.

public

canCraft(player: *, room: *, blueprint: *): boolean

public

collisionDetect(socket: *, room: string, thisPlayer: *, tempObjects: *)

Runs once a frame, checks for collisions between objects and handles them accordingly.

public

createCompound(data: *, room: string, thisPlayer: *, socket: *): *

Checks if a compound can be created, deducts craft material, and returns the new compound.

public

createPlayer(data: *): Player

Creates a Player instance once the stage is fully set up and ready.

public

createRenderAtom(data: *): *

Renders a new atom.

public

createRenderCompound(data: *): *

Recreates an already spawned compound on the clientside based on server data.

public
public

damage(data: *, room: string, socket: *)

Changes the health of the player by the amount given.

public

damageTile(tileID: *, damageAmount: *, player: *, room: *, socket: *): boolean

public

deleteObject(type: string, id: *, room: string, socket: *)

Deletes one of the three types of gameObjects synced to the server

public

Destroy everything in PIXI.

public

Run on disconnect to reset all server-based variables and connections

public

displayWinner(data: *)

Displays the winner panel after a game has concluded.

public

distanceBetween(obj1: *, obj2: *): *

public

Removes the given cookie.

public

frameSync(socket: *, room: string)

Runs once a frame, per ROOM.

public

generateID(): *

Returns a random number between between 10000000 and 99999999, inclusive.

public

Sets the value of a cookie.

public

getCurrTile(obj: *): string

Gets the tile directly underneath any object.

public

getField(path: *): *

Returns the value given a path to that value.

public

getGlobalLocation(obj: *): {"globalY": *, "globalX": *}

Gets the coordinates of the tile directly underneath the object.

public
public

getTeamColors(room: string): *

Returns the team colors object (see client socket.js for more information on the format)

public

getTeamNumber(room: string, teamName: string): *

Returns the index of the given team within the team array of the given room.

public

getTileID(globalLocation: *, room: string): boolean

Returns the serverside ID of the tile at this location.

public

Hides a visible element

public

incrementAtom(player: *, room: *, atomType: *, quantity: *)

public

incrementField(amount: *, path: *)

Shorthand to add or concatenate an amount to a field.

public

Global initialiation.

public

initPlayer(socket: *, room: string, team: string): *

Run on every player join.

public

initRoom(socket: *, roomName: string)

Run when the first person joins a new room that has not been initialized yet.

public

isFocused(): *

If the document is Focused return true otherwise false

public

Returns true if the object parameter is within the map boundaries.

public

keyboard(keyCode: *): *

public
public

Called on mouse down from app.js

public

Called on mouse up from app.js

public

movePlayer(direction: string)

Moves the player by changing its velocity.

public

quitGame(msg: string, isError: boolean)

Transitions from in-game displays to the main menu.

public

requestCreateCompound(blueprint: *, xIn: number, yIn: number, streamID: number): *

Creates a Compound by sending a request to the server.

public

roomMatchmaker(socket: *, room: string, team: string): *

Matchmaking system for public matches.

public

setCookie(name: string, value: string, days: number)

Sets the value of a cookie.

public

setField(value: *, path: *)

Sets a new value for a protected server field.

public

setIngame(newValue: boolean)

Sets the value of inGame

public

Displays a hidden element

public

Call this function to hide loading div and show UI

public

smartEmit(socket: *, room: string, emitName: string, emitContent: *, to: string)

public

spawnAtom(x: number, y: number, type: string, room: string, team: string, verbose: boolean)

public

spawnAtomAtVent(row: number, col: number, room: string, team: string, verbose: boolean)

Spawns an atom at the vent at the given row and column.

public

splash()

TODO

public

startGame(emit: boolean, teams: *)

Starts the game after lobby closes.

public

tickCompound(compound: number, room: string, socket: *)

Checks compound behavior based on compound type.

public

Updates the list of atoms that the player holds.

public

updateCompoundButtons(selectedSlot: number)

public

updateLobby(data: *)

Run on new player join to sync lobby information

public

updateScores(teamSlot: *, increment: *)

Updates the team scoreboard on screen.

Static Public

public addExperience(event: string, socket: *, room: string, player: string) source

import {addExperience} from 'atomblast.io/src/server/utils/experience.js'

Adds experience to a given player.

Params:

NameTypeAttributeDescription
event string

The name of the event as specified in GLOBAL.EXPERIENCE_VALUES

socket *

The socket instance

room string

The ID of the room

player string

ID of the player

public beginConnection() source

import {beginConnection} from 'atomblast.io/src/client/js/socket.js'

Attempts to connect to the server. Run on 'start game' press.

  • Manages connecting to main server vs. devserver
  • Sets up socket listeners
  • Loads textures
  • Loads pixi

public bindHandler(id: string, handlerMethod: function) source

import {bindHandler} from 'atomblast.io/src/client/js/app.js'

Binds handlerMethod to onclick event for element id.

Params:

NameTypeAttributeDescription
id string
handlerMethod function

public canCraft(player: *, room: *, blueprint: *): boolean source

Params:

NameTypeAttributeDescription
player *
room *
blueprint *

Return:

boolean

public collisionDetect(socket: *, room: string, thisPlayer: *, tempObjects: *) source

import {collisionDetect} from 'atomblast.io/src/server/utils/collision.js'

Runs once a frame, checks for collisions between objects and handles them accordingly. Run using

Params:

NameTypeAttributeDescription
socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

room string

The name of the room

thisPlayer *

The player object

tempObjects *

The list of objects to tick. Should only be the objects rendered on the screen of thisPlayer. Contains compounds, atoms, players

public createCompound(data: *, room: string, thisPlayer: *, socket: *): * source

import {createCompound} from 'atomblast.io/src/server/utils/compound.js'

Checks if a compound can be created, deducts craft material, and returns the new compound. Does NOT add the new compound to the objects array.

Params:

NameTypeAttributeDescription
data *

Data sent from the client.

  • blueprint: The blueprint of the compound to create
  • sendingTeam: Team of the player who sent this
  • mousePos: Mouse position of the player who sent this. Contains x and y components
  • sender: Player who sent this
  • streamID: number indicating the consecutive compounds requested on this current mouse hold.
room string

The name of the room

thisPlayer *

The current player instance

socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

Return:

*

public createPlayer(data: *): Player source

import {createPlayer} from 'atomblast.io/src/client/js/pixigame.js'

Creates a Player instance once the stage is fully set up and ready.

Params:

NameTypeAttributeDescription
data *

Starting values to assign to the player. Generated from server

Return:

Player

The Player object that was created

public createRenderAtom(data: *): * source

import {createRenderAtom} from 'atomblast.io/src/client/js/obj/create.js'

Renders a new atom.

Params:

NameTypeAttributeDescription
data *

The server object reference to spawn on the clientside. Must contain:

  • typeID {string} See GLOBAL.ATOM_IDS
  • id {number} Unique ID
  • posX {number}
  • posY {number}
  • vx {number}
  • vy {number}

Return:

*

public createRenderCompound(data: *): * source

import {createRenderCompound} from 'atomblast.io/src/client/js/obj/create.js'

Recreates an already spawned compound on the clientside based on server data.

Params:

NameTypeAttributeDescription
data *

Data sent from server:

  • id {number} Unique ID
  • posX {number}
  • posY {number}
  • vx {number}
  • vy {number}
  • blueprint {*}
  • sendingTeam {string}
  • sender {number - socket ID}

Return:

*

public createTiles() source

import {createTiles} from 'atomblast.io/src/client/js/obj/create.js'

public damage(data: *, room: string, socket: *) source

Changes the health of the player by the amount given.

Params:

NameTypeAttributeDescription
data *

The data sent by the client. Contains:

  • damage (number)
  • player (id string of player that was hit)
  • id (id string of compound)
  • sentBy (id string of player that sent compound)
room string

This room.

socket *

This socket. Must include the player id and amount to damage. Amount may be negative (for health boost).

public damageTile(tileID: *, damageAmount: *, player: *, room: *, socket: *): boolean source

Params:

NameTypeAttributeDescription
tileID *
damageAmount *
player *
room *
socket *

Return:

boolean

public deleteObject(type: string, id: *, room: string, socket: *) source

import {deleteObject} from 'atomblast.io/src/server/server.js'

Deletes one of the three types of gameObjects synced to the server

Params:

NameTypeAttributeDescription
type string

Either players, atoms, compounds

id *

ID of the object to delete

room string

Room name to delete in

socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

public destroyPIXI() source

import {destroyPIXI} from 'atomblast.io/src/client/js/pixigame.js'

Destroy everything in PIXI. DANGEROUS avoid!

public disconnect() source

import {disconnect} from 'atomblast.io/src/client/js/socket.js'

Run on disconnect to reset all server-based variables and connections

public displayWinner(data: *) source

import {displayWinner} from 'atomblast.io/src/client/js/app.js'

Displays the winner panel after a game has concluded.

Params:

NameTypeAttributeDescription
data *

Server sent data, including name and score of winning team.

public distanceBetween(obj1: *, obj2: *): * source

import {distanceBetween} from 'atomblast.io/src/client/js/global.js'

Params:

NameTypeAttributeDescription
obj1 *
obj2 *

Return:

*

public eraseCookie(name: string) source

import {eraseCookie} from 'atomblast.io/src/client/js/lib/cookies.js'

Removes the given cookie.

Params:

NameTypeAttributeDescription
name string

The name of the cookie to erase.

public frameSync(socket: *, room: string) source

Runs once a frame, per ROOM. Refactored 4/8/19 from player to room.

Params:

NameTypeAttributeDescription
socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

room string

The name of the room

public generateID(): * source

import {generateID} from 'atomblast.io/src/client/js/global.js'

Returns a random number between between 10000000 and 99999999, inclusive. TODO Make every ID guaranteed unique

Return:

*

random id between 10000000 and 99999999

public getCookie(name: string): string source

Sets the value of a cookie.

Params:

NameTypeAttributeDescription
name string

Name of cookie

Return:

string

The value of the cookie. Returns null if the cookie is not found.

public getCurrTile(obj: *): string source

import {getCurrTile} from 'atomblast.io/src/client/js/global.js'

Gets the tile directly underneath any object.

Params:

NameTypeAttributeDescription
obj *

Any valid GameObject.

Return:

string

one-letter ID of current tile.

public getField(path: *): * source

import {getField} from 'atomblast.io/src/server/server.js'

Returns the value given a path to that value. Adopted from https://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key

Params:

NameTypeAttributeDescription
path *

Array containing all of the subobject identifiers, with the 0th index being the lowest level. Example: rooms.myRoom.players could be accessed through a path value of ['rooms', 'myRoom', 'players']

Return:

*

The value for the given field.

public getGlobalLocation(obj: *): {"globalY": *, "globalX": *} source

import {getGlobalLocation} from 'atomblast.io/src/client/js/global.js'

Gets the coordinates of the tile directly underneath the object.

Params:

NameTypeAttributeDescription
obj *

Any valid GameObject.

Return:

{"globalY": *, "globalX": *}

public getIngame(): boolean source

import {getIngame} from 'atomblast.io/src/client/js/pixigame.js'

Return:

boolean

Returns inGame variable

public getTeamColors(room: string): * source

import {getTeamColors} from 'atomblast.io/src/server/utils/serverutils.js'

Returns the team colors object (see client socket.js for more information on the format)

Params:

NameTypeAttributeDescription
room string

The room name to check

Return:

*

public getTeamNumber(room: string, teamName: string): * source

import {getTeamNumber} from 'atomblast.io/src/server/utils/serverutils.js'

Returns the index of the given team within the team array of the given room.

Params:

NameTypeAttributeDescription
room string

The room name to check

teamName string

The team name to return the number of

Return:

*

public getTileID(globalLocation: *, room: string): boolean source

Returns the serverside ID of the tile at this location. If the tile is not capturable, then returns false.

Params:

NameTypeAttributeDescription
globalLocation *

Contains globalX and globalY. Location on the map

room string

The room name to check

Return:

boolean

public hideElement(el: string) source

import {hideElement} from 'atomblast.io/src/client/js/app.js'

Hides a visible element

Params:

NameTypeAttributeDescription
el string

The id of the element to hide

public incrementAtom(player: *, room: *, atomType: *, quantity: *) source

import {incrementAtom} from 'atomblast.io/src/server/utils/atoms.js'

Params:

NameTypeAttributeDescription
player *
room *
atomType *
quantity *

public incrementField(amount: *, path: *) source

import {incrementField} from 'atomblast.io/src/server/server.js'

Shorthand to add or concatenate an amount to a field. Best used with numbers or strings.

Params:

NameTypeAttributeDescription
amount *

Amount to increment the field by.

path *

Path to the field.

public initGlobal() source

Global initialiation. Run once on server start.

public initPlayer(socket: *, room: string, team: string): * source

Run on every player join.

Params:

NameTypeAttributeDescription
socket *

The socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

room string

The name of the room that the player belongs to

team string

The name of the team that the player belongs to

Return:

*

public initRoom(socket: *, roomName: string) source

Run when the first person joins a new room that has not been initialized yet.

Params:

NameTypeAttributeDescription
socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

roomName string

The name of the room

public isFocused(): * source

import {isFocused} from 'atomblast.io/src/client/js/pixigame.js'

If the document is Focused return true otherwise false

Return:

*

public isInBounds(obj: GameObject): * source

import {isInBounds} from 'atomblast.io/src/client/js/global.js'

Returns true if the object parameter is within the map boundaries.

Params:

NameTypeAttributeDescription
obj GameObject

The object to test

Return:

*

true if the object parameter is within the map boundaries

public keyboard(keyCode: *): * source

Params:

NameTypeAttributeDescription
keyCode *

Return:

*

public loadTextures() source

import {loadTextures} from 'atomblast.io/src/client/js/pixigame.js'

public mouseDownHandler(e: *) source

import {mouseDownHandler} from 'atomblast.io/src/client/js/pixigame.js'

Called on mouse down from app.js

Params:

NameTypeAttributeDescription
e *

Click event

public mouseUpHandler(e: *) source

import {mouseUpHandler} from 'atomblast.io/src/client/js/pixigame.js'

Called on mouse up from app.js

Params:

NameTypeAttributeDescription
e *

Click event

public movePlayer(direction: string) source

import {movePlayer} from 'atomblast.io/src/client/js/pixigame.js'

Moves the player by changing its velocity.

Params:

NameTypeAttributeDescription
direction string

up, down, left, or right

public quitGame(msg: string, isError: boolean) source

import {quitGame} from 'atomblast.io/src/client/js/app.js'

Transitions from in-game displays to the main menu.

Params:

NameTypeAttributeDescription
msg string

The message to be displayed in the menu after disconnect.

isError boolean

True if the game quit was due to an error; false otherwise.

public requestCreateCompound(blueprint: *, xIn: number, yIn: number, streamID: number): * source

import {requestCreateCompound} from 'atomblast.io/src/client/js/obj/create.js'

Creates a Compound by sending a request to the server.

Params:

NameTypeAttributeDescription
blueprint *

Then blueprint to create the compound from

xIn number

x-coords

yIn number

y-coords

streamID number

The current stream number.

Return:

*

true if successful, false if the compound was not requested.

public roomMatchmaker(socket: *, room: string, team: string): * source

import {roomMatchmaker} from 'atomblast.io/src/server/utils/matchmaker.js'

Matchmaking system for public matches. Runs after initial socket.io server connection, but before connecting to a server.

Params:

NameTypeAttributeDescription
socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

room string

Name of room

team string

Name of team

Return:

*

The new room that has been assigned

public setCookie(name: string, value: string, days: number) source

Sets the value of a cookie.

Params:

NameTypeAttributeDescription
name string

Name of cookie

value string

New value of cookie

days number

Number of days this cookie will last for

public setField(value: *, path: *) source

import {setField} from 'atomblast.io/src/server/server.js'

Sets a new value for a protected server field. Adopted from https://stackoverflow.com/questions/18936915/dynamically-set-property-of-nested-object

Params:

NameTypeAttributeDescription
value *

The value to set

path *

Array containing all of the subobject identifiers, with the 0th index being the lowest level. Example: rooms.myRoom.players could be accessed through a path value of ['rooms', 'myRoom', 'players']

public setIngame(newValue: boolean) source

import {setIngame} from 'atomblast.io/src/client/js/pixigame.js'

Sets the value of inGame

Params:

NameTypeAttributeDescription
newValue boolean

Value to set inGame to

public showElement(el: string) source

import {showElement} from 'atomblast.io/src/client/js/app.js'

Displays a hidden element

Params:

NameTypeAttributeDescription
el string

The id of the element to show

public showGameUI() source

import {showGameUI} from 'atomblast.io/src/client/js/pixigame.js'

Call this function to hide loading div and show UI

public smartEmit(socket: *, room: string, emitName: string, emitContent: *, to: string) source

Params:

NameTypeAttributeDescription
socket *

The socket.io instance (independent)

room string

Name of the room to emit to.

emitName string

Name of the emit event, used to match on the clientside.

emitContent *

What content to send over. This can be any object.

to string

(OPTIONAL) What ID to send the emit to. Default: sends to all players.

public spawnAtom(x: number, y: number, type: string, room: string, team: string, verbose: boolean) source

import {spawnAtom} from 'atomblast.io/src/server/utils/atoms.js'

Params:

NameTypeAttributeDescription
x number

X-position of center

y number

Y-position of center

type string

Type of atom to spawn

room string

The room to spawn in

team string

The team that can pick up this atom. Set to 'all' for neutral spawns.

verbose boolean

True if this method should output to the console

public spawnAtomAtVent(row: number, col: number, room: string, team: string, verbose: boolean) source

import {spawnAtomAtVent} from 'atomblast.io/src/server/utils/atoms.js'

Spawns an atom at the vent at the given row and column.

Params:

NameTypeAttributeDescription
row number

The row of the vent

col number

The column of the vent to spawn at

room string

The room to spawn in

team string

The team that can pick up this atom. Set to 'all' for neutral spawns.

verbose boolean

True if this method should output to the console

public splash() source

TODO

public startGame(emit: boolean, teams: *) source

import {startGame} from 'atomblast.io/src/client/js/pixigame.js'

Starts the game after lobby closes.

Params:

NameTypeAttributeDescription
emit boolean

True if this client should emit the event to the server.

teams *

Array of teams on the scoreboard.

public tickCompound(compound: number, room: string, socket: *) source

import {tickCompound} from 'atomblast.io/src/server/utils/compound.js'

Checks compound behavior based on compound type. Runs once a frame.

Params:

NameTypeAttributeDescription
compound number

compound object

room string

Name of room

socket *

socket.io instance. INDEPENDENT OF PLAYER (any valid socket connection can go here!!!!!)

public updateAtomList(atomID: string) source

import {updateAtomList} from 'atomblast.io/src/client/js/app.js'

Updates the list of atoms that the player holds. Only updates the entry for the particular ID given.

Params:

NameTypeAttributeDescription
atomID string

The ID of the atom to update.

public updateCompoundButtons(selectedSlot: number) source

import {updateCompoundButtons} from 'atomblast.io/src/client/js/app.js'

Params:

NameTypeAttributeDescription
selectedSlot number

The index of the selected slot. 0-3

public updateLobby(data: *) source

import {updateLobby} from 'atomblast.io/src/client/js/app.js'

Run on new player join to sync lobby information

Params:

NameTypeAttributeDescription
data *

The data transferred from server

public updateScores(teamSlot: *, increment: *) source

import {updateScores} from 'atomblast.io/src/client/js/app.js'

Updates the team scoreboard on screen.

Params:

NameTypeAttributeDescription
teamSlot *
increment *