Working the modules into Shared, untested

This commit is contained in:
2018-10-26 18:05:17 +11:00
parent 3745a1efc4
commit cabcc88685
13 changed files with 64 additions and 137 deletions

17
Shared/calc_random.js Normal file
View File

@@ -0,0 +1,17 @@
//initialize the exports
exports = module.exports = {};
//Random
//low - the inclusive lower bounds of the result
//high - the inclusive higher bounds of the result
exports.Random = function(low, high) {
//inclusive high
return Math.floor(Math.random() * (high - low + 1) + low);
}
//Gamble (depreciated)
//percentage - chance of winning as a percentage
exports.Gamble = function(percentage) {
// Random generation by %
return exports.Random(1, 100) <= percentage;
}