Search by

teamradhq / dice-rolls

teamradhq

Package info

github.com/teamradhq/dice-rolls

pkg:composer/teamradhq/dice-rolls

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.0.1 2026-10-27 04:15 UTC

This package is auto-updated.

Last update: 2026-10-27 04:41:31 UTC


README

A simple package for rolling dice and making roll tables.

Quick Start

Roll some dice:

use Teamradhq\DiceRoll\Dice;

$d6 = Dice::make();
$d20 = Dice::make(20);

Roll the dice:

$d6->roll()->result();          // 3
$d6->advantage()->result();     // 6
$d6->disadvantage()->result();  // 1

$d20->roll()->result();          // 10
$d20->advantage()->result();     // 20
$d20->disadvantage()->result();  // 1

$rolls = $d20->times(3);
foreach ($rolls as $roll) {
    $roll->result(); // 1 - 20
}

Create a roll table:

use Teamradhq\DiceRoll\RollTable;
use Teamradhq\DiceRoll\PrimitiveType;

$table = new RollTable(6, PrimitiveType::String);

Add some items:

$table->add('One');
$table->add('Two', 2);
$table->add('Three', 3);

Roll for an item:

$table->disadvantage(); // 'One'
$table->roll();         // 'Two'
$table->advantage();    // 'Three'

Get a specific item:

$table->get(1)          // 'One';
$table->get(3)          // 'Two';
$table->get(6)          // 'Three';

List all items:

$table->list();         // ['One', 'Two', 'Three']