Skip to content

tilttek/spotlight

✅ published

Play time shared among a table's players, and who is waiting for their turn.

tilttek/spotlight keeps a discreet count of the scene at a game table: who holds it now, how long each player held it, how long since their last scene, and who waits with a raised hand. The game master reads it, alone by default, to share the play time; the table sees who holds the scene and the queue.

  • The scene. Given to a player, taken back for a scene of the whole group, passed to the next player who should have it: the first raised hand, else the player who held it the least, who has waited the longest at equal time.
  • The queue. A player raises a hand in one gesture and waits first come, first served; giving them the scene takes them out of it.
  • The shares. Each player's time, scenes and share of the table's time, and whether they are behind: below a part of the fair share once the table has counted enough time — half of it after ten minutes, by default.
  • Pauses and seats. The table pauses the count and resumes it; a player joins in the last seat or leaves with their count; a closed table changes no more.
  • Who sees what. The counts are for the game master by default; a table that wants them shows them to everyone.

The service reads the time from a PSR-20 clock and from nothing else; it never listens to the players. The facts of a table — opened, a scene given or ended, a hand raised or lowered, paused, resumed, a player joined or left, closed — go to an observer, each once, by identifiers only.

It is a plain PHP library: one service, value objects, ports and a store kept in memory for tests.

Status

PartState
Table, PlayerShare, Visibility, FairnessPolicy: a table and its players' counts, bounded and checkedImplemented and tested
Spotlight: open, give, give next, release, raise and lower a hand, pause, resume, join, leave, closeImplemented and tested
View\SpotlightView and View\PlayerSpotlight: the shares for the game master, and what the table seesImplemented and tested
Store\InMemoryTableStore: the store of the testsImplemented and tested
A Symfony bundle: the Doctrine store, Mercure and a Stimulus displayNot started

Documentation

DocumentWhat it covers
InstallationRequirements, installing and wiring.
Scenes and sharesThe scene, the queue, the next player, pauses, seats, closing, the shares and who sees them.
Extension pointsThe store, the observer and its events, the clock, and who may do what.
ExceptionsSpotlightException and its exceptions.
TestingThe library's tests and its benchmarks.
ReferenceEvery type of the library, with its role.

Quick start

use Tilttek\Spotlight\Spotlight;

$spotlight = new Spotlight($store, $clock, $observer);       // your TableStore, a PSR-20 clock, an observer

$spotlight->open('table-4', ['player-1', 'player-2', 'player-3']);
$spotlight->give('table-4', 'player-1');                     // player 1 has the scene
$spotlight->raiseHand('table-4', 'player-3');                // player 3 waits
$spotlight->giveNext('table-4');                             // the scene goes to player 3
$spotlight->release('table-4');                              // a scene of the whole group

$view = $spotlight->view('table-4');
$view->toArray();                                            // for the game master: times, shares, who is behind
$view->toTableArray();                                       // for the table: who holds the scene, and the queue

Requirements

PHP 8.5 or later, with psr/clock.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Tilttek project. See LICENSE.