From a852cc094e3e1023d601658ebc39c86c1c45a67e Mon Sep 17 00:00:00 2001 From: Harm Manders Date: Sun, 2 Jul 2023 22:37:32 +0200 Subject: [PATCH 1/8] convert versatile to options --- src/views/UserContent/Npcs/EditNpc.vue | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/views/UserContent/Npcs/EditNpc.vue b/src/views/UserContent/Npcs/EditNpc.vue index 631ba120..421e7c13 100644 --- a/src/views/UserContent/Npcs/EditNpc.vue +++ b/src/views/UserContent/Npcs/EditNpc.vue @@ -168,6 +168,7 @@ export default { copy({ result }) { this.copy_dialog = false; this.npc = { ...result }; + this.npc = this.convertVersatileToOptions(this.npc); }, reset() { this.npc = {}; @@ -177,6 +178,19 @@ export default { this.npc_copy = JSON.parse(JSON.stringify(this.npc)); this.unsaved_changes = false; }, + convertVersatileToOptions(npc) { + if (npc.actions.length > 0) { + for (const action of npc.actions) { + if (action.versatile === true) { + action.options = [action.versatile_one, action.versatile_two]; + delete action.versatile; + delete action.versatile_one; + delete action.versatile_two; + } + } + } + return npc; + }, /** * Checks if a new NPC must be added, or an existing NPC must be saved. **/ From e3aaf6f997d0ee1f04d779b2254599b9968cef7d Mon Sep 17 00:00:00 2001 From: Harm Manders Date: Sun, 2 Jul 2023 22:37:48 +0200 Subject: [PATCH 2/8] fixed < issue in tempaltes --- src/components/combat/actions/Roll.vue | 24 +++++-------------- .../hk-action-rolls/hk-action-rolls-table.vue | 12 ++++------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/components/combat/actions/Roll.vue b/src/components/combat/actions/Roll.vue index 84aec002..048904cd 100644 --- a/src/components/combat/actions/Roll.vue +++ b/src/components/combat/actions/Roll.vue @@ -1,3 +1,4 @@ + - - {{ versatileOptions[0] || "Enter versatile option" }} - - + | {{ calcAverage( @@ -27,9 +24,10 @@ ) }} ({{ versatileRoll(data.row) }}) - - {{ versatileOptions[1] || "Enter versatile option" }} - + + + | ... + More then two Options @@ -177,27 +175,29 @@ export default { : parseInt(modifier); }, versatileRoll(roll) { - if (!roll.versatile_dice_count && !roll.versatile_dice_type && !roll.versatile_fixed_val) { + console.log(roll); + if (!roll.options) { return undefined; - } else { - let returnRoll = {}; + } - returnRoll.dice_count = roll.versatile_dice_count - ? roll.versatile_dice_count - : roll.dice_count; - returnRoll.dice_type = roll.versatile_dice_type ? roll.versatile_dice_type : roll.dice_type; - returnRoll.fixed_val = roll.versatile_fixed_val ? roll.versatile_fixed_val : roll.fixed_val; + const firstOption = Object.values(roll.options)[0]; - let fixed; - if (returnRoll.fixed_val !== undefined) { - fixed = - returnRoll.fixed_val < 0 - ? ` - ${Math.abs(returnRoll.fixed_val)}` - : ` + ${returnRoll.fixed_val}`; - } + let returnRoll = {}; - return `${returnRoll.dice_count}d${returnRoll.dice_type}${fixed}`; + returnRoll.dice_count = firstOption.dice_count ? firstOption.dice_count : roll.dice_count; + returnRoll.dice_type = firstOption.dice_type ? firstOption.dice_type : roll.dice_type; + returnRoll.fixed_val = + firstOption.fixed_val !== undefined ? firstOption.fixed_val : roll.fixed_val; + + let fixed; + if (returnRoll.fixed_val !== undefined) { + fixed = + returnRoll.fixed_val < 0 + ? ` - ${Math.abs(returnRoll.fixed_val)}` + : ` + ${returnRoll.fixed_val}`; } + + return `${returnRoll.dice_count}d${returnRoll.dice_type}${fixed}`; }, scalingDesc(tiers, scaling, level) { return spellScalingDescription(tiers, scaling, level); From dc4d5af540d39493f71922fac69163714ada1d29 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 7 Jul 2023 11:22:40 +0200 Subject: [PATCH 6/8] For update on options input --- src/components/npcs/Actions.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/npcs/Actions.vue b/src/components/npcs/Actions.vue index 3a4f0288..6390e769 100644 --- a/src/components/npcs/Actions.vue +++ b/src/components/npcs/Actions.vue @@ -349,6 +349,7 @@ class="mb-4" @new-value="addOption" @remove="removeOption($event, category, ability_index)" + @input="$forceUpdate()" >