Extension points
tilttek/spotlightThe package is at 0.x: its extension points are stable only from its 1.0 release. Until then, a minor version may
change them, and its CHANGELOG says how.
| To | Do |
|---|---|
| Keep the tables | Implement Contract\TableStore, and pass it to Spotlight. |
| Act on what happened | Implement Contract\SpotlightObserver, and pass it to Spotlight. |
| Give the time | Pass a PSR-20 ClockInterface. |
| Say when a player is behind | Pass a FairnessPolicy to Spotlight::open(). |
| Say who may give the scene, pause, close, or raise a hand | Check it in the application before calling Spotlight. |
The store
Contract\TableStore keeps the tables, each at a version:
table()gives one by its identifier, or null;save()keeps one at the next version and returns it. One at version 0 is new, and the store has none of its identifier; any other is kept only when the store holds it at that version, andSpotlightConflictis raised otherwise, nothing kept.
Two game masters give the scene at once and both read version 7: the first save keeps version 8, and the second is
refused with SpotlightConflict; read anew, the scene is given already.
Store\InMemoryTableStore keeps them in memory, as long as the object lasts: it is for tests. An application keeps
them in its database. A table holds strings, integers, booleans, moments, its visibility — an enumeration whose value
is its string case — its fairness policy — two integers — its queue of identifiers, and its players, each strings,
integers and up to two moments.
The observer and its events
Contract\SpotlightObserver::notify() is told each fact once the table is kept, by identifiers only:
| Event | When | Carries |
|---|---|---|
Event\TableOpened | A table was opened. | |
Event\SceneGiven | A player was given the scene. | the player |
Event\SceneEnded | A player's scene ended. | the player, the milliseconds counted |
Event\HandRaised | A player raised their hand. | the player |
Event\HandLowered | A player lowered their hand. | the player |
Event\SpotlightPaused | A table was paused. | |
Event\SpotlightResumed | A table counts again. | |
Event\PlayerJoined | A player joined the table. | the player |
Event\PlayerLeft | A player left the table. | the player |
Event\TableClosed | A table was closed. |
Every event implements Event\SpotlightEvent, whose table is an identifier; the events of one player implement
Event\PlayerEvent, which adds player. When the scene passes, SceneEnded comes first, then SceneGiven; when the
holder leaves, SceneEnded then PlayerLeft; when a table closes, SceneEnded then TableClosed. A call that
changes nothing tells nothing. An application sends a message from them — through Messenger, with the identifiers
alone — and reads the rest from the store: a push of the view to the game master and of the table's view to the
players.
The clock
Spotlight reads the time from the PSR-20 ClockInterface it is given, and from nothing else. Between two calls,
nothing happens on its own: the time of the scene in progress is counted when it is read. A clock that goes back counts
nothing more, never a negative time.