Skip to content

Commit

Permalink
fix: 🐛 Consumable roll not decreasing consumable
Browse files Browse the repository at this point in the history
Fixes #441
  • Loading branch information
aMediocreDad committed Jul 30, 2024
1 parent 47f52eb commit 9729eeb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-mangos-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"forbidden-lands": patch
---

Consumable roll not correctly decreasing consumables
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
"MONSTER.TYPE.MOUNT": "Mount",
"MOVEMENT": "Movement",
"NONE": "None",
"NOTIFY.CONSUMABLE_USED": "Consumable used!",
"NOTIFY.YOUR_ITEM_BROKE": "Your item broke!",
"NOTIFY.YOU_ARE_BROKEN": "You are broken!",
"OTHER": "OTHER",
Expand Down
2 changes: 1 addition & 1 deletion src/actor/character/character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class ForbiddenLandsCharacterSheet extends ForbiddenLandsActorSheet {
await roll.roll({ async: true });
const message = await roll.toMessage();
if (
Number(message.roll.result) <=
Number(message.rolls[0].result) <=
(game.settings.get("forbidden-lands", "autoDecreaseConsumable") || 0)
) {
FBLRollHandler.decreaseConsumable(message.id);
Expand Down
11 changes: 7 additions & 4 deletions src/components/roll-engine/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,15 +704,18 @@ export class FBLRollHandler extends FormApplication {
*/
static async decreaseConsumable(messageId) {
let {
data: { speaker },
roll: {
options: { consumable },
},
speaker,
rolls: [
{
options: { consumable },
},
],
} = game.messages.get(messageId);

speaker = this.getSpeaker(speaker);
if (!speaker)
return console.error("Could not decrease consumable: No actor found.");
ui.notifications.info("NOTIFY.CONSUMABLE_USED", { localize: true });

const currentValue = speaker?.consumables[consumable]?.value;
const newValue = Math.max(currentValue - 1, 0);
Expand Down

0 comments on commit 9729eeb

Please sign in to comment.