Tests.ts 363 B

123456789101112
  1. module Tests {
  2. export var MIN_DICE = 0; // Dices can be < 0
  3. export var MAX_DICE = 3; // Dices can go real high
  4. export function rollDice () {
  5. return Math.floor(Math.random() * (MAX_DICE - MIN_DICE)) + 1 + MIN_DICE;
  6. }
  7. export function test (attr : number, difficulty : number) {
  8. return (attr + rollDice()) >= difficulty;
  9. }
  10. }