diff --git a/module/actor.js b/module/actor.js index 63267ae2..25cdd2fb 100644 --- a/module/actor.js +++ b/module/actor.js @@ -106,31 +106,32 @@ export class RdDActor extends Actor { RdDUtility.computeCarac(actorData.data); this.computeEncombrementTotalEtMalusArmure(); this.computeEtatGeneral(); - await this.checkMonnaiePresence(); + // Sanity check + let newMonnaie = this.checkMonnaiePresence(); + if ( newMonnaie.length > 0 ) + await this.createOwnedItem( newMonnaie ); } /* -------------------------------------------- */ - async checkMonnaiePresence( ) { // Ajout opportuniste si les pièces n'existent pas. + checkMonnaiePresence( ) { // Ajout opportuniste si les pièces n'existent pas. + let newMonnaie = []; let piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1); if (!piece) { - let piece = RdDUtility.createMonnaie("Etain (1 denier)", 1, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp" ); - const updated = await this.createOwnedItem( piece ); + newMonnaie.push( RdDUtility.createMonnaie("Etain (1 denier)", 1, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp" ) ); } piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 10); if (!piece) { - let piece = RdDUtility.createMonnaie("Bronze (10 deniers)", 10, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_bronze_epees.webp"); - const updated = await this.createOwnedItem( piece ); + newMonnaie.push(RdDUtility.createMonnaie("Bronze (10 deniers)", 10, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_bronze_epees.webp") ); } piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 100); if (!piece) { - let piece = RdDUtility.createMonnaie("Argent (1 sol)", 100, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_argent_sol.webp"); - const updated = await this.createOwnedItem( piece ); + newMonnaie.push(RdDUtility.createMonnaie("Argent (1 sol)", 100, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_argent_sol.webp")); } piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1000); if (!piece) { - let piece = RdDUtility.createMonnaie("Or (10 sols)", 1000, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_or_sol.webp"); - const updated = await this.createOwnedItem( piece ); + newMonnaie.push(RdDUtility.createMonnaie("Or (10 sols)", 1000, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_or_sol.webp") ); } + return newMonnaie; } /* -------------------------------------------- */