Moved dice.js and renamed it
This commit is contained in:
21
rpg-docs/lib/dice/roll.js
Normal file
21
rpg-docs/lib/dice/roll.js
Normal file
@@ -0,0 +1,21 @@
|
||||
roll = function(n, d){
|
||||
var result = [];
|
||||
if (!isNaN(n)){
|
||||
//if only provided 1 argument, it is the dice to roll
|
||||
if (d === undefined){
|
||||
d = n;
|
||||
n = 1;
|
||||
}
|
||||
//hard limit the number of dice rolled
|
||||
if (n > 500){
|
||||
console.warn(n + " > 500, cannot lift that many dice to roll them");
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < n; i++){
|
||||
var roll = Math.floor(Random.fraction() * d + 1);
|
||||
result.push(roll);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
Reference in New Issue
Block a user