Class: Player

Player()

Class representing a player.

Constructor

new Player()

Source:

Members

group :Group

This player's group.

Type:
Source:

id :String

The player's ID.

Type:
  • String
Source:

idInGroup :Number

Type:
  • Number
Source:

participant :Participant

This player's participant.

Type:
Source:

points :number

Type:
  • number
Default Value:
  • 0
Source:

stage :Stage

Type:
Default Value:
  • null
Source:

stageIndex :number

Type:
  • number
Default Value:
  • 0
Source:

status :string

The current status of this player.

  1. 'ready': the player is ready to play their current stage, but is waiting (for their fellow group members).
  2. 'playing': the player is playing their current stage.
  3. 'done': the player is done playing their current stage, waiting to call 'Stage.playerEnd(player)'.
  4. 'finished': player is ready to move to next stage.

See Session Flow tutorial for more details.

Type:
  • string
Default Value:
  • 'ready'
Source:

Methods

addClient(client)

addClient - description

Parameters:
Name Type Description
client type

description

Source:

app()

app - description

Source:
Returns:

App The app that this player is a member of.

appIndex() → {type}

appIndex - description

Source:
Returns:

description

Type
type

atLeastFinishedStage()

Is the player at least finished the given stage of the given period?

Return false if any of the following are true:

  • the player is in a previous app.
  • the player is in the same app, but a previous period.
  • the player is in the same period, but a previous stage.
  • the player is in the same stage, but is still 'playing'.

Otherwise return true.

CALLED FROM:

  • Stage#playerCanGroupProceedToNextStage.
Source:

compId() → {type}

compId - description

Source:
Returns:

description

Type
type

emit(name, dta)

emit - description

Parameters:
Name Type Description
name type

description

dta type

description

Source:

emitUpdate() → {type}

emitUpdate - description

Source:
Returns:

description

Type
type

endStage(endGroupopt, moveopt)

Parameters:
Name Type Attributes Default Description
endGroup boolean <optional>
true

Then try to end the stage for the group too.

move boolean <optional>
true

Then move on to the next stage. The group ending a stage
that waits for everyone (see Group#endStage) moves its players itself, after groupEnd.

Source:

endStageIfStill()

Ends stage for this player if they are still playing it (see timeUp).

Source:

inAllPeriods()

This participant's players in this app's periods, from the first to this one.

Source:

inPeriod()

This participant's player in period n (from 1) of this app, or null if there is none yet.

Source:

inPreviousPeriods()

This participant's players in this app's periods before this one, first first.

Source:

isFinished() → {type}

isFinished - description

Source:
Returns:

description

Type
type

isFinishedStage()

Whether this player has finished stage, of their current period: played it (done or
finished), or gone past it. (Players skip stages on their own, so the group's current
stage, which isFinished goes by, may be past theirs.)

Source:

isReady() → {type}

isReady - description

Source:
Returns:

description

Type
type

matchesPlayer(plyrShell) → {boolean}

matchesPlayer - description

Parameters:
Name Type Description
plyrShell type

description

Source:
Returns:

whether or not the inputted player matches this one.

Type
boolean

nextStage()

The next stage for this player.

Source:

old() → {type}

old - description

Source:
Returns:

description

Type
type

otherPlayersInGroup() → {type}

otherPlayersInGroup - description

Source:
Returns:

description

Type
type

period() → {type}

period - description

Source:
Returns:

description

Type
type

periodIndex() → {type}

periodIndex - description

Source:
Returns:

description

Type
type

roomId() → {type}

roomId - description

Source:
Returns:

description

Type
type

save()

save - description

Source:

sendUpdate(channel)

sendUpdate - description

Parameters:
Name Type Description
channel type

description

Source:

session() → {type}

session - description

Source:
Returns:

description

Type
type

shell() → {type}

this - description

Source:
Returns:

description

Type
type

shellWithChildren() → {type}

CALLED FROM

  • Participant#shellAll
Source:
Returns:

description

Type
type

startTimer()

Starts this player's own timer for stage, if it has one (see Stage#clientDuration).

Source:

timeUp()

This player's time for stage is up: marks them timed out, and unless the stage stays
open (Stage#endOnTimeout), asks their page to submit what it has and, if it has not
within stage.timeoutGrace seconds (or the player has no page), ends the stage for them.

Source:

(static) load(json, session) → {type}

Parameters:
Name Type Description
json type

description

session type

description

Source:
Returns:

description

Type
type