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

[#881] Add spell level and item id to message flags when a spell is cast #1916

Merged
merged 3 commits into from
Dec 2, 2022
Merged

[#881] Add spell level and item id to message flags when a spell is cast #1916

merged 3 commits into from
Dec 2, 2022

Conversation

krbz999
Copy link
Contributor

@krbz999 krbz999 commented Nov 1, 2022

This is a one-liner to add a spell's level, as well as its item id, as flags.dnd5e.use.spellLevel: <Number>, and hopefully resolve #881.

I have put this in a separate PR to get some feedback on what the best flag would be; attack rolls use flags.dnd5e.roll.type: "attack" and damage rolls use flags.dnd5e.roll.type: "damage", and this is not entirely in line with that, but using flags.dnd5e.roll.type: "use" didn't seem correct either.

@@ -783,6 +783,7 @@ export default class Item5e extends Item {
item.prepareFinalAttributes();
}
}
if ( isSpell ) foundry.utils.setProperty(options.flags, "dnd5e.use", {spellLevel: item.system.level, itemId: this.id});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, is the original item ID not already attached to the chat card?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On item.use() there are no system flags at all. The item id and the spell level have always been present in the dataset, however. But as the issue says, this makes it easier.

@arbron
Copy link
Collaborator

arbron commented Nov 7, 2022

I'm wondering if it would just be simpler to put these at the top level, so flags.dnd5e.spellLevel and flags.dnd5e.itemId. Or perhaps something like flags.dnd5e.item.level & flags.dnd5e.item.id.

Also, it would probably be better to store the item's UUID rather than the ID otherwise it would be difficult to retrieve the original item. And the ID should be stored for all items rather than just spells.

@krbz999
Copy link
Contributor Author

krbz999 commented Nov 7, 2022

I had the same thought about putting it at the top level. Something like flags.dnd5e.use: {type: item.type, itemId: item.id} and spellLevel when it is a spell.

I chose the item id because that is what is stored on attack rolls and damage rolls. Should those be changed?

- spellLevel still only on spell uses.
@Fyorl
Copy link
Contributor

Fyorl commented Dec 2, 2022

@krbz999

I chose the item id because that is what is stored on attack rolls and damage rolls. Should those be changed?

Perhaps, in order to avoid breakage, we can include both for now, and retire itemId later? Could you update attack and damage rolls to include itemUuid as well?

@krbz999
Copy link
Contributor Author

krbz999 commented Dec 2, 2022

@krbz999

I chose the item id because that is what is stored on attack rolls and damage rolls. Should those be changed?

Perhaps, in order to avoid breakage, we can include both for now, and retire itemId later? Could you update attack and damage rolls to include itemUuid as well?

I realise it would veer out of scope of the PR slightly, but I did so and added itemUuid to all other item roll types since those used itemId too. So in total, tool checks, other formula, attack, damage, and use.

@Fyorl Fyorl merged commit 64b30e4 into foundryvtt:2.1.x Dec 2, 2022
@krbz999 krbz999 deleted the spell-level-message-flag branch December 2, 2022 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants