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

Display activity uses on spells tab for spells from Cast activity #4903

Open
wants to merge 1 commit into
base: 4.2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions module/applications/actor/sheet-v2-mixin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ export default function ActorSheetV2Mixin(Base) {
ctx.activities = item.system.activities
?.filter(a => !item.getFlag("dnd5e", "riders.activity")?.includes(a.id))
?.map(this._prepareActivity.bind(this));

// Linked Uses
const cachedFor = fromUuidSync(item.flags.dnd5e?.cachedFor, { relative: this.actor, strict: false });
if ( cachedFor ) ctx.linkedUses = cachedFor.consumption?.targets.find(t => t.type === "activityUses")
? cachedFor.uses : cachedFor.consumption?.targets.find(t => t.type === "itemUses")
? cachedFor.item.system.uses : null;
}

/* -------------------------------------------- */
Expand Down
7 changes: 6 additions & 1 deletion templates/actors/tabs/creature-spells.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,17 @@
</div>

{{!-- Spell Uses --}}
<div class="item-detail item-uses spell-uses {{#unless ctx.hasUses}}empty{{/unless}}">
<div class="item-detail item-uses spell-uses
{{#unless (or ctx.hasUses ctx.linkedUses)}}empty{{/unless}}">
{{#if ctx.hasUses}}
<input type="text" value="{{ item.system.uses.value }}" placeholder="0" data-dtype="Number"
data-name="system.uses.value" inputmode="numeric" pattern="[+=\-]?\d*">
<span class="separator">&sol;</span>
<span class="max">{{ item.system.uses.max }}</span>
{{else if ctx.linkedUses}}
<span class="value">{{ ctx.linkedUses.value }}</span>
<span class="separator">&sol;</span>
<span class="max">{{ ctx.linkedUses.max }}</span>
{{/if}}
</div>

Expand Down