You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
575 B

  1. module.exports = {
  2. generate: function (item, blueprint) {
  3. if (!blueprint.effects)
  4. return;
  5. item.effects = blueprint.effects.map(function (e) {
  6. let rolls = e.rolls;
  7. let newRolls = {};
  8. for (let p in rolls) {
  9. let isInt = (p.indexOf('i_') === 0);
  10. let fieldName = p.replace('i_', '');
  11. let range = rolls[p];
  12. let value = range[0] + (Math.random() * (range[1] - range[0]));
  13. if (isInt)
  14. value = ~~value;
  15. newRolls[fieldName] = value;
  16. }
  17. return {
  18. type: e.type,
  19. properties: e.properties,
  20. rolls: newRolls
  21. };
  22. });
  23. }
  24. };