Empirica.gameStart(callback)
gameInit
callback is called just before a game starts, when all players are ready, and it must create rounds and stages for the game.game
object, which gives access to the players
and the treatment for this game.addRound()
method, which allows to add a round to the game
. The returned Round object will implement the addStage(stageArgs)
method, which allows to add a Stage to the Round. The stageArgs
object to be passed to the stage creation method must contain:name
: the name used to identify this stage in the UI codedisplayName
: which will be showed to the UI to playersdurationInSeconds
: the stage duration, in seconds​
Empirica.onRoundStart(callback)
onRoundStart
is triggered before each round starts, and before onStageStart
. It receives the same options as onGameStart
, and the round that is starting.Empirica.onStageStart(callback)
onRoundStart
is triggered before each stage starts. It receives the same options as onRoundStart
, and the stage that is starting.Empirica.onStageEnd(callback)
Empirica.onRoundEnd(callback)
Empirica.onGameEnd(callback)
set()
and append()
you make (avoid calling them on a continuous drag of a slider for example) and inside these callbacks use the key
argument at the very beginning of the callback to filter out which keys your need to run logic against.Empirica.onSet(callback)
onSet
is called when the experiment code call the .set()
method on games, rounds, stages, players, playerRounds or playerStages.Empirica.onAppend(callback)
onSet
is called when the experiment code call the .append()
method on games, rounds, stages, players, playerRounds or playerStages.Empirica.onChange(callback)
onChange
is called when the experiment code call the .set()
or the .append()
method on games, rounds, stages, players, playerRounds or playerStages.onChange
is useful to run server-side logic for any user interaction. Note the extra isAppend
boolean that will allow to differenciate sets and appends.Empirica.onSubmit(callback)
onSubmit
is called when the experiment code call the .submit()
on a Stage..submit()
is explicitely called on the Stage object. Players for which the stage times out naturally, onSubmit
will not be triggered.Empirica.bot(name, configuration)
bot
method allows to add a bot with name
(e.g. "Alice"), while the configuration
is a set of callbacks that will allow to configure how the bot is suppose to react in certain conditions.configuration
has the follows callbacks:onStageTick
: called during each stage at 1 second intervalonStageStart
: CURRENTLY NOT SUPPORTED called at the beginning of eachonRoundStart
/onStageStart
)onStageEnd
: CURRENTLY NOT SUPPORTED called at the end of each stageonStageEnd
, before onRoundEnd
if it's the enf of the round)onPlayerChange
: CURRENTLY NOT SUPPORTED called each time any (human)secondsRemaining
: the number of remaining seconds in the stageEmpirica.round(Component)
Round
Component that will contain all of the UI logic for your game.Empirica.consent(Component)
Consent
Component you want to present players before they are allowed to register.onConsent
Empirica.introSteps(callback)
introSteps
callback should return an array of 0 or more React Components to show the user in order.game
given here only has the treatment
field defined as the game has not yet been created.InstructionStepOne
or Quiz
, in this example, are components that are not implemented in this example, they are simply React Components.Empirica.exitSteps(callback)
exitSteps
callback should return an array of 1 or more React Components to show the user in order.ExitSurvey
or Thanks
, in this example, are components that are not implemented in this example, they are simply React Components.Empirica.lobby(Component)
Lobby
Component to replace the default lobby.Empirica.header(Component)
Header
Component to replace the default app header.Empirica.breadcrumb(Component)
Breadcrumb
Component to replace the default Round/Stage progress indicator. This is the UI that shows which are the current Round and Stage, between the page Header and the RoundEmpirica.routes()
routes
are the entry point for the Empirica app. It is required to be used as part of the React render tree for Empirica to work properly and the example below usually does not need changing, other than the HTML node to attach to (document.getElementById("app")
here).Game
objectindex
treatment
{ "playerCount": 12 }
.rounds
createdAt
Round
objectindex
Stage
objectindex
name
if (name === "outcome") ...
).displayName
durationInSeconds
startTimeAt
onStageStart
).Player
objectindex
id
urlParams
bot
Alice
).readyAt
exitAt
exitStatus
online
idle
lastActivityAt
lastLogin.at
GameLobby
objecttreatment
{ "playerCount": 12 }
.queuedCount
playerCount
Factor, as Empirica can sometimes overbook Games to shorten wait times.
Use gameLobby.treatment.playerCount
to get the expected number of players.readyCount