Fix js error when Advancement is not in a actor
This commit is contained in:
@@ -95,12 +95,22 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
* @private
|
||||
*/
|
||||
async _updateChoice(oldChoice, newChoice) {
|
||||
let skillCatId = null;
|
||||
const actor = duplicate(this.actor.data.data);
|
||||
let xp_used = this.object.data.data.xp_used;
|
||||
let name = this.object.data.name;
|
||||
let img = this.object.data.img;
|
||||
|
||||
// Modify image to reflect choice
|
||||
if (newChoice.ring) {
|
||||
img = `systems/l5r5e/assets/icons/rings/${newChoice.ring}.svg`;
|
||||
} else if (newChoice.skill) {
|
||||
img = `systems/l5r5e/assets/dices/default/skill_blank.svg`;
|
||||
}
|
||||
|
||||
// Object embed in actor ?
|
||||
if (this.actor) {
|
||||
const actor = duplicate(this.actor.data.data);
|
||||
let skillCatId = null;
|
||||
|
||||
// Old choices
|
||||
if (oldChoice.ring) {
|
||||
actor.rings[oldChoice.ring] = Math.max(1, actor.rings[oldChoice.ring] - 1);
|
||||
@@ -117,7 +127,6 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
name =
|
||||
game.i18n.localize(`l5r5e.rings.${newChoice.ring}`) +
|
||||
` +1 (${actor.rings[newChoice.ring] - 1} -> ${actor.rings[newChoice.ring]})`;
|
||||
img = `systems/l5r5e/assets/icons/rings/${newChoice.ring}.svg`;
|
||||
}
|
||||
if (newChoice.skill) {
|
||||
skillCatId = CONFIG.l5r5e.skills.get(newChoice.skill);
|
||||
@@ -128,13 +137,13 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
` +1 (${actor.skills[skillCatId][newChoice.skill] - 1} -> ${
|
||||
actor.skills[skillCatId][newChoice.skill]
|
||||
})`;
|
||||
img = `systems/l5r5e/assets/dices/default/skill_blank.svg`;
|
||||
}
|
||||
|
||||
// Update Actor
|
||||
await this.actor.update({
|
||||
data: diffObject(this.actor.data.data, actor),
|
||||
});
|
||||
}
|
||||
|
||||
// Update object
|
||||
await this.object.update({
|
||||
|
||||
Reference in New Issue
Block a user