Fix: édition des compétences de créatures

This commit is contained in:
2023-01-07 19:46:27 +01:00
parent 912b1d3df3
commit 388629d36e
4 changed files with 35 additions and 29 deletions

View File

@ -847,17 +847,21 @@ export class RdDActor extends RdDBaseActor {
}
/* -------------------------------------------- */
async updateCreatureCompetence(idOrName, fieldName, compValue) {
async updateCreatureCompetence(idOrName, fieldName, value) {
let competence = this.getCompetence(idOrName);
if (competence) {
const update = { _id: competence.id }
if (fieldName == "niveau")
update['system.niveau'] = compValue;
else if (fieldName == "dommages")
update['system.dommages'] = compValue;
else
update['system.carac_value'] = compValue;
await this.updateEmbeddedDocuments('Item', [update]); // updates one EmbeddedEntity
function getPath(fieldName) {
switch (fieldName) {
case "niveau": return 'system.niveau';
case "dommages": return 'system.dommages';
case "carac_value": return 'system.carac_value';
}
return undefined
}
const path = getPath(fieldName);
if (path){
await this.updateEmbeddedDocuments('Item', [{ _id: competence.id, [path]: value }]); // updates one EmbeddedEntity
}
}
}