teamradhq / dice-rolls
0.0.1
2026-10-27 04:15 UTC
Requires
- php: ^8.5
Requires (Dev)
- laravel/pint: ^1.29
- mockery/mockery: ^1.6
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-mockery: ^2
- phpstan/phpstan-phpunit: ^2
- phpstan/phpstan-strict-rules: ^2
- phpunit/phpunit: ^13.1
- rector/rector: ^2.4
- squizlabs/php_codesniffer: ^4
- symfony/var-dumper: ^8
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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']