diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 0a4d9abd..6c7314f0 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -417,6 +417,11 @@ export class RdDActorSheet extends ActorSheet { let compName = event.currentTarget.attributes.compname.value; this.actor.updateCompetenceXP(compName, parseInt(event.target.value)); }); + // On competence xp change + html.find('.competence-xp-sort').change((event) => { + let compName = event.currentTarget.attributes.compname.value; + this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value)); + }); // On competence archetype change html.find('.competence-archetype').change((event) => { let compName = event.currentTarget.attributes.compname.value; diff --git a/module/actor.js b/module/actor.js index 5aa8950f..70102d76 100644 --- a/module/actor.js +++ b/module/actor.js @@ -704,6 +704,17 @@ export class RdDActor extends Actor { } } + /* -------------------------------------------- */ + async updateCompetenceXPSort(compName, compValue) { + let comp = this.getCompetence(compName); + if (comp) { + const update = { _id: comp._id, 'data.xp_sort': compValue }; + const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity + } else { + console.log("Competence not found", compName); + } + } + /* -------------------------------------------- */ async updateCompetenceArchetype(compName, compValue) { let comp = this.getCompetence(compName);