Giter VIP home page Giter VIP logo

dice-typescript's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dice-typescript's Issues

Set a limit for face / dice number

Hi,

Would it be possible, for performance reasons, to set up a customised & disableable limit for the number of faces / dice?

Thanks you for your work,

Add support for repeating groups.

Add ellipsis syntax in groups for repetition, for example:
{2d20kl,...5}>=14

The above will repeat 2d20kl 5 times within the group, and mark each one a success if it is greater than or equal to 14.

Add Support for Compare Points

Add support in the parser and interpreter, and write tests, for compare points to denote successes and failures. For example 5d20>13 denotes a success for all rolls over 13.

Package Missing TypeScript Type Declarations

When I try and use this in my typescript project, tsc complains about the *.d.ts files missing.

Visual Studio Code error below:

attributes.ts(2,23): error TS7016: Could not find a declaration file for module 'dice-typescript'. '/Users/williamlightning/Documents/Projects/working/node_modules/dice-typescript/dist/index.js' implicitly has an 'any' type.
  Try `npm install @types/dice-typescript` if it exists or add a new declaration (.d.ts) file containing `declare module 'dice-typescript';`
The terminal process terminated with exit code: 2

Showing the amount kept or dropped in renderedExpression

I forked this repo to try to add the amount of results kept or dropped in the renderedExpression. If I roll this 5d6d2, I would like to see the renderedExpression [5, 4, 1, 2, 2]dl2 (currently it only shows [5, 4, 1, 2, 2]dl, withou the amount dropped).

I tried two approaches to this:

  • Adding a new attribute called amount to the Keep/Drop Expression. This was done in the parseKeep/parseDrop method. Then the generators must read this new attribute and show the amount.
  • Using the generateKeep and generateDrop methods to read the Keep/Drop childs and figure out the amount kept/dropped.

Wich one of this approaches should I follow? I'm not sure wich one is the best. There is any other way? I can make a pull request after adding this feature.

Lexer seems to not understand keep notation, but the parser does

As far as I can tell, 'keep' expressions (k[hl]?\d+) are being ignored because the lexer does not have the token for it defined. When debugging, parseKeep is skipped. TokenType is missing a Keep entry. (Apparently it should just be an Identifier, but still, the keep functionality does not appear to be accessible).

Preventing infinite loops in exponding/rerolling when multiple conditions are specified

The change in #22 added a check to explode/reroll condition to verify if the condition included all dice results (if that was allowed if would make explodes/rerolls forever). Roll20 don't do that, it simply allows 1000 rerolls and then stops (accepting the last roll, whatever it is). Try using this dice roll in Roll20: /roll 1d2r<3 (wait a few seconds to get a result).

Explode/reroll logic is done with while:
https://github.com/trwolfe13/dice-typescript/blob/dce5f9b6126ede665883f587704423bb78d03660/src/interpreter/dice-interpreter.class.ts#L223
https://github.com/trwolfe13/dice-typescript/blob/dce5f9b6126ede665883f587704423bb78d03660/src/interpreter/dice-interpreter.class.ts#L341)

This would still cause infinite loops if adding more complex explode/reroll conditions (eg: d2r=1r=2 or d8r=4r<4r>4)

How about setting a hard limit to rerolls (like Roll20 does)?

Add support for in-line real numbers

Currently the lexer, parser and interpreter only support inline integers. For example, the following is invalid:

3d6 * 1.5

While certainly not a common usage, it is a mathematically valid expression. Add support for parsing real numbers in the lexer, parser and interpreter, and write the appropriate unit tests for them.

Missing deployment instructions?

The Getting Started section states:

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

However, I don't see a deployment section in the main README or associated documentation. Is that section somewhere I'm not seeing, or still in progress?

Thanks!

Add Support for Dice Modifiers

Currently dice modifiers such as exploding dice, re-rolling dice, etc. are not supported.

Support for these should be implemented in the parser and interpreter, and have appropriate tests written.

Feature Request: Be able to show the individual rolls

Showing the total works great, it'd be nice to also be able to show the individual results, or a populated expression: 4d10dl2 + 5 would give you [1*,7,4*,5] + 5.

Maybe a renderedExpression property on Result?

I tried looking at this, but typescript/javascript are not my forte, and I got lost in the AST/Expressions.

Really cool project, even cooler when I saw the 5th ed e-tools you've put together!

Evaluating a bad roll expression crashes

For example, trying to roll the expression something will crash.

Looking at the stack trace, I think it is crashing when trying to interpret something as a function name. which I haven't defined. Notably, an error message is added to the error message array, but that doesn't seem to matter since we immediately try to find and call a function with that name.

Personally, I would expect the roll method to return a result with most of the values undefined or null or something similar, but allowing me to access the error messages. Alternatively, if you do want to just throw an error, it would be nice if the error message described the problem with the expression (e.g., No function called "something" defined in dice interpreter).

Clarify Behavior for Fractional Dice Rolls

Currently it is possible to achieve a decimal dice roll. Take the following example:

(5 / 2)d20

Exactly how this is handled is not defined. It should explicitly round the 5 / 2 to the nearest integer.

Make sure this is the case, write unit tests for it and update the documentation.

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.