GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - TiltTek/turn-clock: A turn timer for the table: per-player budgets, Fischer or Bronstein increments, delays, days per move, pauses, vacations and overtime.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
doc
doc
 
 
src
src
 
 
tests/Unit
tests/Unit
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.fr.md
README.fr.md
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
composer-dependency-analyser.php
composer-dependency-analyser.php
 
 
composer.json
composer.json
 
 
phil-dev.php
phil-dev.php
 
 

Repository files navigation

tilttek/turn-clock

A turn timer for the table: per-player budgets, Fischer or Bronstein increments, delays, days per move, pauses, vacations and overtime.

tilttek/turn-clock keeps the time of a turn-based game, as a chess clock does for two players and a game clock for a table of up to 20. Each player has a budget, the same for all or one each to even the table; the clock runs for the player whose turn it is, and passing the turn charges it.

  • Time controls. An increment added after each turn (Fischer), the time spent given back up to the increment (Bronstein), a delay before the budget runs (simple delay), or the whole budget again at each turn — days per move, as in a game by correspondence.
  • Overtime. When a budget runs out, the clock counts the time over, below zero, for the table to decide; or the player is out of time, their budget stays at zero and their turns are skipped, until the clock stops when every player is out.
  • Pauses and vacations. The table pauses the clock and resumes it; a player declares vacations, during which their clock does not run.
  • The turn order. The next player in seat order who is not out of time, or the player named; time added or taken away by hand.

The service reads the time from a PSR-20 clock and from nothing else. It tells when the turn in progress runs out of time, for the application's scheduled task to check the clock at that moment. The facts of a clock — started, a turn started or ended, the time expired, paused, resumed, a vacation declared, time adjusted, stopped — 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

Part State
TimeControl, Mode, Overtime: budgets, increments, delays, days per move, overtime counted or forfeited Implemented and tested
TableClock, PlayerClock, Vacation: a clock and its players' time, bounded and checked Implemented and tested
TurnClock: create, start, pass, check, pause, resume, vacations, adjust, stop Implemented and tested
View\ClockView and View\PlayerTime: the clock to show the table, and when the turn runs out Implemented and tested
Store\InMemoryClockStore: the store of the tests Implemented and tested
A Symfony bundle: the Doctrine store, the scheduled checks, Mercure and a Stimulus display Not started

Documentation

Document What it covers
Installation Requirements, installing and wiring.
Clocks and time controls Budgets, modes, overtime, turns, pauses, vacations, adjustments, stopping and the view.
Extension points The store, the observer and its events, the clock, and checking at the expiry.
Exceptions TurnClockException and its exceptions.
Testing The library's tests.
Reference Every type of the library, with its role.

Quick start

use Tilttek\TurnClock\Mode;
use Tilttek\TurnClock\TimeControl;
use Tilttek\TurnClock\TurnClock;

$clocks = new TurnClock($store, $clock, $observer);              // your ClockStore, a PSR-20 clock, an observer

$clocks->create('table-4', ['player-1', 'player-2', 'player-3'],
    new TimeControl(10 * 60_000, Mode::Fischer, 5_000),           // ten minutes each, five seconds added per turn
    ['player-3' => 15 * 60_000],                                  // fifteen minutes for a new player
);
$clocks->start('table-4');

$clocks->pass('table-4', 'player-1');                             // player 1 ends their turn; player 2's runs
$clocks->pause('table-4');                                        // a break: no time counts
$clocks->resume('table-4');

$view = $clocks->view('table-4');                                 // send $view->toArray() to the table
// schedule $clocks->check('table-4') at $view->expiresAt

$clocks->create('mail-game', ['player-1', 'player-2'], TimeControl::daysPerTurn(3));   // three days per move

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.

About

A turn timer for the table: per-player budgets, Fischer or Bronstein increments, delays, days per move, pauses, vacations and overtime.

Topics

board-gamesgame-clockphprole-playing-gamestilttektime-controlturn-timer

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.