Git Product home page Git Product logo

d20's Introduction

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

then run:

pub get

or with flutter:

flutter packages get

Usage

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:

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

d20's People

Contributors

comigor avatar csells avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.