diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 795f7fe..2edaf1a 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -95,7 +95,8 @@ "dicepicker": { "difficulty_title": "Difficulty", "difficulty_hidden_label": "Hide TN", - "use_void_point_label": "Spend a Void point", + "use_void_point_label": "Spend a", + "void_point_tooltip": "Void point", "roll_label": "Roll", "bt_add_macro": "Add a macro" }, diff --git a/system/lang/es-es.json b/system/lang/es-es.json index 5d2b01e..580fbaa 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -95,7 +95,8 @@ "dicepicker": { "difficulty_title": "Difficulty", "difficulty_hidden_label": "Hide TN", - "use_void_point_label": "Spend a Void point", + "use_void_point_label": "Spend a", + "void_point_tooltip": "Void point", "roll_label": "Roll", "bt_add_macro": "Add a macro" }, diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index 8befc6b..da54b6c 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -95,7 +95,8 @@ "dicepicker": { "difficulty_title": "Difficulté", "difficulty_hidden_label": "ND Caché", - "use_void_point_label": "Dépenser un point de Vide", + "use_void_point_label": "Dépenser un", + "void_point_tooltip": "Point de Vide", "roll_label": "Lancer", "bt_add_macro": "Ajouter une macro" }, diff --git a/system/scripts/dice/dice-picker-dialog.js b/system/scripts/dice/dice-picker-dialog.js index 93cbde6..75ffb74 100644 --- a/system/scripts/dice/dice-picker-dialog.js +++ b/system/scripts/dice/dice-picker-dialog.js @@ -26,6 +26,7 @@ export class DicePickerDialog extends FormApplication { difficulty: { value: 2, hidden: false, + add_void_point: true, }, useVoidPoint: false, }; @@ -136,6 +137,7 @@ export class DicePickerDialog extends FormApplication { this._actor = actor; if (this.object.ring.id === null) { this.ringId = this._actor.data.data.stance; + this.object.ring.value = this._actor.data.data.rings[this.object.ring.id]; } } @@ -240,7 +242,7 @@ export class DicePickerDialog extends FormApplication { actor: this._actor, actorIsPc: !this._actor || this._actor.data?.type === "character", canUseVoidPoint: - this.object.difficulty.hidden || !this._actor || this._actor.data.data.void_points.value > 0, + this.object.difficulty.add_void_point || !this._actor || this._actor.data.data.void_points.value > 0, disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1, }; } @@ -275,7 +277,7 @@ export class DicePickerDialog extends FormApplication { event.preventDefault(); event.stopPropagation(); this.object.ring.id = event.target.dataset.ringid; - this.object.ring.value = event.target.value; + this.object.ring.value = parseInt(event.target.value) + (this.object.useVoidPoint ? 1 : 0); this.render(false); }); @@ -310,15 +312,17 @@ export class DicePickerDialog extends FormApplication { event.preventDefault(); event.stopPropagation(); this.object.difficulty.hidden = !this.object.difficulty.hidden; - if ( - this.object.useVoidPoint && - !this.object.difficulty.hidden && - !!this._actor && - this._actor.data.data.void_points.value < 1 - ) { - this.object.useVoidPoint = false; - this._quantityChange("ring", -1); - } + this.object.difficulty.add_void_point = this.object.difficulty.hidden; + this._updateVoidPointUsage(); + this.render(false); + }); + + // Difficulty Add a void point + html.find("#diff_add_void_point").on("click", async (event) => { + event.preventDefault(); + event.stopPropagation(); + this.object.difficulty.add_void_point = !this.object.difficulty.add_void_point; + this._updateVoidPointUsage(); this.render(false); }); } @@ -390,6 +394,22 @@ export class DicePickerDialog extends FormApplication { this.object[element].value = Math.max(Math.min(parseInt(this.object[element].value) + add, 9), 0); } + /** + * Remove the use of void point if actor don't have any and use of vp is un checked + * @private + */ + _updateVoidPointUsage() { + if ( + this.object.useVoidPoint && + !this.object.difficulty.add_void_point && + !!this._actor && + this._actor.data.data.void_points.value < 1 + ) { + this.object.useVoidPoint = false; + this._quantityChange("ring", -1); + } + } + /** * Create a macro on the first empty space in player's bar * @private diff --git a/system/templates/dice/dice-picker-dialog.html b/system/templates/dice/dice-picker-dialog.html index ee897e3..ecf2e59 100644 --- a/system/templates/dice/dice-picker-dialog.html +++ b/system/templates/dice/dice-picker-dialog.html @@ -79,7 +79,12 @@ {{!-- Third line--}} - {{^if data.difficulty.hidden}} + {{#if data.difficulty.hidden}} + + {{else}}
@@ -152,7 +157,7 @@ {{#if canUseVoidPoint}} {{/if}}