Fix monnaie (again....)

This commit is contained in:
sladecraven 2021-01-07 11:42:36 +01:00
parent 19e96b0cac
commit ec86c81fc8

View File

@ -110,27 +110,31 @@ export class RdDActor extends Actor {
this.computeEncombrementTotalEtMalusArmure();
this.computeEtatGeneral();
// Sanity check
RdDActor.checkMonnaiePresence(actorData.items);
await this.checkMonnaiePresence(actorData.items);
}
/* -------------------------------------------- */
static checkMonnaiePresence( items ) { // Ajout opportuniste si les pièces n'existent pas.
async checkMonnaiePresence( items ) { // Ajout opportuniste si les pièces n'existent pas.
if( !items) return; // Sanity check during import
let piece = items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1);
let newMonnaie = [];
if (!piece) {
items.push( RdDUtility.createMonnaie("Etain (1 denier)", 1, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp" ) );
newMonnaie.push( RdDUtility.createMonnaie("Etain (1 denier)", 1, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp" ) );
}
piece = items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 10);
if (!piece) {
items.push(RdDUtility.createMonnaie("Bronze (10 deniers)", 10, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_bronze_epees.webp") );
newMonnaie.push(RdDUtility.createMonnaie("Bronze (10 deniers)", 10, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_bronze_epees.webp") );
}
piece = items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 100);
if (!piece) {
items.push(RdDUtility.createMonnaie("Argent (1 sol)", 100, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_argent_sol.webp"));
newMonnaie.push(RdDUtility.createMonnaie("Argent (1 sol)", 100, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_argent_sol.webp"));
}
piece = items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1000);
if (!piece) {
items.push(RdDUtility.createMonnaie("Or (10 sols)", 1000, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_or_sol.webp") );
newMonnaie.push(RdDUtility.createMonnaie("Or (10 sols)", 1000, "systems/foundryvtt-reve-de-dragon/icons/objets/piece_or_sol.webp") );
}
if ( newMonnaie.length > 0) {
await this.createOwnedItem( newMonnaie );
}
}