diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js index eabaf828..ce0d51a2 100644 --- a/module/actor-entite-sheet.js +++ b/module/actor-entite-sheet.js @@ -22,13 +22,6 @@ export class RdDActorEntiteSheet extends ActorSheet { }); } - /* -------------------------------------------- */ - _checkNull(items) { - if (items && items.length) { - return items; - } - return []; - } /* -------------------------------------------- */ async getData() { diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js index 43b20810..e6cf1fbc 100644 --- a/module/actor-vehicule-sheet.js +++ b/module/actor-vehicule-sheet.js @@ -25,14 +25,6 @@ export class RdDActorVehiculeSheet extends ActorSheet { }); } - /* -------------------------------------------- */ - _checkNull(items) { - if (items && items.length) { - return items; - } - return []; - } - /* -------------------------------------------- */ async getData() { const objectData = Misc.data(this.object); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 1c43cdc8..786ad9b1 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -326,8 +326,8 @@ export class RdDUtility { } /* -------------------------------------------- */ - static checkNull(items) { - if (items && items.length) { + static arrayOrEmpty(items) { + if (items?.length) { return items; } return []; @@ -360,44 +360,44 @@ export class RdDUtility { RdDUtility.filterEquipementParType(formData); - formData.sorts = this.checkNull(formData.itemsByType['sort']); - formData.signesdraconiques = this.checkNull(formData.itemsByType['signedraconique']); - formData.queues = this.checkNull(formData.itemsByType['queue']); - formData.souffles = this.checkNull(formData.itemsByType['souffle']); - formData.ombres = this.checkNull(formData.itemsByType['ombre']); - formData.tetes = this.checkNull(formData.itemsByType['tete']); - formData.taches = this.checkNull(formData.itemsByType['tache']); - formData.meditations = this.checkNull(formData.itemsByType['meditation']); - formData.chants = this.checkNull(formData.itemsByType['chant']); - formData.danses = this.checkNull(formData.itemsByType['danse']); - formData.musiques = this.checkNull(formData.itemsByType['musique']); - formData.oeuvres = this.checkNull(formData.itemsByType['oeuvre']); - formData.jeux = this.checkNull(formData.itemsByType['jeu']); + formData.sorts = this.arrayOrEmpty(formData.itemsByType['sort']); + formData.signesdraconiques = this.arrayOrEmpty(formData.itemsByType['signedraconique']); + formData.queues = this.arrayOrEmpty(formData.itemsByType['queue']); + formData.souffles = this.arrayOrEmpty(formData.itemsByType['souffle']); + formData.ombres = this.arrayOrEmpty(formData.itemsByType['ombre']); + formData.tetes = this.arrayOrEmpty(formData.itemsByType['tete']); + formData.taches = this.arrayOrEmpty(formData.itemsByType['tache']); + formData.meditations = this.arrayOrEmpty(formData.itemsByType['meditation']); + formData.chants = this.arrayOrEmpty(formData.itemsByType['chant']); + formData.danses = this.arrayOrEmpty(formData.itemsByType['danse']); + formData.musiques = this.arrayOrEmpty(formData.itemsByType['musique']); + formData.oeuvres = this.arrayOrEmpty(formData.itemsByType['oeuvre']); + formData.jeux = this.arrayOrEmpty(formData.itemsByType['jeu']); - formData.recettescuisine = this.checkNull(formData.itemsByType['recettecuisine']); - formData.recettesAlchimiques = this.checkNull(formData.itemsByType['recettealchimique']); - formData.maladies = this.checkNull(formData.itemsByType['maladie']); - formData.poisons = this.checkNull(formData.itemsByType['poison']); - formData.possessions = this.checkNull(formData.itemsByType['possession']); + formData.recettescuisine = this.arrayOrEmpty(formData.itemsByType['recettecuisine']); + formData.recettesAlchimiques = this.arrayOrEmpty(formData.itemsByType['recettealchimique']); + formData.maladies = this.arrayOrEmpty(formData.itemsByType['maladie']); + formData.poisons = this.arrayOrEmpty(formData.itemsByType['poison']); + formData.possessions = this.arrayOrEmpty(formData.itemsByType['possession']); formData.maladiesPoisons = formData.maladies.concat(formData.poisons); formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []); } static filterEquipementParType(formData) { - formData.conteneurs = this.checkNull(formData.itemsByType['conteneur']); + formData.conteneurs = this.arrayOrEmpty(formData.itemsByType['conteneur']); - formData.materiel = this.checkNull(formData.itemsByType['objet']); - formData.armes = this.checkNull(formData.itemsByType['arme']); - formData.armures = this.checkNull(formData.itemsByType['armure']); - formData.munitions = this.checkNull(formData.itemsByType['munition']); - formData.livres = this.checkNull(formData.itemsByType['livre']); - formData.potions = this.checkNull(formData.itemsByType['potion']); - formData.ingredients = this.checkNull(formData.itemsByType['ingredient']); - formData.herbes = this.checkNull(formData.itemsByType['herbe']); - formData.monnaie = this.checkNull(formData.itemsByType['monnaie']); + formData.materiel = this.arrayOrEmpty(formData.itemsByType['objet']); + formData.armes = this.arrayOrEmpty(formData.itemsByType['arme']); + formData.armures = this.arrayOrEmpty(formData.itemsByType['armure']); + formData.munitions = this.arrayOrEmpty(formData.itemsByType['munition']); + formData.livres = this.arrayOrEmpty(formData.itemsByType['livre']); + formData.potions = this.arrayOrEmpty(formData.itemsByType['potion']); + formData.ingredients = this.arrayOrEmpty(formData.itemsByType['ingredient']); + formData.herbes = this.arrayOrEmpty(formData.itemsByType['herbe']); + formData.monnaie = this.arrayOrEmpty(formData.itemsByType['monnaie']); formData.monnaie.sort(Monnaie.triValeurDenier()); - formData.nourritureboissons = this.checkNull(formData.itemsByType['nourritureboisson']); - formData.gemmes = this.checkNull(formData.itemsByType['gemme']); + formData.nourritureboissons = this.arrayOrEmpty(formData.itemsByType['nourritureboisson']); + formData.gemmes = this.arrayOrEmpty(formData.itemsByType['gemme']); formData.objets = formData.conteneurs .concat(formData.materiel)