Skip to content

Adding features similar to the ones in Roll20 #14

Description

@DonaldTsang

The code used by Roll20: https://ghostbin.com/paste/2n67m
Documentation: https://wiki.roll20.net/Dice_Reference

  • addition, subtraction, multiplication, division, modulo, exponentiation
  • floor, ceil, round, abs
    • Abilities are expanded (meaning the definition of the ability is placed in the formula anywhere that ability appears).
      Macros are expanded, including nested macros up to 99 levels deep.
      Variables are substituted
      Roll queries are executed (the player making the roll is asked to provide a value for each query, and that value is substituted in where the roll query appears in the formula)
      All previous steps are repeated until there are no longer any unresolved abilities, macros, variables, or queries. This allows for nesting (e.g. putting an attribute in a macro).
      Inline rolls are executed, starting with the most deeply nested inline roll working upward. The overall result of the inline roll is substituted in place where it appeared in the formula.
      The remaining roll is executed: first, dice are rolled for any dice (e.g. "2d6" is rolled; including any special dice such as dropped or exploding), then the result of that roll is substituted into the formula. Next, floor() and ceil() functions are executed. Finally, the entire remaining formula is evaluated, including observing proper math order of operations (parentheses first, then multiplication/division, then addition/subtraction).

  • All Types Of Dice
    • Basic Roll of NdX
    • Fate/Fudge Roll NdF
    • Computed Dice Roll (N+Y)dX or Nd(X+Y)
  • All Roll Modifiers
    • Target Number / Successes (B,F) - CP
    • Failures (B,F) - fCP
    • Exploding Dice (B,F) !CP
    • Compounding Dice (B,F) !!CP
    • Penetrating Dice (B,F) !pCP
    • Dice Matching m and mt
    • Keep / Drop Dice (B,F) khN or klN or dhN dlN
    • Rerolling Dice (B,F) rCP
    • Sorting Dice (B,F) sa or sd
    • Order of Operations for Modifiers
      • Exploding, Compounding, Penetrating, Rerolls
        These are applied while the dice are still rolling. imagine that you roll some exploding 6d6 on your table and the instant one of them settles as a 6 another die is rolled
        Keep, Drop, Success, Failure, Sorting
        These are applied after all of the dice have "settled" and all of the result values are known.

  • Grouped Rolls
  • Grouped Roll Modifiers
    • Keep / Drop khN or klN or dhN or dlN
    • Target Number / Successes (B,F) CP
    • Failures (B,F) fCP

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions