d20 0.2.0+testgithubactions1
D20
D20 is a Dart library for RPG dice rolling. Supports standard notation (like "2d12", "d6+5" and "2d20L").
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 2d20L
, 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
toD20
, 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.
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+testgithubactions1
2. Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter pub get
Alternatively, your editor might support pub get
or flutter pub 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';
Popularity:
Describes how popular the package is relative to other packages.
[more]

54

Health:
Code health derived from static analysis.
[more]

100

Maintenance:
Reflects how tidy and uptodate the package is.
[more]

85

Overall:
Weighted score of the above.
[more]

74

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
 Dart: 2.7.1
 pana: 0.13.5
Maintenance suggestions
Package is getting outdated. (15.07 points)
The package was last published 60 weeks ago.
Dependencies
Package  Constraint  Resolved  Available 

Direct dependencies  
Dart SDK  >=2.0.0 <3.0.0  
math_expressions  ^1.0.0  1.1.1  
Transitive dependencies  
vector_math  2.0.8  
Dev dependencies  
test  ^1.5.1+1 