Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a consumable item with a Negative Consumption value fails if the consumed resource is zero. #2479

Closed
FrankIsAtank opened this issue Sep 19, 2023 · 3 comments
Labels
bug Functionality which is not working as intended
Milestone

Comments

@FrankIsAtank
Copy link

FoundryVTT V 11 Stable 306
DnD5e 2.3.1

To reproduce :

  1. Create a player character actor.
  2. Add a Consumable item to the actor.
  3. Give the new item these properties :
  • Activation Cost : Action
  • Resource Consumption -1 'resources.primary.value' Attribute
  1. Return to the character sheet and try to consume the new item.

Observed behaviour :
The item fails to be consumed, presumably because it checks that the consumed resource is available.
A warning notification appears with "New Consumable has run out of its designated Attribute!".

Expected behaviour :
With a negative cost, the intent is for consuming the item to increase an attribute, such as adding to a resource counter. Doing so when that attribute is zero should not fail.

@Fyorl Fyorl added the bug Functionality which is not working as intended label Oct 19, 2023
@Fyorl Fyorl added this to the D&D5E 2.4.0 milestone Oct 19, 2023
@Hoppyhob
Copy link
Contributor

I wasn't able to recreate this with:
FoundryVTT V 11 Stable 308
DnD5e 2.3.1 or the 2.4.x branch

It appears from the code we warn with this message(ConsumeWarningNoQuantity) here (in item.mjs):

let remaining = quantity - amount;
    if ( remaining < 0 ) {
      ui.notifications.warn(game.i18n.format("DND5E.ConsumeWarningNoQuantity", {name: this.name, type: typeLabel}));
      return false;
    }

Which with a quantity of zero (gotten from resources.primary.value or defaulted to 0 if null) would be working as expected 0 - -1 = 1 which is greater than zero. (This should only warn if the resource value is -2 or lower)

@krbz999
Copy link
Contributor

krbz999 commented Oct 22, 2023

Which with a quantity of zero (gotten from resources.primary.value or defaulted to 0 if null) would be working as expected 0 - -1 = 1 which is greater than zero. (This should only warn if the resource value is -2 or lower)

I suspect it is related to #2165.

resource = foundry.utils.getProperty(this.actor.system, consume.target) becomes undefined, and then fails here:

    // Verify that a consumed resource is available
    if ( resource === undefined ) {
      ui.notifications.warn(game.i18n.format("DND5E.ConsumeWarningNoSource", {name: this.name, type: typeLabel}));
      return false;
    }

@krbz999
Copy link
Contributor

krbz999 commented Oct 22, 2023

OK, maybe it's not so weird that these (value and max) get deleted given that we delete them.

https://github.com/foundryvtt/dnd5e/blob/master/module/applications/actor/character-sheet.mjs#L30

krbz999 pushed a commit to krbz999/dnd5e that referenced this issue Oct 22, 2023
Fyorl pushed a commit that referenced this issue Oct 26, 2023
Co-authored-by: Zhell <zhellqol@gmail.com>
@Fyorl Fyorl closed this as completed Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality which is not working as intended
Projects
None yet
Development

No branches or pull requests

4 participants