Skip to content

Commit

Permalink
add RK skill name to the token hud - closes #58
Browse files Browse the repository at this point in the history
  • Loading branch information
reonZ committed Nov 24, 2024
1 parent 3a62174 commit a6a1efe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 16 additions & 2 deletions src/hud/shared/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getFlag,
getItemWithSourceId,
getSetting,
getSkillLabel,
localize,
} from "module-helpers";
import { IWR_DATA, StatsSpeed, StatsStatistic, getSpeeds, getStatistics } from "./base";
Expand Down Expand Up @@ -197,8 +198,22 @@ function getAdvancedStats(actor: ActorPF2e, hud: AdvancedHUD): StatsAdvanced {
?.map((speed) => `<i class="${speed.icon}"></i> <span>${speed.total}</span>`)
.join("");

const recall = (() => {
if (!isNPC) return;

const skills = actor.identificationDCs.skills.map((skill) => getSkillLabel(skill));
const label = game.i18n.localize("PF2E.RecallKnowledge.Label");
const tooltip = `${label} (${skills.join(", ")})`;

return {
tooltip,
dc: actor.identificationDCs.standard.dc,
};
})();

const data: StatsAdvanced = {
isNPC,
recall,
isArmy,
isHazard,
isVehicle,
Expand All @@ -209,7 +224,6 @@ function getAdvancedStats(actor: ActorPF2e, hud: AdvancedHUD): StatsAdvanced {
level: actor.level,
dying: isCharacter ? actor.attributes.dying : undefined,
wounded: isCharacter ? actor.attributes.wounded : undefined,
recall: isNPC ? actor.identificationDCs.standard.dc : undefined,
heroPoints: isCharacter ? actor.heroPoints : undefined,
statistics: getStatistics(actor),
otherSpeeds: otherSpeeds || undefined,
Expand Down Expand Up @@ -253,7 +267,7 @@ type StatsAdvanced = {
isCharacter: boolean;
isCombatant: boolean;
alliance?: ThreeStep;
recall: { dc: number; skills: string } | undefined;
recall: { dc: number; tooltip: string } | undefined;
dying: ValueAndMax | undefined;
wounded: ValueAndMax | undefined;
heroPoints: ValueAndMax | undefined;
Expand Down
9 changes: 2 additions & 7 deletions templates/token/hud.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@
{{> (@root.partial 'three-steps') step=alliance}}
{{/if}}
{{#if isNPC}}
<div data-section="recall-knowledge" data-tooltip="PF2E.RecallKnowledge.Label">
<div data-section="recall-knowledge" data-tooltip="{{recall.tooltip}}">
<i class="fa-solid fa-book"></i>
<span>{{recall}}</span>
<span>{{recall.dc}}</span>
</div>
{{!-- <a data-section="recall-knowledge" data-tooltip="PF2E.RecallKnowledge.Label"
data-action="recall-knowledge">
<i class="fa-solid fa-book"></i>
<span>{{recall}}</span>
</a> --}}
{{/if}}
</div>
{{/if}}
Expand Down

0 comments on commit a6a1efe

Please sign in to comment.