Skip to content

Commit

Permalink
Add journal button to versatile performance skill rolls
Browse files Browse the repository at this point in the history
  • Loading branch information
dmrickey committed Dec 5, 2023
1 parent 14b3ff3 commit a613145
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/bonuses/versatile-performance.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ Hooks.on('renderActorSheetPF', (
function versatileRollSkill(wrapped, skillId, options) {
const vps = getDocDFlags(this, key);

const journalLookup = (/** @type {string} */ skl) => {
const link = this.getSkillInfo(skl.split('.subSkills')[0])?.journal || pf1.config.skillCompendiumEntries[skl.split('.subSkills')[0]] || '';
if (link) {
return `
<a data-tooltip="PF1.OpenAssociatedCompendiumEntry" data-action="open-compendium-entry" data-compendium-entry="${link}" data-document-type="JournalEntry">
<i class="fas fa-book"></i>
</a>
`;
}
return '';
};

for (let i = 0; i < vps.length; i++) {
const [baseId, ...substitutes] = `${vps[i]}`.split(';').map(x => x.trim());

Expand All @@ -136,7 +148,7 @@ function versatileRollSkill(wrapped, skillId, options) {
}
const updatedTitle = localize('PF1.SkillCheck', { skill: currentTitle });
const vpTitle = localize('versatilePerformance.title', { skill: baseName });
doc.updateSource({ content: doc.content.replace(baseName, ` ${updatedTitle}<br /> ${vpTitle}`) });
doc.updateSource({ content: doc.content.replace(baseName, `${journalLookup(skillId)} ${updatedTitle}<br />${journalLookup(baseId)} ${vpTitle}`) });
});
return wrapped(baseId, options);
}
Expand Down
3 changes: 3 additions & 0 deletions types/pf1/pf1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ declare global {
acp: boolean;
changeBonus: number;
cs: boolean;
/** compendium link returned for custom skills */
journal: string | undefined;
rank: number;
rt: boolean;

Expand Down Expand Up @@ -668,6 +670,7 @@ declare global {
"nonlethal": "Nonlethal"
},
savingThrows: SavingThrows;
skillCompendiumEntries: { [key: string]: string };
skills;
spellSchools: { [key: string]: string };
weaponGroups: { [key: string]: string };
Expand Down

0 comments on commit a613145

Please sign in to comment.