PHP code example of tilttek / tavern-games

1. Go to this page and download the library: Download tilttek/tavern-games library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tilttek / tavern-games example snippets


use Tilttek\GameEngine\{Move, Tables};
use Tilttek\TavernGames\{TavernGames, TavernTables};
use Tilttek\TavernGames\Game\{CrazyEights, Pig, ShipCaptainCrew};

$games = new TavernGames(new Pig(), new ShipCaptainCrew(), new CrazyEights());
$tavern = new TavernTables(new Tables($games->games(), $logStore), $games, $turnTimer);

$tavern->open('crazy-eights', 'table:7', ['seat:ann', 'seat:bob', 'seat:cid']);
$tavern->view('table:7', 'seat:ann');               // Ann's hand, the top card, the others' counts
$tavern->play('table:7', new Move(CrazyEights::DRAW, 'seat:ann'), expected: 0);
$tavern->timeout('table:7', 'seat:ann', 1);           // the timer ran out: Ann passes
$tavern->ending('table:7', 'seat:bob')?->tone;        // Victory, Tie or GoodGame once it is over