forked from GitHub-Mirrors/foundry-sw5e
Enable display of character sheet
This commit is contained in:
parent
db5c5f4810
commit
a597964bc4
5 changed files with 97 additions and 80 deletions
|
@ -252,12 +252,8 @@ export default class Item5e extends Item {
|
|||
// Item Actions
|
||||
if ( data.hasOwnProperty("actionType") ) {
|
||||
|
||||
// Saving throws for unowned items
|
||||
const save = data.save;
|
||||
if ( save?.ability && !this.isOwned ) {
|
||||
if ( save.scaling !== "flat" ) save.dc = null;
|
||||
labels.save = game.i18n.format("SW5E.SaveDC", {dc: save.dc || "", ability: C.abilities[save.ability]});
|
||||
}
|
||||
// Saving throws
|
||||
this.getSaveDC();
|
||||
|
||||
// Damage
|
||||
let dam = data.damage || {};
|
||||
|
@ -271,6 +267,30 @@ export default class Item5e extends Item {
|
|||
this.labels = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the derived spell DC for an item that requires a saving throw
|
||||
* @returns {number|null}
|
||||
*/
|
||||
getSaveDC() {
|
||||
if ( !this.hasSave ) return;
|
||||
const save = this.data.data?.save;
|
||||
|
||||
// Actor spell-DC based scaling
|
||||
if ( save.scaling === "spell" ) {
|
||||
save.dc = this.isOwned ? getProperty(this.actor.data, "data.attributes.spelldc") : null;
|
||||
}
|
||||
|
||||
// Ability-score based scaling
|
||||
else if ( save.scaling !== "flat" ) {
|
||||
save.dc = this.isOwned ? getProperty(this.actor.data, `data.abilities.${save.scaling}.dc`) : null;
|
||||
}
|
||||
|
||||
// Update labels
|
||||
const abl = CONFIG.DND5E.abilities[save.ability];
|
||||
this.labels.save = game.i18n.format("DND5E.SaveDC", {dc: save.dc || "", ability: abl});
|
||||
return save.dc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue