Giter Club home page Giter Club logo

pyhedrals's Introduction

PyHedrals Build Status

A library for evaluating tabletop dice roll expressions.

Usage Overview

Sample usage: 5d6!>4 + (5d(2d10)dl - d10) * (d20 / 2) # for an unnecessarily complicated roll

Sample output: 84 for an unnecessarily complicated roll

There is also a verbose mode that outputs every individual die roll, that output looks like this: [2d10: 2,5 (7) | 5d7: -1-,6,2,4,5 (17) | 1d10: 3 (3) | 1d20: 9 (9) | 5d6: 2,2,3,*5*,*5*,2,*5*,4 (28)] 84 for an unnecessarily complicated roll

Supported Operators

  • Arithmetic: + - * / % ^ () (addition, subtraction, multiplication, division, modulus, exponent, parentheses)
  • Dice: #d# (eg, 3d6, d20)
    • Rolls the left number of dice with the right number of sides. 3d6 rolls 3 six-sided dice
    • The first number is optional and defaults to 1 if omitted
  • Dice modifiers:
    • Keep/Drop Highest/Lowest: kh# kl# dh# dl#
      • Keeps/Drops only the # highest/lowest dice rolls. Any that are either not kept or dropped are removed from the total
      • The number is optional and defaults to 1 if omitted
    • Exploding: ! !# !># !>=# !<# !<=#
      • Each die that rolls maximum (!), or a specific number (!#), or over/under a threshold (!># !>=# !<# !<=#), adds an additional die to the pool
        • This repeats for each die added to the pool
    • Reroll: r r# r># r>=# r<# r<=#
      • Drops and rerolls each die that rolls minimum (r), or a specific number (r#), or over/under a threshold (r># r>=# r<# r<=#)
        • This repeats for each die rerolled. You can make it only reroll each die once with ro instead of r
    • Sorting: s sa sd
      • Sorts the dice rolls in ascending (s sa) or descending (sd) order
      • This still applies in non-verbose mode but you won't see any visible effect
  • Comments: # your comment here
    • Adds a comment to the end of the output, so you can describe what the roll is for. eg: d20+5 # for initiative
    • The # is a literal hash, not a number this time :)

If you have more ideas for operators, suggestions and pull requests are welcome!

pyhedrals's People

Contributors

starlitghost avatar pyup-bot avatar

Watchers

Hope Ranker avatar James Cloos 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.