From 43607afc1249d6a41ed16b55837ec1d65f7217e7 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 27 Sep 2024 02:33:01 +0200 Subject: [PATCH] Correction du parser des bonus de case --- module/item-sort.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/module/item-sort.js b/module/item-sort.js index a8b038b4..be1a2f66 100644 --- a/module/item-sort.js +++ b/module/item-sort.js @@ -5,11 +5,11 @@ import { Misc } from "./misc.js"; import { TMRUtility } from "./tmr-utility.js"; const VOIES_DRACONIC = [ - { code: 'O', label: "Voie d'Oniros", short: 'Oniros'}, - { code: 'H', label: "Voie d'Hypnos" , short:'Hypnos' }, + { code: 'O', label: "Voie d'Oniros", short: 'Oniros' }, + { code: 'H', label: "Voie d'Hypnos", short: 'Hypnos' }, { code: 'N', label: "Voie de Narcos", short: 'Narcos' }, - { code: 'T', label: "Voie de Thanatos", short:'Thanatos' }, - { code: 'O/H/N/T', label: "Oniros/Hypnos/Narcos/Thanatos", short:'Oniros/Hypnos/Narcos/Thanatos' }, + { code: 'T', label: "Voie de Thanatos", short: 'Thanatos' }, + { code: 'O/H/N/T', label: "Oniros/Hypnos/Narcos/Thanatos", short: 'Oniros/Hypnos/Narcos/Thanatos' }, { code: 'O/H/N', label: "Oniros/Hypnos/Narcos" } ] @@ -65,9 +65,9 @@ export class RdDItemSort extends Item { /* -------------------------------------------- */ static buildBonusCaseList(bonuscase, newCase) { - const list = RdDItemSort._bonuscaseStringToList(bonuscase) + const list = RdDItemSort.bonuscaseStringToList(bonuscase) if (newCase) { - return list.concat({ case: "Nouvelle", bonus: 0 }); + list.push({ case: "Nouvelle", bonus: 0 }) } return list; } @@ -138,8 +138,11 @@ export class RdDItemSort extends Item { .sort(Misc.ascending()) .join(','); } - static _bonuscaseStringToList(bonuscase) { - return (bonuscase ?? '').split(',').map(it => { + static bonuscaseStringToList(bonuscase) { + if (bonuscase == undefined || bonuscase == '') { + return [] + } + return bonuscase.split(',').map(it => { const b = it.split(':'); return { case: b[0], bonus: b[1] }; });