diff --git a/CHANGELOG.md b/CHANGELOG.md index 6647ed2..e398d7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,9 +18,12 @@ - Added a booster for loading compendium's core items (speed up 20Q) - Added confirm dialog on item's deletion (Hold "ctrl" on the click, if you want to bypass it) - Added "Sleep" & "Scene End" buttons in "GM ToolBox" (old "difficulty" box) -- Added an option to reverse the token's bar on fatigue (thanks to Jzrzmy), and colorize in red the strife bar if compromise +- Token's bar: + - The strife bar is now displayed in red if the actor is compromised + - Added an option, off by default, to reverse the fatigue's token bar (thanks to Jzrzmy). +- Added an option, on by default, to set the TN to 1 when the encounter type is selected (Intrigue, Duel, Skirmish or Mass battle) - Split Techniques & Items by category in actor sheet (pc & npc) for better readability -- Armor & Weapon added in the conflict tab now set the "eqquiped" props by default +- Armor & Weapon added in the conflict tab now set the "eqquiped" property by default ## 1.1.2 - One Compendium to bring them all - Added compendiums (Thanks to Stéfano Fara for the English version !) Partial for French as PoW and CR are not translated yet diff --git a/system/lang/en-en.json b/system/lang/en-en.json index a6de56f..9a3f64a 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -9,6 +9,10 @@ "RollNKeep": { "DeleteOldMessage": "RnK Delete previous chat message", "DeleteOldMessageHint": "Choose to keep or delete the previous message for a RnK series" + }, + "Initiative": { + "SetTn1OnTypeChange": "Set TN to 1 on encounter change", + "SetTn1OnTypeChangeHint": "Set the TN to 1 when the encounter type is selected (Intrigue, Duel, Skirmish or Mass battle)" } }, "ACTOR": { diff --git a/system/lang/es-es.json b/system/lang/es-es.json index f564e96..7b2492e 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -9,6 +9,10 @@ "RollNKeep": { "DeleteOldMessage": "RnK Delete previous chat message", "DeleteOldMessageHint": "Choose to keep or delete the previous message for a RnK series" + }, + "Initiative": { + "SetTn1OnTypeChange": "Set TN to 1 on encounter change", + "SetTn1OnTypeChangeHint": "Set the TN to 1 when the encounter type is selected (Intrigue, Duel, Skirmish or Mass battle)" } }, "ACTOR": { diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index f9b0376..ad957df 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -9,6 +9,10 @@ "RollNKeep": { "DeleteOldMessage": "RnK Supprime le précédent message du chat", "DeleteOldMessageHint": "Si coché, on supprime le message précédent pour la série de jets via le RnK" + }, + "Initiative": { + "SetTn1OnTypeChange": "ND 1 à la sélection du type de rencontre", + "SetTn1OnTypeChangeHint": "Met le ND à 1 lorsqu'on modifie le type de rencontre (Intrigue, Duel, Escarmouche ou Bataille rangée)" } }, "ACTOR": { diff --git a/system/scripts/dice/gm-tools-dialog.js b/system/scripts/dice/gm-tools-dialog.js index 57fa300..22120d7 100644 --- a/system/scripts/dice/gm-tools-dialog.js +++ b/system/scripts/dice/gm-tools-dialog.js @@ -34,6 +34,25 @@ export class GmToolsDialog extends FormApplication { */ constructor(options = {}) { super(options); + this._initialize(); + } + + /** + * Refresh data (used from socket) + */ + async refresh() { + if (!game.user.isGM) { + return; + } + this._initialize(); + this.render(false); + } + + /** + * Initialize the values + * @private + */ + _initialize() { this.object = { difficulty: game.settings.get("l5r5e", "initiative.difficulty.value"), difficultyHidden: game.settings.get("l5r5e", "initiative.difficulty.hidden"), @@ -148,15 +167,6 @@ export class GmToolsDialog extends FormApplication { * @override */ async _updateObject(event, formData) { - // Notify the change to other players if they already have opened the DicePicker - game.l5r5e.sockets.refreshAppId("l5r5e-dice-picker-dialog"); - - // If the current GM also have the DP open - const app = Object.values(ui.windows).find((e) => e.id === "l5r5e-dice-picker-dialog"); - if (app && typeof app.refresh === "function") { - app.refresh(); - } - this.render(false); } diff --git a/system/scripts/helpers.js b/system/scripts/helpers.js index 1f273bd..210f062 100644 --- a/system/scripts/helpers.js +++ b/system/scripts/helpers.js @@ -238,4 +238,16 @@ export class HelpersL5r5e { }, }).render(true); } + + /** + * Notify Applications using Difficulty settings that the values was changed + */ + static notifyDifficultyChange() { + ["l5r5e-dice-picker-dialog", "l5r5e-gm-tools-dialog"].forEach((appId) => { + const app = Object.values(ui.windows).find((e) => e.id === appId); + if (app && typeof app.refresh === "function") { + app.refresh(); + } + }); + } } diff --git a/system/scripts/hooks.js b/system/scripts/hooks.js index 7ac51d6..94af3dc 100644 --- a/system/scripts/hooks.js +++ b/system/scripts/hooks.js @@ -125,24 +125,17 @@ export default class HooksL5r5e { html.find(".prepared-control").on("click", (event) => { event.preventDefault(); event.stopPropagation(); - let preparedId = $(event.currentTarget).data("id"); + const preparedId = $(event.currentTarget).data("id"); if (!Object.hasOwnProperty.call(prepared, preparedId)) { return; } - let value = prepared[preparedId]; - switch (value) { - case "false": - value = "true"; - break; - case "true": - value = "null"; - break; - case "null": - value = "false"; - break; - } + const nextValue = { + false: "true", + true: "null", + null: "false", + }; game.settings - .set("l5r5e", `initiative.prepared.${preparedId}`, value) + .set("l5r5e", `initiative.prepared.${preparedId}`, nextValue[prepared[preparedId]]) .then(() => HooksL5r5e._gmCombatBar(app, html, data)); }); } diff --git a/system/scripts/settings.js b/system/scripts/settings.js index 4dfa2f6..b02e9d8 100644 --- a/system/scripts/settings.js +++ b/system/scripts/settings.js @@ -13,6 +13,21 @@ export const RegisterSettings = function () { default: true, type: Boolean, }); + game.settings.register("l5r5e", "initiative.setTn1OnTypeChange", { + name: "SETTINGS.Initiative.SetTn1OnTypeChange", + hint: "SETTINGS.Initiative.SetTn1OnTypeChangeHint", + scope: "world", + config: true, + type: Boolean, + default: true, + }); + game.settings.register("l5r5e", "token.reverseFatigueBar", { + name: "SETTINGS.ReverseFatigueBar", + scope: "world", + config: true, + type: Boolean, + default: false, + }); /* ------------------------------------ */ /* Update */ @@ -34,6 +49,7 @@ export const RegisterSettings = function () { config: false, type: Boolean, default: false, + onChange: () => game.l5r5e.HelpersL5r5e.notifyDifficultyChange(), }); game.settings.register("l5r5e", "initiative.difficulty.value", { name: "Initiative difficulty value", @@ -41,6 +57,7 @@ export const RegisterSettings = function () { config: false, type: Number, default: 2, + onChange: () => game.l5r5e.HelpersL5r5e.notifyDifficultyChange(), }); game.settings.register("l5r5e", "initiative.encounter", { name: "Initiative encounter type", @@ -48,6 +65,11 @@ export const RegisterSettings = function () { config: false, type: String, default: "skirmish", + onChange: () => { + if (game.settings.get("l5r5e", "initiative.setTn1OnTypeChange")) { + game.settings.set("l5r5e", "initiative.difficulty.value", 1); + } + }, }); game.settings.register("l5r5e", "initiative.prepared.character", { name: "Initiative PC prepared or not", @@ -70,15 +92,4 @@ export const RegisterSettings = function () { type: String, default: "null", }); - - /* ------------------------------------ */ - /* Token bars */ - /* ------------------------------------ */ - game.settings.register("l5r5e", "token.reverseFatigueBar", { - name: game.i18n.localize("SETTINGS.ReverseFatigueBar"), - scope: "world", - config: true, - type: Boolean, - default: false, - }); };