polserver/testsuite/escript/utilmod/randomdiceroll.src
Kevin Eady 1ce1a16f5d
Add allow_negatives to module function util::RandomDiceRoll (#748)
* implementation

* tests

* docs, core-changes

* address review comments
- no need for negative check with clamping
2025-01-21 15:33:22 +01:00

6 lines
225 B
Text

use util;
print( RandomDiceRoll( "1d1" ) == 1 );
print( RandomDiceRoll( "1d1 - 10" ) == 0 );
print( RandomDiceRoll( "1d1 - 10", 1 ) == -9 ); // allow_negatives
print( RandomDiceRoll( "1d1 + 0xffff" ) == 0xffff ); // clamp