Code Monkey home page Code Monkey logo

dice_roller's People

Contributors

btmorton avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dice_roller's Issues

Multiple reroll directives are not handled correctly?

> const { DiceRoller } = require('dice-roller-parser')
undefined
> roller = new DiceRoller()
{ randFunction: [Function: random], maxRollCount: 1000 }
> roller.roll('1d4r1r4')
{
  count: { type: 'number', value: 1, success: false, valid: true, order: 0 },
  die: { type: 'number', value: 4, success: false, valid: true, order: 0 },
  rolls: [
    {
      critical: 'success',
      die: 4,
      matched: false,
      order: 0,
      roll: 4,
      success: false,
      type: 'roll',
      valid: false,
      value: 4
    },
    {
      critical: 'success',
      die: 4,
      matched: false,
      order: 1,
      roll: 4,
      success: false,
      type: 'roll',
      valid: false,
      value: 4
    },
    {
      critical: 'failure',
      die: 4,
      matched: false,
      order: 2,
      roll: 1,
      success: false,
      type: 'roll',
      valid: true,
      value: 1
    }
  ],
  success: false,
  type: 'die',
  valid: true,
  value: 1,
  order: 0,
  matched: false
}

With multiple rerolls in the formula, only the last one seems to be respected.

See the example, 1d4r1r4 -> 4 is rerolled, but 1 is used as last value.

The same forumla works on roll20:

image

Feature Request: public function to parse RootType with provided DiceRollResult

This is a feature request to add a new public function to parse previously parsed dice roll input strings (RootType) along with a provided DiceRollResult object so it can be parsed into a final RollBase object.

The application here is that I have created a 3D dice roller (using BabylonJS) that is capable of rolling dice on a canvas element and returns the face up value of the die rolled. I'd like to be able to return a "previously parsed dice roll input string" along with the roll results as an array of DiceRollResult objects to then have dice-roller-parser compute the final RollBase object. I really enjoy all the features of this package and would like to leverage it for my app.

Based on a quick review of the code, I think a good approach may be to allow the private RollType function to accept another argument of rolls: DiceRollResult that it can then pass onto the various rollType function. Then, if the rolls argument is undefined, rolls will be calculated by generateDiceRoll. Otherwise it will use the provided object. Is this feasible?

Compound rolling does not seem to be working

If I input 5d6!! whenever a six is rolled the value remains at six even though an additional d6 should be added to the value.

Additionally, since the compounded roll is not spliced into the rolls array, it can not be evaluated for additional exploding results.

[
    {
        "critical": "success",
        "die": 6,
        "matched": false,
        "order": 4,
        "roll": 6,
        "success": false,
        "type": "roll",
        "valid": true,
        "value": 6
    }
]

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.