PHP code example of joshbruce / php-dice-tower

1. Go to this page and download the library: Download joshbruce/php-dice-tower 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/ */

    

joshbruce / php-dice-tower example snippets


use JoshBruce\DiceTower\DicePool;

DicePool::roll4d6()->highest(3)->sum();
// step 1: [3, 5, 2, 1]
// step 2: [5, 3, 2]
// step 3: 10

use JoshBruce\DiceTower\DicePool;

DicePool::roll(4, 6)->highest(3)->sum();
// step 1: [3, 5, 2, 1]
// step 2: [5, 3, 2]
// step 3: 10

use JoshBruce\DiceTower\DicePool;

DicePool::roll();
// rolls 1d6

DicePool::roll(1, 6);
// rolls 1d6

use JoshBruce\DiceTower\Dn;

Dn::withSides();
// roll 1 die with the given number of sides

composer