Reference Source Test
public class | source

Client

Controls the client side changes for the application and game

Test:

Constructor Summary

Public Constructor
public

Load all the different windows/UI portions on the index page relevant for use in the game, set the zoom factor, update the orientation and then load the login screen

Member Summary

Public Members
public

An instance of the DOM $('#toggle-about') element

public

An instance of the DOM $('body') element

public

An instance of the DOM $('#border') element

public

An instance of the DOM $('#cancelButton') element

public

An instance of the DOM $('#canvasLayers') element

public

Configuration for the client application loaded from ./data/config.json

public

An instance of the DOM $('#container') element

public

An instance of the DOM $('#play') element

public

An instance of the DOM $('#toggle-credits') element

public

An instance of the DOM $('.error.message') element

public

An instance of Game class

public

An instance of the DOM $('#toggle-git') element

public

An instance of the DOM $('#guest') element

public

Used to determine if the player is logging in as a guest or not

public

The height of the player's browser window

public

An instance of the DOM $('#helpButton') element

public

An instance of the DOM $('#modal') element

public

An instance of the DOM $('.loader') element

public

An instance of the DOM $('.loader.message') element

public

Used to figure out whether or not to show the login screen

public

An instance of the DOM $('#loginButton') element

public

An instance of the DOM $('#loginNameInput') and $('#loginPasswordInput') element

public

An instance of the DOM $('#no') element

public

The orientation of the player's device

public

The field whose range is being updated

public

Callback function when this class is done loading

public

An instance of the DOM $('#newCharacter') element

public

Register fields

public

An instance of the DOM $('#rememberMe') element

public

An instance of the DOM $('#respawn') element

public

Used to display loading status messages

public

The width of the player's browser window

public

An instance of the DOM $(window) element

public

An instance of the DOM $('#content') element

public

An instance of the DOM $('#yes') element

public

Zoom percentage from 0 to 1

Method Summary

Public Methods
public

Handles clicks on the HTML5 canvas

public

Clean up any current form validation errors on the active form's input fields

public

displayScreen(origin: String, destination: String): boolean

Changes from one screen to another

public

displayScroll(content: String)

Display the given screen

public

Fades the menu

public

Return the active form from the top wrapper's class name

public

Returns the orientation of the device the user is on

public

Figures out the current scale factor to use for assets

public

Returns the zoom factor

public

Checks to see if the window has a web worker

public

Returns true if this player is playing as a guest

public

Check if the player is using a phone

public

Returns true if the join form is displayed

public

Check if the player is using a tablet

public

Handles key down presses

public

Handles key up presses

public

Add click listeners for the different parts of the UI

public

Handles mouse movements

public

onReady(callback: Function)

The callback function when this app class is ready and done loading

public

resize()

Call the game's resizer function

public

Revert the loader message to it's default state of 'Connecting to server...'

public

sendError(field: Object, error: String)

Set this input field as having an error

public

sendStatus(message: String)

Display a status message to the client

public

setGame(game: *)

Set the client to use a new instance of the game

public

Shows the menu

public

toggleLogin(toggle: Boolean)

Toggle displaying the login form

public

Toggle the read only attribute on the login fields and form registration fields

public

updateLoader(message: String)

Update the loader to show a specific message

public

Updates the orientation of the application to match the orientation of the device the player is using

public

updateRange(field: *)

Update the range of and object using a linear gradient on the background color

public

Verify this is a valid email address

public

Verify the active form

public

Verify the input fields on the join form

public

Check to see if the player has entered a valid username and password before attempting to login

public

Dismissing the welcome screen when the application has finished loading

public

zoom()

Handles zooming the container to scale the game to fit porportionally with the player's window size

Private Methods
private

Switch to the load character screen

private

Try to connect and login to the game

private

Try to login as a guest

private

Tells the game to toggle remembering this player, if true will store player information in local storage

private

Tells the game to respawn the player

Public Constructors

public constructor() source

Load all the different windows/UI portions on the index page relevant for use in the game, set the zoom factor, update the orientation and then load the login screen

Test:

Public Members

public about: Object source

An instance of the DOM $('#toggle-about') element

public body: Object source

An instance of the DOM $('body') element

public border: Object source

An instance of the DOM $('#border') element

public cancelButton: Object source

An instance of the DOM $('#cancelButton') element

public canvas: Object source

An instance of the DOM $('#canvasLayers') element

public config: Object source

Configuration for the client application loaded from ./data/config.json

public container: Object source

An instance of the DOM $('#container') element

public createButton: Object source

An instance of the DOM $('#play') element

public credits: Object source

An instance of the DOM $('#toggle-credits') element

public errorMsg: Object source

An instance of the DOM $('.error.message') element

public game: Game source

An instance of Game class

public git: Object source

An instance of the DOM $('#toggle-git') element

public guest: Object source

An instance of the DOM $('#guest') element

public guestLogin: Boolean source

Used to determine if the player is logging in as a guest or not

public height: Number source

The height of the player's browser window

public helpButton: Object source

An instance of the DOM $('#helpButton') element

public intro: Object source

An instance of the DOM $('#modal') element

public loading: Object source

An instance of the DOM $('.loader') element

public loadingMsg: Object source

An instance of the DOM $('.loader.message') element

public loggingIn: Boolean source

Used to figure out whether or not to show the login screen

public loginButton: Object source

An instance of the DOM $('#loginButton') element

public loginFields: Object[] source

An instance of the DOM $('#loginNameInput') and $('#loginPasswordInput') element

public no: Object source

An instance of the DOM $('#no') element

public orientation: String source

The orientation of the player's device

public rangeField: Object source

The field whose range is being updated

public readyCallback: Function source

Callback function when this class is done loading

public registerButton: Object source

An instance of the DOM $('#newCharacter') element

public registerFields: Array source

Register fields

public rememberMe: Object source

An instance of the DOM $('#rememberMe') element

public respawn: Object source

An instance of the DOM $('#respawn') element

public statusMessage: String source

Used to display loading status messages

public width: Number source

The width of the player's browser window

public window: Object source

An instance of the DOM $(window) element

public wrapper: Object source

An instance of the DOM $('#content') element

public yes: Object source

An instance of the DOM $('#yes') element

public zoomFactor: Number source

Zoom percentage from 0 to 1

Public Methods

public canvasClickEventListener(event: Object): Boolean source

Handles clicks on the HTML5 canvas

Params:

NameTypeAttributeDescription
event Object

click event

Return:

Boolean

public cleanErrors() source

Clean up any current form validation errors on the active form's input fields

public displayScreen(origin: String, destination: String): boolean source

Changes from one screen to another

Params:

NameTypeAttributeDescription
origin String

the old screen to hide

destination String

the new screen to show

Return:

boolean

public displayScroll(content: String) source

Display the given screen

Params:

NameTypeAttributeDescription
content String

the screen to display

public fadeMenu() source

Fades the menu

public getActiveForm(): String source

Return the active form from the top wrapper's class name

Return:

String

active form's ID

public getOrientation(): String source

Returns the orientation of the device the user is on

Return:

String

portrait|landscape

public getScaleFactor(): Number source

Figures out the current scale factor to use for assets

Return:

Number

1 = mobile, 2 = desktop and 3 = tablet

public getZoom(): Number source

Returns the zoom factor

Return:

Number

a value from 0 to 1

public hasWorker(): Boolean source

Checks to see if the window has a web worker

Return:

Boolean

returns true if the window has an active web worker

public isGuest(): Boolean source

Returns true if this player is playing as a guest

Return:

Boolean

true if player is a guest

public isMobile(): Boolean source

Check if the player is using a phone

Return:

Boolean

true if a phone

public isRegistering(): Boolean source

Returns true if the join form is displayed

Return:

Boolean

true if on the join form

public isTablet(): Boolean source

Check if the player is using a tablet

Return:

Boolean

true if a tablet

public keydownEventListener(event: Object): Boolean source

Handles key down presses

Params:

NameTypeAttributeDescription
event Object

keypress event

Return:

Boolean

public keyupEventListener(event: Object): Boolean source

Handles key up presses

Params:

NameTypeAttributeDescription
event Object

keypress event

Return:

Boolean

public loadClient() source

Add click listeners for the different parts of the UI

public mousemoveEventListener(event: Object): boolean source

Handles mouse movements

Params:

NameTypeAttributeDescription
event Object

mouse event

Return:

boolean

public onReady(callback: Function) source

The callback function when this app class is ready and done loading

Params:

NameTypeAttributeDescription
callback Function

the callback function when this application class is done loading

public resize() source

Call the game's resizer function

public revertLoader() source

Revert the loader message to it's default state of 'Connecting to server...'

public sendError(field: Object, error: String) source

Set this input field as having an error

Params:

NameTypeAttributeDescription
field Object

the Jquery instance of the field that has the error

error String

the error message to display telling the player that this field has an issue

public sendStatus(message: String) source

Display a status message to the client

Params:

NameTypeAttributeDescription
message String

the message

public setGame(game: *) source

Set the client to use a new instance of the game

Params:

NameTypeAttributeDescription
game *

public showMenu() source

Shows the menu

public toggleLogin(toggle: Boolean) source

Toggle displaying the login form

Params:

NameTypeAttributeDescription
toggle Boolean

true to hide, false to show

public toggleTyping(state: String) source

Toggle the read only attribute on the login fields and form registration fields

Params:

NameTypeAttributeDescription
state String

the state to update the fields to

public updateLoader(message: String) source

Update the loader to show a specific message

Params:

NameTypeAttributeDescription
message String

the loader message to display

public updateOrientation() source

Updates the orientation of the application to match the orientation of the device the player is using

public updateRange(field: *) source

Update the range of and object using a linear gradient on the background color

Params:

NameTypeAttributeDescription
field *

public verifyEmail(email: String): Boolean source

Verify this is a valid email address

Params:

NameTypeAttributeDescription
email String

player's email address

Return:

Boolean

true if valid

public verifyForm(): boolean source

Verify the active form

Return:

boolean

public verifyJoinForm(): Boolean source

Verify the input fields on the join form

Return:

Boolean

true if valid

public verifyLoginForm(): Boolean source

Check to see if the player has entered a valid username and password before attempting to login

Return:

Boolean

true if valid

public welcomeContinue(): boolean source

Dismissing the welcome screen when the application has finished loading

Return:

boolean

public zoom() source

Handles zooming the container to scale the game to fit porportionally with the player's window size

Private Methods

private loadCharacter(): Boolean source

Switch to the load character screen

Return:

Boolean

private login(): Boolean source

Try to connect and login to the game

Return:

Boolean

private loginAsGuest(): Boolean source

Try to login as a guest

Return:

Boolean

private rememberLogin(): Boolean source

Tells the game to toggle remembering this player, if true will store player information in local storage

Return:

Boolean

private respawnPlayer(): Boolean source

Tells the game to respawn the player

Return:

Boolean