forked from public/foundryvtt-reve-de-dragon
Fix: édition des compétences de créatures
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user