All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
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.

50 lines
1.6 KiB

1 year ago
  1. let toChat = (content) => {
  2. let chatData = {
  3. user: game.user.id,
  4. content,
  5. speaker: ChatMessage.getSpeaker(),
  6. };
  7. ChatMessage.create(chatData, {});
  8. };
  9. let applyChanges = false;
  10. new Dialog({
  11. title: `Take a Breather`,
  12. content: `
  13. <div>Rest for 10 minutes, spend a resolve point, and regain stamina?</div>
  14. `,
  15. buttons: {
  16. yes: {
  17. icon: "<i class='fas fa-check'></i>",
  18. label: `Take a Breather`,
  19. callback: () => (applyChanges = true),
  20. },
  21. no: {
  22. icon: "<i class='fas fa-times'></i>",
  23. label: `Cancel`,
  24. },
  25. },
  26. default: "yes",
  27. close: (html) => {
  28. if (applyChanges) {
  29. for (let token of canvas.tokens.controlled) {
  30. const { name } = token;
  31. console.log(token);
  32. const { resolve, sp } = token.actor.system.attributes;
  33. console.log(resolve, sp);
  34. if (resolve.value > 0) {
  35. let oldSP = sp.value;
  36. toChat(
  37. `${name} has ${sp.value}/${sp.max} SP and spends a resolve point, taking a 10 minute breather. Stamina Refreshed.`
  38. );
  39. token.actor.update({
  40. "data.attributes.sp.value": sp.max,
  41. "data.attributes.resolve.value": resolve.value - 1,
  42. });
  43. } else {
  44. toChat(`${name} is tired and needs to go to bed! No resolve points remaining.`);
  45. }
  46. }
  47. }
  48. },
  49. }).render(true);