From 03400c7a32e81587b0d9a07ba1c81b6f591409f4 Mon Sep 17 00:00:00 2001 From: SilverDragon <923068035@qq.com> Date: Sat, 13 Apr 2024 17:06:35 +0800 Subject: [PATCH] Fix mismatch between multiple release methods for spells --- babele.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/babele.js b/babele.js index 3c6176a..31b4d20 100644 --- a/babele.js +++ b/babele.js @@ -1,25 +1,30 @@ class SpellActionsConverters { - static actions(value, translations) { + actions(value, translations) { if (!translations) { return value; } - + let data; value.forEach((type, index) => { - const data = translations[index]; - - value[index].effectNotes = data.effectNotes; - value[index].name = data.name; - value[index].spellArea = data.area; - value[index].spellEffect = data.effect; - + data = translations[index]; + if (index !== 0) { data = translations[0] } + if (value[index]?.name) { + value[index].name = data.name; + } + if (value[index]?.effectNotes) { + value[index].effectNotes = data.effectNotes; + } + if (value[index]?.spellArea) { + value[index].spellArea = data.area; + } + if (value[index]?.spellEffect) { + value[index].spellEffect = data.effect; + } if (value[index].duration?.value) { value[index].duration.value = data.duration; } - if (value[index].save?.description) { value[index].save.description = data.savingThrow; } - if (value[index].target?.value) { value[index].target.value = data.target; } @@ -28,6 +33,7 @@ class SpellActionsConverters { return value; } } +const spellActionsConverters = new SpellActionsConverters(); Hooks.on('init', () => { if (typeof Babele !== 'undefined') { @@ -38,7 +44,7 @@ Hooks.on('init', () => { }); Babele.get().registerConverters({ - 'actions': (value, translations) => SpellActionsConverters.actions(value, translations) + 'actions': (value, translations) => spellActionsConverters.actions(value, translations) }); } });