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

Actor's sourcedItems not properly cleared during delete update from consumption of destroy-on-empty item #4764

Closed
roth-michael opened this issue Nov 23, 2024 · 1 comment
Assignees
Labels
bug Functionality which is not working as intended
Milestone

Comments

@roth-michael
Copy link
Contributor

Can easily be replicated with a healing potion; use its final charge/quantity on a sheet, then immediately try to drag another of the same item onto the sheet. Causes a problem with this function in module/applications/actor/sheet-mixin.mjs:

_onDropStackConsumables(itemData, { container=null }={}) {
  const droppedSourceId = itemData._stats?.compendiumSource ?? itemData.flags.core?.sourceId;
  if ( itemData.type !== "consumable" || !droppedSourceId ) return null;
  const similarItem = this.actor.sourcedItems.get(droppedSourceId, { legacy: false }) // <-- this.actor.sourcedItems still has the now-deleted item
    ?.filter(i => (i.system.container === container) && (i.name === itemData.name))?.first();
  if ( !similarItem ) return null;
  return similarItem.update({
    "system.quantity": similarItem.system.quantity + Math.max(itemData.system.quantity, 1)
  });
}

I wasn't able to determine why sourcedItems isn't properly updated, though.

@arbron arbron added the bug Functionality which is not working as intended label Nov 25, 2024
@arbron arbron added this to the D&D5E 4.1.2 milestone Nov 25, 2024
@arbron arbron self-assigned this Nov 25, 2024
@arbron
Copy link
Collaborator

arbron commented Nov 25, 2024

Looks like the system isn't checking whether an item is real or temporary, so when we revive items to roll damage they are being added to sourcedItems even though they don't actually exist on the actor.

@arbron arbron closed this as completed in b62d0b2 Nov 25, 2024
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

2 participants