d20 0.2.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 66

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.

CHANGELOG

0.2.0

  • Add rollWithStatistics to D20, with (probably) useful information of roll results.

0.1.1

  • Obvious conditional optimization.

0.1.0

  • Add support to -L/-H subtractions.

0.0.3

  • Add support to d% notation.

0.0.2

  • Initial release. Support standard dice notation and arithmetic operations.

example/main.dart

import 'package:d20/d20.dart';

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

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  d20: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:d20/d20.dart';
  
Version Uploaded Documentation Archive
0.2.0 Sep 17, 2018 Go to the documentation of d20 0.2.0 Download d20 0.2.0 archive
0.1.1 Sep 17, 2018 Go to the documentation of d20 0.1.1 Download d20 0.1.1 archive
0.1.0 Sep 14, 2018 Go to the documentation of d20 0.1.0 Download d20 0.1.0 archive
0.0.2 Sep 14, 2018 Go to the documentation of d20 0.0.2 Download d20 0.0.2 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:d20/d20.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
math_expressions ^1.0.0 1.0.0
Transitive dependencies
dart2_constant 1.0.2+dart2
vector_math 2.0.8
Dev dependencies
test ^1.0.0