https://github.com/comigor/d20
Dart library for RPG dice rolling
https://github.com/comigor/d20
d20 dart dart-library dice dice-roller flutter hacktoberfest random rpg
Last synced: about 2 months ago
JSON representation
Dart library for RPG dice rolling
- Host: GitHub
- URL: https://github.com/comigor/d20
- Owner: comigor
- License: mit
- Created: 2018-09-14T14:43:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-01T17:50:45.000Z (over 2 years ago)
- Last Synced: 2025-04-18T05:53:34.250Z (about 2 months ago)
- Topics: d20, dart, dart-library, dice, dice-roller, flutter, hacktoberfest, random, rpg
- Language: Shell
- Homepage:
- Size: 70.3 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
D20
[![View at pub.dev][pub-badge]][pub-link]
[![Test][actions-badge]][actions-link]
[![PRs Welcome][prs-badge]][prs-link]
[![Star on GitHub][github-star-badge]][github-star-link]
[![Fork on GitHub][github-forks-badge]][github-forks-link][pub-badge]: https://img.shields.io/pub/v/d20?style=for-the-badge
[pub-link]: https://pub.dev/packages/d20[actions-badge]: https://img.shields.io/github/workflow/status/comigor/d20/CI?style=for-the-badge
[actions-link]: https://github.com/comigor/d20/actions[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
[prs-link]: https://github.com/comigor/d20/issues[github-star-badge]: https://img.shields.io/github/stars/comigor/d20.svg?style=for-the-badge&logo=github&logoColor=ffffff
[github-star-link]: https://github.com/comigor/d20/stargazers[github-forks-badge]: https://img.shields.io/github/forks/comigor/d20.svg?style=for-the-badge&logo=github&logoColor=ffffff
[github-forks-link]: https://github.com/comigor/d20/network/membersD20 is a Dart library for RPG dice rolling. Supports standard notation (like "2d12", "d6+5" and "2d20-L").
## Installation
Add the following to your `pubspec.yaml` file:
```yaml
dependencies:
d20: <1.0.0
```
then run:
```shell
pub get
```
or with flutter:
```shell
flutter packages get
```## Usage
```dart
import 'package:d20/d20.dart';void main() {
final d20 = D20();
print(d20.roll('2d8+5+5d6'));
}```
One can also get (probably) useful information of roll results:
```dart
import 'package:d20/d20.dart';void main() {
final d20 = D20();
final stats = d20.rollWithStatistics('2d8+5+5d6');
print(stats.results[0].faces);
print(stats.results[1].results);
}```
## Supported notation
The [standard dice notation](https://en.wikipedia.org/wiki/Dice_notation) will be parsed, such as 2d8+4.### L and H subtraction
When a `-L` or `-H` follows a roll, as in `2d20-L`, the lowest (or highest) roll of the sequence will be subtracted from the result.### Operators
You can also use mathematical operators, such as `1d6*3` or `10d4/d6`; or even `10 * sin(d20)`, though I'm not sure why you'd need that.### Percentile dice (d%)
You can also use use the `d%` notation instead of `d100`.