d20 0.3.1+1 copy "d20: ^0.3.1+1" to clipboard
d20: ^0.3.1+1 copied to clipboard

D20 is a Dart library for RPG dice rolling. Supports standard notation (like "2d12", "d6+5" and "2d20-L").

D20

View at pub.dev Test PRs Welcome Star on GitHub Fork on GitHub

D20 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:

dependencies:
  d20: <1.0.0
copied to clipboard

then run:

pub get
copied to clipboard

or with flutter:

flutter packages get
copied to clipboard

Usage #

import 'package:d20/d20.dart';

void main() {
  final d20 = D20();
  print(d20.roll('2d8+5+5d6'));
}

copied to clipboard

One can also get (probably) useful information of roll results:

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);
}

copied to clipboard

Supported notation #

The standard 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.

9
likes
150
points
26
downloads

Publisher

verified publisherborges.dev

Weekly Downloads

2024.09.10 - 2025.03.25

D20 is a Dart library for RPG dice rolling. Supports standard notation (like "2d12", "d6+5" and "2d20-L").

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

math_expressions

More

Packages that depend on d20