Overview

Server functions

essential.addPlayer
essential.createPlayerInfo
essential.disconnectedPlayer
essential.getGameStateData
essential.getScore
essential.handlePacket
essential.handleState
essential.playerAddedToIdleGame
essential.reconnectedPlayer
essential.removePlayer
essential.setupGameRoom
essential.storeHighScore
essential.winnerResult

helper.bootPlayer
helper.calcScoreFromTime
helper.getAllPlayerInfos
helper.getAllPlayerNames
helper.getCurrentTime
helper.getPlayerInfo
helper.getPlayerPosition
helper.getSpecialStat
helper.getSquizQuestion
helper.getStat
helper.numberOfPlayersInGame
helper.postNewState
helper.postPacketToAll
helper.postPacketToPlayer
helper.postPacketToRest
helper.removeCheater
helper.setLobbyStatus
helper.setPlayerInfo
helper.storeStat
helper.trace

Client methods

chat.addText
chat.connectToLobby
chat.connectToPlayerComponent

lobby.addEventListener
lobby.exitToLobby
lobby.getInviteAddress
lobby.getSettings
lobby.sendPacket
lobby.setGameName
lobby.setLocal
lobby.updateSettings

player.clearPlayerInfo
player.updatePlayerInfo

essential.handleState

Prototype

function handleState(stateType, dataObject)

Input parameters

stateType - type of the state we are changing into
dataObject - data associated with the new state (can be null)

Return value

array defining the next state, or null if no next state should be set

Description

Handles a game state change. Should return an object with information of the next planned state change, or null if the game should be set to idle.

Returned object should be an associated array with the fields newstatetype, newdata and timenextstate. STARTGAME_STATE and ENDGAME_STATE are special, see the Programmers Guide for more information about handling states.

Example code

function handleState(stateType, dataObject)
{
    if (stateType == STARTGAME_STATE)
    {
        // Handle the start game state
        // ...

        return {"newstatetype":STATE_NEXT_QUESTION, "newdata":null,
            "timenextstate":0};
    }

    if (stateType == STATE_NEXT_QUESTION)
    {
        // ...

        return {"newstatetype":ENDGAME_STATE,
            "newdata":{"startnewwait": 8000 },
            "timenextstate":0};
    }

    return null;
}