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

[#4861] Add combat activation types that display in turn message #4911

Open
wants to merge 2 commits into
base: 4.2.x
Choose a base branch
from

Conversation

arbron
Copy link
Collaborator

@arbron arbron commented Dec 20, 2024

Adds three new activation types in a new "Combat" section: "Start of Encounter", "Start of Turn", and "End of Turn". These activation types will display in the combat chat message with a "Use" button to be easily activated. They also have a tooltip to display the full item description on hover.

The turn chat message stores relative UUIDs of the activiations in its data model to avoid having to check all of the actor's items every time the chat message is rendered.

Closes #4861

@arbron arbron added this to the D&D5E 4.2.0 milestone Dec 20, 2024
@arbron arbron self-assigned this Dec 20, 2024
@arbron arbron linked an issue Dec 20, 2024 that may be closed by this pull request
Base automatically changed from turn-message to 4.2.x January 3, 2025 21:53
Adds three new activation types in a new "Combat" section:
"Start of Encounter", "Start of Turn", and "End of Turn". These
activation types will display in the combat chat message with a
"Use" button to be easily activated. They also have a tooltip
to display the full item description on hover.

The turn chat message stores relative UUIDs of the activiations
in its data model to avoid having to check all of the actor's
items every time the chat message is rendered.

Closes #4861
@arbron arbron requested a review from Fyorl January 3, 2025 21:56
Copy link
Contributor

@Fyorl Fyorl left a comment

Choose a reason for hiding this comment

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

In addition to my comments I noticed a couple of issues while testing:

  • It seems that turnStart is not fired for the first combatant of the combat when the combat is started. When I tested this I had only one combatant in the combat and they had rolled initiative. This might be a core v12 bug though.
  • Giving an activity one of the new combat activations puts them in the 'actions' section on the NPC features tab if 'group by origin' is enabled. Notably this is distinct from the 'action' section where all other actions are. I think there's still a todo for pluralising those section titles, but I think this issue is unrelated, and that combat activations should probably be sorted into the 'features' section (that we should also rename to 'traits' at some point).

Comment on lines +167 to +168
.map(i => i.system.activities?.filter(a => periods.includes(a.activation?.type)).map(a => a.relativeUUID) ?? [])
.flat();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.map(i => i.system.activities?.filter(a => periods.includes(a.activation?.type)).map(a => a.relativeUUID) ?? [])
.flat();
.flatMap(i => i.system.activities?.filter(a => periods.includes(a.activation?.type)).map(a => a.relativeUUID) ?? []);;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Collection doesn't have flatMap.

templates/chat/turn-card.hbs Outdated Show resolved Hide resolved
@arbron
Copy link
Collaborator Author

arbron commented Jan 4, 2025

  • It seems that turnStart is not fired for the first combatant of the combat when the combat is started. When I tested this I had only one combatant in the combat and they had rolled initiative. This might be a core v12 bug though.

Had to move it from nextTurn to _onStartTurn & _onEndTurn, which also fixes a potential issue with players pressing the "Next Turn" button and creating chat messages for combatants they don't own.

I've realized we might have a bug with updating the dynamic ring during combat, because it looks like it only updates for the user who presses the "Next Turn" button. Might need to move that code into the Combat5e._onUpdate to ensure it is called for all clients.

Reworked where `_recoverUses` is called for start & end of turn
to ensure that the `turnStart` period is called for the first
combatant and to ensure these methods are always called for a GM
user.

Also fixes a bug where the dynamic ring is only being refreshed
for the user who presses the combat control buttons.

Changes the activity usage button in chat to be a rollable link
on the title, rather than a separate button.

Adjusts NPC sheets so that combat activations will appear in the
passive section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Start of Combat" and "Start of Turn" activation types
3 participants