Added "add a void point" checkbox, and some fixes

This commit is contained in:
Vlyan
2021-01-06 19:50:58 +01:00
parent 3eded04610
commit a9fd5ebd92
5 changed files with 44 additions and 16 deletions

View File

@@ -95,7 +95,8 @@
"dicepicker": { "dicepicker": {
"difficulty_title": "Difficulty", "difficulty_title": "Difficulty",
"difficulty_hidden_label": "Hide TN", "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", "roll_label": "Roll",
"bt_add_macro": "Add a macro" "bt_add_macro": "Add a macro"
}, },

View File

@@ -95,7 +95,8 @@
"dicepicker": { "dicepicker": {
"difficulty_title": "Difficulty", "difficulty_title": "Difficulty",
"difficulty_hidden_label": "Hide TN", "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", "roll_label": "Roll",
"bt_add_macro": "Add a macro" "bt_add_macro": "Add a macro"
}, },

View File

@@ -95,7 +95,8 @@
"dicepicker": { "dicepicker": {
"difficulty_title": "Difficulté", "difficulty_title": "Difficulté",
"difficulty_hidden_label": "ND Caché", "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", "roll_label": "Lancer",
"bt_add_macro": "Ajouter une macro" "bt_add_macro": "Ajouter une macro"
}, },

View File

@@ -26,6 +26,7 @@ export class DicePickerDialog extends FormApplication {
difficulty: { difficulty: {
value: 2, value: 2,
hidden: false, hidden: false,
add_void_point: true,
}, },
useVoidPoint: false, useVoidPoint: false,
}; };
@@ -136,6 +137,7 @@ export class DicePickerDialog extends FormApplication {
this._actor = actor; this._actor = actor;
if (this.object.ring.id === null) { if (this.object.ring.id === null) {
this.ringId = this._actor.data.data.stance; 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, actor: this._actor,
actorIsPc: !this._actor || this._actor.data?.type === "character", actorIsPc: !this._actor || this._actor.data?.type === "character",
canUseVoidPoint: 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, disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1,
}; };
} }
@@ -275,7 +277,7 @@ export class DicePickerDialog extends FormApplication {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
this.object.ring.id = event.target.dataset.ringid; 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); this.render(false);
}); });
@@ -310,15 +312,17 @@ export class DicePickerDialog extends FormApplication {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
this.object.difficulty.hidden = !this.object.difficulty.hidden; this.object.difficulty.hidden = !this.object.difficulty.hidden;
if ( this.object.difficulty.add_void_point = this.object.difficulty.hidden;
this.object.useVoidPoint && this._updateVoidPointUsage();
!this.object.difficulty.hidden && this.render(false);
!!this._actor && });
this._actor.data.data.void_points.value < 1
) { // Difficulty Add a void point
this.object.useVoidPoint = false; html.find("#diff_add_void_point").on("click", async (event) => {
this._quantityChange("ring", -1); event.preventDefault();
} event.stopPropagation();
this.object.difficulty.add_void_point = !this.object.difficulty.add_void_point;
this._updateVoidPointUsage();
this.render(false); 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); 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 * Create a macro on the first empty space in player's bar
* @private * @private

View File

@@ -79,7 +79,12 @@
{{!-- Third line--}} {{!-- Third line--}}
<tr> <tr>
<td> <td>
{{^if data.difficulty.hidden}} {{#if data.difficulty.hidden}}
<label>
<input type="checkbox" id="diff_add_void_point" name="difficulty.add_void_point" value="1" {{checked data.difficulty.add_void_point}}>
+1 <i class="i_void" title="{{localize 'l5r5e.dicepicker.void_point_tooltip'}}"></i>
</label>
{{else}}
<div id="difficulty_picker"> <div id="difficulty_picker">
<div class="third"> <div class="third">
<i class="quantity pointer-choice fa fa-minus-square" data-item="difficulty" data-value="-1"></i> <i class="quantity pointer-choice fa fa-minus-square" data-item="difficulty" data-value="-1"></i>
@@ -152,7 +157,7 @@
{{#if canUseVoidPoint}} {{#if canUseVoidPoint}}
<label> <label>
<input type="checkbox" id="use_void_point" name="useVoidPoint" value="1" {{checked data.useVoidPoint}}> <input type="checkbox" id="use_void_point" name="useVoidPoint" value="1" {{checked data.useVoidPoint}}>
{{localize 'l5r5e.dicepicker.use_void_point_label'}} {{localize 'l5r5e.dicepicker.use_void_point_label'}} <i class="i_void" title="{{localize 'l5r5e.dicepicker.void_point_tooltip'}}"></i>
</label> </label>
{{/if}} {{/if}}
</td> </td>