Skip to content

Scenes and shares

tilttek/spotlight

A table has 1 to 20 players in seat order, each named by an opaque identifier: 1 to 128 letters, digits, _, ., : or -, starting with a letter, never an address. Spotlight::open() opens it with no one holding the scene and no one waiting.

$spotlight->open('table-4', ['player-1', 'player-2', 'player-3'], Visibility::GameMaster, new FairnessPolicy(50, 600_000));

The scene

One player holds the scene at a time, or no one.

  • give() gives it to a player: the scene in progress ends and is added to its holder's time, and the player's time counts from now. Giving it to its holder changes nothing.
  • release() takes it back: the scene in progress ends and no one holds it — a scene of the whole group, or of the game master. That time is no player's.
  • giveNext() gives it to the player who should have it next, the one SpotlightView::$suggested names.

Each scene given adds one to the player's scenes; each scene ended records when, for sinceLastScene.

The queue

A player who wants the scene raises a hand with raiseHand(): they wait at the end of the queue, first come, first served. A player who waits already, or holds the scene, does not move. lowerHand() takes them out; giving them the scene does too, without a HandLowered event.

The next player

giveNext() and SpotlightView::$suggested choose the same player:

  1. the first raised hand;
  2. else, among the players who do not hold the scene, the one who held it the least;
  3. at equal time, a player who never had the scene, then the one whose last scene ended the earliest;
  4. at equal waits, the first in seat order.

A table where no one else can take the scene — a single player holding it — does not change, and suggests no one.

Pauses

pause() stops the count: the scene in progress keeps the time it had, and counts no more until resume(). A scene given while the table is paused starts paused. Pausing or resuming twice changes nothing.

Seats

join() seats a player in the last seat, with an empty count, up to 20 players. leave() takes a player away with their count: their scene ends first when they hold it, and they leave the queue. The last player does not leave: the table closes.

Closing

close() ends the scene in progress, empties the queue, and closes the table: every change after it is refused with SpotlightRefused, and its view still reads.

The shares

view() gives the spotlight at the moment of the clock, as a View\SpotlightView:

FieldWhat it holds
holderThe player holding the scene, or null.
paused, closedThe state of the table.
totalThe milliseconds every player held the scene; the released time is not counted.
suggestedThe next player, or null; null on a closed table.
queueThe waiting players, first come first.
playersEach player's View\PlayerSpotlight, in seat order.
versionThe version read, for the screen to know it is late.

Each PlayerSpotlight holds the player's held milliseconds, the scene in progress counted, their scenes, their share of total in basis points — 10 000 is all of it, rounded down — whether they are holding, their waitingPosition from 1 and waitingFor in milliseconds, sinceLastScene — null before their first scene, 0 while they hold one — and whether they are behind.

Who is behind

A FairnessPolicy says when a player is behind: their time is below behindBelow percent of the fair share — total divided by the players — once total reaches warmUp milliseconds. The default is half of the fair share after ten minutes; behindBelow is 1 to 100 and warmUp 0 to a day. A player alone is never behind, nor anyone while nothing is counted.

Who sees what

Visibility says who sees the counts:

  • Visibility::GameMaster, the default: toTableArray() gives the table the holder, the state, the queue and each player's holding and waitingPosition, without total, suggested or any count;
  • Visibility::Table: toTableArray() gives the whole view, as toArray() does.

toArray() always gives the whole view: the application sends it to the game master alone.