RedReign / FoundryVTT-BetterRolls5e

A module for modifying certain sheet functions on Foundry VTT Character sheets for D&D 5th Edition.
GNU General Public License v3.0
36 stars 67 forks source link

Math functions fail with Better Rolls unless wrapped in additional parentheses #270

Open ohmusama opened 3 years ago

ohmusama commented 3 years ago

Math functions fail in Better Rolls.

Tests in world modules enabled: Better Rolls v1.4.11 libWrapper v1.6.0.0

Repro Steps 1

Create Acolyte actor in empty scene (from SRD) Modify Feature Attack Club Change Attack Roll Bonus to floor(sqrt(10)) Roll Club

Result Exception:

Uncaught (in promise) SyntaxError: Unexpected number
    at new Function (<anonymous>)
    at Proxy.Roll.MATH_PROXY.safeEval (foundry.js:8368)
    at Roll._safeEval (foundry.js:8059)
    at Roll.evaluate (foundry.js:7674)
    at Roll.roll (foundry.js:7704)
    at Function.constructMultiRoll (fields.js:82)
    at Function.constructAttackRoll (fields.js:175)
    at async Function.constructModelsFromField (fields.js:437)
    at async CustomItemRoll._processField (custom-roll.js:922)
    at async CustomItemRoll.roll (custom-roll.js:664)

Repro Steps 2

Create Acolyte actor in empty scene (from SRD) Modify Feature Attack Club Change Attack Roll Bonus to floor(sqrt(@attributes.hp.value)) Roll Club

Result Exception:

foundry.js:7677 Uncaught (in promise) Error: The dice roll formula floor3 + 0 + 2 did not produce a numeric outcome.
    at Roll.evaluate (foundry.js:7677)
    at Roll.roll (foundry.js:7704)
    at Function.constructMultiRoll (fields.js:82)
    at Function.constructAttackRoll (fields.js:175)
    at async Function.constructModelsFromField (fields.js:437)
    at async CustomItemRoll._processField (custom-roll.js:922)
    at async CustomItemRoll.roll (custom-roll.js:664)
    at async CustomItemRoll.toMessage (custom-roll.js:770)

Repro Steps 3

Create Acolyte actor in empty scene (from SRD) Modify Feature Attack Club Change Attack Roll Bonus to sqrt(9) Roll Club

Result Exception:

foundry.js:7677 Uncaught (in promise) Error: The dice roll formula sqrt9 + 0 + 2 did not produce a numeric outcome.
    at Roll.evaluate (foundry.js:7677)
    at Roll.roll (foundry.js:7704)
    at Function.constructMultiRoll (fields.js:82)
    at Function.constructAttackRoll (fields.js:175)
    at async Function.constructModelsFromField (fields.js:437)
    at async CustomItemRoll._processField (custom-roll.js:922)
    at async CustomItemRoll.roll (custom-roll.js:664)
    at async CustomItemRoll.toMessage (custom-roll.js:770)

Expected

Math functions work in the base game here, and should work with better rolls too.

ohmusama commented 3 years ago

it does seem to work if you wrap everything in an extra set of parentheses like (floor(sqrt(@attributes.hp.value)))

CarlosFdez commented 3 years ago

Seems to be working fine in the beta branch for foundry 0.8. Probably a foundry issue (that might have had a workaround in d&d) that has been fixed recently.