tom-wolfe/dice-typescript

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

Opened this issue · 0 comments

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)?