DiceDangerous.ts 852 B

1234567891011121314151617181920
  1. /// <reference path="Dice.ts" />
  2. class DiceDangerous extends Dice {
  3. protected range : Array<number> = [-2, -1, 0, 0, 0, 0, 1, 1, 1, 1];
  4. public minResult = -2;
  5. public static testAgainstRoll (player : TestingOptions, enemy : TestingOptions) : number {
  6. let playerDice = new DiceDangerous(player.name);
  7. let playerResult = playerDice.roll(player.value);
  8. let enemyDice = new DiceDangerous(enemy.name);
  9. let enemyResult = enemyDice.roll(enemy.value);
  10. return playerResult.reduce(Dice.sum) - enemyResult.reduce(Dice.sum);
  11. }
  12. public static testAgainstDifficulty (player : TestingOptions, difficulty : number) : number {
  13. let playerDice = new DiceDangerous(player.name);
  14. let playerResult = playerDice.roll(player.value);
  15. return playerResult.reduce(Dice.sum) - difficulty;
  16. }
  17. }