Skip to content
Dart library for RPG dice rolling
Dart HCL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci trying to figure out circleci Sep 14, 2018
.github
example readme and example Sep 17, 2018
lib Agree with dartanalyzer using dart 2.1.0 Dec 19, 2018
test create rollWithStatistics Sep 17, 2018
.gitignore gitignore.io Sep 14, 2018
CHANGELOG.md 0.2.0 Sep 17, 2018
LICENSE Initial commit Sep 14, 2018
README.md readme and example Sep 17, 2018
analysis_options.yaml Agree with dartanalyzer using dart 2.1.0 Dec 19, 2018
pubspec.yaml Agree with dartanalyzer using dart 2.1.0 Dec 19, 2018

README.md

D20

Pub Package CircleCI

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

then run:

pub get

or with flutter:

flutter packages get

Usage

import 'package:d20/d20.dart';

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

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

import 'package:d20/d20.dart';
import 'package:d20/roll_statistics.dart';

void main() {
  final D20 d20 = D20();
  final RollStatistics stats = d20.rollWithStatistics('2d8+5+5d6');
  print(stats.results[0].faces);
  print(stats.results[1].results);
}

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.

You can’t perform that action at this time.