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

[#2561] Display ASI values in config mode #2570

Merged
merged 1 commit into from
Nov 8, 2023
Merged
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
22 changes: 17 additions & 5 deletions module/documents/advancement/ability-score-improvement.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,34 @@ export default class AbilityScoreImprovementAdvancement extends Advancement {

/** @inheritdoc */
summaryForLevel(level, { configMode=false }={}) {
if ( (this.value.type === "feat") && this.value.feat ) {
const formatter = new Intl.NumberFormat(game.i18n.lang, { signDisplay: "always" });
if ( configMode ) {
const entries = Object.entries(this.configuration.fixed).map(([key, value]) => {
if ( !value ) return null;
const name = CONFIG.DND5E.abilities[key]?.label ?? key;
return `<span class="tag">${name} <strong>${formatter.format(value)}</strong></span>`;
});
if ( this.configuration.points ) entries.push(`<span class="tag">${
game.i18n.localize("DND5E.AdvancementAbilityScoreImprovementPoints")}: <strong>${
this.configuration.points}</strong></span>`
);
return entries.filterJoin("\n");
}

else if ( (this.value.type === "feat") && this.value.feat ) {
const id = Object.keys(this.value.feat)[0];
const feat = this.actor.items.get(id);
if ( feat ) return feat.toAnchor({classes: ["content-link"]}).outerHTML;
}

} else if ( (this.value.type === "asi") && this.value.assignments ) {

const formatter = new Intl.NumberFormat(game.i18n.lang, { signDisplay: "always" });
else if ( (this.value.type === "asi") && this.value.assignments ) {
return Object.entries(this.value.assignments).reduce((html, [key, value]) => {
const name = CONFIG.DND5E.abilities[key]?.label ?? key;
html += `<span class="tag">${name} <strong>${formatter.format(value)}</strong></span>\n`;
return html;
}, "");

}

return "";
}

Expand Down