diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 0e8aa32..4c99421 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -97,6 +97,7 @@ "difficulty_hidden_label": "Hide TN", "use_void_point_label": "Spend a", "void_point_tooltip": "Void point", + "skill_assistance_label": "Assistance", "roll_label": "Roll", "bt_add_macro": "Add a macro" }, diff --git a/system/lang/es-es.json b/system/lang/es-es.json index f59b409..22f92bc 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -97,6 +97,7 @@ "difficulty_hidden_label": "Ocultar NO", "use_void_point_label": "Gasta un", "void_point_tooltip": "Punto de vacío", + "skill_assistance_label": "Assistance", "roll_label": "Tirar", "bt_add_macro": "Añadir una macro" }, diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index cc9ca58..45cf9b1 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -97,6 +97,7 @@ "difficulty_hidden_label": "ND Caché", "use_void_point_label": "Dépenser un", "void_point_tooltip": "Point de Vide", + "skill_assistance_label": "Assistance", "roll_label": "Lancer", "bt_add_macro": "Ajouter une macro" }, diff --git a/system/scripts/combat.js b/system/scripts/combat.js index 730628d..9317cb5 100644 --- a/system/scripts/combat.js +++ b/system/scripts/combat.js @@ -104,12 +104,13 @@ export class CombatL5r5e extends Combat { ? messageOptions.difficultyHidden : cfg.difficultyHidden; roll.l5r5e.voidPointUsed = !!messageOptions.useVoidPoint; + roll.l5r5e.skillAssistance = messageOptions.skillAssistance; roll.roll(); rnkMessage = await roll.toMessage({ flavor }); } - // Ugly but work... i need the new messageId + // Ugly but work... i need the new message if (ids.length === 1) { combatant.actor.rnkMessage = rnkMessage; } diff --git a/system/scripts/dice/dice-picker-dialog.js b/system/scripts/dice/dice-picker-dialog.js index 3f527e6..126fc0e 100644 --- a/system/scripts/dice/dice-picker-dialog.js +++ b/system/scripts/dice/dice-picker-dialog.js @@ -30,6 +30,7 @@ export class DicePickerDialog extends FormApplication { defaultValue: 0, cat: "", name: "", + assistance: 0, }, difficulty: { value: 2, @@ -184,6 +185,7 @@ export class DicePickerDialog extends FormApplication { } this.object.skill = { + ...this.object.skill, id: skillId.toLowerCase().trim(), value: 0, cat: "", @@ -323,11 +325,27 @@ export class DicePickerDialog extends FormApplication { this.render(false); }); + // Skill assistance + html.find(".assistance").on("click", async (event) => { + event.preventDefault(); + event.stopPropagation(); + const assistanceAdd = $(event.currentTarget).data("value"); + if (this.object.skill.assistance > 0 || assistanceAdd > 0) { + this._quantityChange("skill", assistanceAdd); + } + this.object.skill.assistance = Math.max( + Math.min(parseInt(this.object.skill.assistance) + assistanceAdd, 9), + 0 + ); + this.render(false); + }); + // Click on the Default Skill Dice html.find("#skill_default_value").on("click", async (event) => { event.preventDefault(); event.stopPropagation(); this.object.skill.value = this.object.skill.defaultValue; + this.object.skill.assistance = 0; this.render(false); }); @@ -427,6 +445,7 @@ export class DicePickerDialog extends FormApplication { difficulty: this.object.difficulty.value, difficultyHidden: this.object.difficulty.hidden, useVoidPoint: this.object.useVoidPoint, + skillAssistance: this.object.skill.assistance, }, }, }); @@ -444,6 +463,7 @@ export class DicePickerDialog extends FormApplication { roll.l5r5e.difficulty = this.object.difficulty.value; roll.l5r5e.difficultyHidden = this.object.difficulty.hidden; roll.l5r5e.voidPointUsed = this.object.useVoidPoint; + roll.l5r5e.skillAssistance = this.object.skill.assistance; await roll.roll(); message = await roll.toMessage(); diff --git a/system/scripts/dice/roll-n-keep-dialog.js b/system/scripts/dice/roll-n-keep-dialog.js index d7c6989..2ba7c3f 100644 --- a/system/scripts/dice/roll-n-keep-dialog.js +++ b/system/scripts/dice/roll-n-keep-dialog.js @@ -659,7 +659,13 @@ export class RollnKeepDialog extends FormApplication { const card = button.parents(".l5r5e.item-display.dices-l5r"); const messageId = card.parents(".chat-message").data("message-id"); - new RollnKeepDialog(messageId).render(true); + // Already open ? close it + const app = Object.values(ui.windows).find((e) => e.id === `l5r5e-roll-n-keep-dialog-${messageId}`); + if (app) { + app.close(); + } else { + new RollnKeepDialog(messageId).render(true); + } // Re-enable the button button.attr("disabled", false); diff --git a/system/scripts/dice/roll.js b/system/scripts/dice/roll.js index 40a5a9d..fc0302b 100644 --- a/system/scripts/dice/roll.js +++ b/system/scripts/dice/roll.js @@ -18,6 +18,7 @@ export class RollL5r5e extends Roll { voidPointUsed: false, keepLimit: null, isInitiativeRoll: false, + skillAssistance: 0, dicesTypes: { std: false, l5r: false, @@ -106,10 +107,9 @@ export class RollL5r5e extends Roll { summary.totalBonus = Math.max(0, summary.totalSuccess - this.l5r5e.difficulty); if (!this.l5r5e.keepLimit) { - this.l5r5e.keepLimit = this.dice.reduce( - (acc, term) => (term instanceof game.l5r5e.RingDie ? acc + term.number : acc), - 0 - ); + this.l5r5e.keepLimit = + this.dice.reduce((acc, term) => (term instanceof game.l5r5e.RingDie ? acc + term.number : acc), 0) + + Math.max(0, this.l5r5e.skillAssistance); } } diff --git a/system/templates/dice/dice-picker-dialog.html b/system/templates/dice/dice-picker-dialog.html index 9467fa3..337d84a 100644 --- a/system/templates/dice/dice-picker-dialog.html +++ b/system/templates/dice/dice-picker-dialog.html @@ -164,6 +164,23 @@ {{/if}}
+