We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ccc263c commit 9aadcecCopy full SHA for 9aadcec
2 files changed
src/engine/script/handlers/NumberOps.ts
@@ -30,12 +30,12 @@ const NumberOps: CommandHandlers = {
30
},
31
32
[ScriptOpcode.RANDOM]: state => {
33
- const a = state.popInt();
+ const a = Math.max(0, state.popInt());
34
state.pushInt(JavaRandom.nextInt(a));
35
36
37
[ScriptOpcode.RANDOMINC]: state => {
38
39
state.pushInt(JavaRandom.nextInt(a + 1));
40
41
src/util/JavaRandom.ts
@@ -57,7 +57,7 @@ function next(bits: number) {
57
58
function checkIsPositiveInt(n: number, r = Number.MAX_SAFE_INTEGER) {
59
if (n < 0 || n > r) {
60
- throw RangeError();
+ throw RangeError('number must be > 0');
61
}
62
63
0 commit comments