https://github.com/granam/dice-rolls
Wanna random number? And what about dices, six-sides, ten-sided, seventy-five sided, whatever?
https://github.com/granam/dice-rolls
dice numbers php random roll
Last synced: about 1 month ago
JSON representation
Wanna random number? And what about dices, six-sides, ten-sided, seventy-five sided, whatever?
- Host: GitHub
- URL: https://github.com/granam/dice-rolls
- Owner: granam
- License: mit
- Created: 2015-03-31T11:34:48.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T09:35:31.000Z (over 5 years ago)
- Last Synced: 2026-03-20T06:59:20.122Z (4 months ago)
- Topics: dice, numbers, php, random, roll
- Language: PHP
- Homepage: https://www.drdplus.info
- Size: 258 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/jaroslavtyc/drd-dice-rolls)
[](https://codeclimate.com/github/jaroslavtyc/drd-dice-rolls/coverage)
[](https://packagist.org/packages/drd/dice-rolls)
[Let's roll!](#lets-roll)
[Custom dices & rolls](#custom-dices--rolls)
[Install](#install)
## Let's roll!
```php
roll();
if ($rolledValue === 6) {
echo 'Hurray! You win!';
} else {
echo 'Try harder';
}
$roller2d6Granam = new Roller2d6DrdPlus();
while (($roll = $roller2d6Granam->roll()) && $roll->getValue() <= 12) {
echo 'Still no bonus :( ...';
}
echo 'There it is! Bonus roll comes, with final value of '
. $roll->getValue() . '
Rolls were quite dramatic, consider by yourself: ';
foreach ($roll->getDiceRolls() as $diceRoll) {
echo 'Rolled number ' . $diceRoll->getRolledNumber() . ', evaluated as value ' . $diceRoll->getValue();
}
```
There are plenty of predefined templates of dices and rolls as 1d4, 1d6, 1d10.
You can mix those and any else you create by `CustomDice` class.
Just think about your needs and check templates. Your requirements may be already satisfied by them.
## Custom dices & rolls
There can be situations, where you need crazy combinations. Let's say one roll with 1d5 dice and three rolls with 1d74 dice.
It is easy. The hard part is only to find the way:
```php
roll();
```
## Install
- order [composer](https://getcomposer.org/download/) to add new requirement
```
composer require drd/dice-roll
```