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.
 
 
 

37 lines
820 B

  1. module.exports = {
  2. events: {
  3. onConsumeItem (effectResult, item, effect) {
  4. const cpnStats = this.stats;
  5. const stat = effect.rolls.stat;
  6. let amount = effect.rolls.amount;
  7. if (stat === 'hp') {
  8. if (cpnStats.values.hp >= cpnStats.values.hpMax) {
  9. effectResult.success = false;
  10. effectResult.errorMessage = 'You are already at full health.';
  11. return;
  12. }
  13. if (typeof(amount) === 'string' && amount.indexOf('%') > -1)
  14. amount = (cpnStats.values.hpMax / 100) * ~~amount.replace('%', '');
  15. cpnStats.getHp({
  16. heal: {
  17. amount,
  18. threatMult: 0
  19. },
  20. source: cpnStats.obj,
  21. target: cpnStats.obj
  22. });
  23. } else
  24. cpnStats.addStat(stat, amount);
  25. },
  26. onGetText (item, effect) {
  27. return `Restores ${effect.rolls.amount} ${effect.rolls.stat}`;
  28. }
  29. }
  30. };