Renommage methode checkNull

This commit is contained in:
Vincent Vandemeulebrouck 2022-06-04 23:17:27 +02:00
parent 60b6da5cd3
commit bdead49d01
3 changed files with 32 additions and 47 deletions

View File

@ -22,13 +22,6 @@ export class RdDActorEntiteSheet extends ActorSheet {
}); });
} }
/* -------------------------------------------- */
_checkNull(items) {
if (items && items.length) {
return items;
}
return [];
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async getData() { async getData() {

View File

@ -25,14 +25,6 @@ export class RdDActorVehiculeSheet extends ActorSheet {
}); });
} }
/* -------------------------------------------- */
_checkNull(items) {
if (items && items.length) {
return items;
}
return [];
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async getData() { async getData() {
const objectData = Misc.data(this.object); const objectData = Misc.data(this.object);

View File

@ -326,8 +326,8 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static checkNull(items) { static arrayOrEmpty(items) {
if (items && items.length) { if (items?.length) {
return items; return items;
} }
return []; return [];
@ -360,44 +360,44 @@ export class RdDUtility {
RdDUtility.filterEquipementParType(formData); RdDUtility.filterEquipementParType(formData);
formData.sorts = this.checkNull(formData.itemsByType['sort']); formData.sorts = this.arrayOrEmpty(formData.itemsByType['sort']);
formData.signesdraconiques = this.checkNull(formData.itemsByType['signedraconique']); formData.signesdraconiques = this.arrayOrEmpty(formData.itemsByType['signedraconique']);
formData.queues = this.checkNull(formData.itemsByType['queue']); formData.queues = this.arrayOrEmpty(formData.itemsByType['queue']);
formData.souffles = this.checkNull(formData.itemsByType['souffle']); formData.souffles = this.arrayOrEmpty(formData.itemsByType['souffle']);
formData.ombres = this.checkNull(formData.itemsByType['ombre']); formData.ombres = this.arrayOrEmpty(formData.itemsByType['ombre']);
formData.tetes = this.checkNull(formData.itemsByType['tete']); formData.tetes = this.arrayOrEmpty(formData.itemsByType['tete']);
formData.taches = this.checkNull(formData.itemsByType['tache']); formData.taches = this.arrayOrEmpty(formData.itemsByType['tache']);
formData.meditations = this.checkNull(formData.itemsByType['meditation']); formData.meditations = this.arrayOrEmpty(formData.itemsByType['meditation']);
formData.chants = this.checkNull(formData.itemsByType['chant']); formData.chants = this.arrayOrEmpty(formData.itemsByType['chant']);
formData.danses = this.checkNull(formData.itemsByType['danse']); formData.danses = this.arrayOrEmpty(formData.itemsByType['danse']);
formData.musiques = this.checkNull(formData.itemsByType['musique']); formData.musiques = this.arrayOrEmpty(formData.itemsByType['musique']);
formData.oeuvres = this.checkNull(formData.itemsByType['oeuvre']); formData.oeuvres = this.arrayOrEmpty(formData.itemsByType['oeuvre']);
formData.jeux = this.checkNull(formData.itemsByType['jeu']); formData.jeux = this.arrayOrEmpty(formData.itemsByType['jeu']);
formData.recettescuisine = this.checkNull(formData.itemsByType['recettecuisine']); formData.recettescuisine = this.arrayOrEmpty(formData.itemsByType['recettecuisine']);
formData.recettesAlchimiques = this.checkNull(formData.itemsByType['recettealchimique']); formData.recettesAlchimiques = this.arrayOrEmpty(formData.itemsByType['recettealchimique']);
formData.maladies = this.checkNull(formData.itemsByType['maladie']); formData.maladies = this.arrayOrEmpty(formData.itemsByType['maladie']);
formData.poisons = this.checkNull(formData.itemsByType['poison']); formData.poisons = this.arrayOrEmpty(formData.itemsByType['poison']);
formData.possessions = this.checkNull(formData.itemsByType['possession']); formData.possessions = this.arrayOrEmpty(formData.itemsByType['possession']);
formData.maladiesPoisons = formData.maladies.concat(formData.poisons); formData.maladiesPoisons = formData.maladies.concat(formData.poisons);
formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []); formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []);
} }
static filterEquipementParType(formData) { 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.materiel = this.arrayOrEmpty(formData.itemsByType['objet']);
formData.armes = this.checkNull(formData.itemsByType['arme']); formData.armes = this.arrayOrEmpty(formData.itemsByType['arme']);
formData.armures = this.checkNull(formData.itemsByType['armure']); formData.armures = this.arrayOrEmpty(formData.itemsByType['armure']);
formData.munitions = this.checkNull(formData.itemsByType['munition']); formData.munitions = this.arrayOrEmpty(formData.itemsByType['munition']);
formData.livres = this.checkNull(formData.itemsByType['livre']); formData.livres = this.arrayOrEmpty(formData.itemsByType['livre']);
formData.potions = this.checkNull(formData.itemsByType['potion']); formData.potions = this.arrayOrEmpty(formData.itemsByType['potion']);
formData.ingredients = this.checkNull(formData.itemsByType['ingredient']); formData.ingredients = this.arrayOrEmpty(formData.itemsByType['ingredient']);
formData.herbes = this.checkNull(formData.itemsByType['herbe']); formData.herbes = this.arrayOrEmpty(formData.itemsByType['herbe']);
formData.monnaie = this.checkNull(formData.itemsByType['monnaie']); formData.monnaie = this.arrayOrEmpty(formData.itemsByType['monnaie']);
formData.monnaie.sort(Monnaie.triValeurDenier()); formData.monnaie.sort(Monnaie.triValeurDenier());
formData.nourritureboissons = this.checkNull(formData.itemsByType['nourritureboisson']); formData.nourritureboissons = this.arrayOrEmpty(formData.itemsByType['nourritureboisson']);
formData.gemmes = this.checkNull(formData.itemsByType['gemme']); formData.gemmes = this.arrayOrEmpty(formData.itemsByType['gemme']);
formData.objets = formData.conteneurs formData.objets = formData.conteneurs
.concat(formData.materiel) .concat(formData.materiel)