Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

37 строки
844 B

  1. //Prebound Methods
  2. const mathRandom = Math.random.bind(Math);
  3. //Helpers
  4. const willBlock = ({ isAttack, tgtValues: { blockAttackChance, blockSpellChance } }) => {
  5. const blockChance = isAttack ? blockAttackChance : blockSpellChance;
  6. const roll = mathRandom() * 100;
  7. const result = roll < blockChance;
  8. return result;
  9. };
  10. const willDodge = ({ isAttack, tgtValues: { dodgeAttackChance, dodgeSpellChance } }) => {
  11. const dodgeChance = isAttack ? dodgeAttackChance : dodgeSpellChance;
  12. const roll = mathRandom() * 100;
  13. const result = roll < dodgeChance;
  14. return result;
  15. };
  16. //Method
  17. const avoid = (config, result) => {
  18. //Heals, among other things, should not be avoided
  19. if (config.noMitigate)
  20. return;
  21. result.blocked = willBlock(config);
  22. if (!result.blocked)
  23. result.dodged = willDodge(config);
  24. };
  25. //Exports
  26. module.exports = avoid;