Add an option to set the TN to 1 when the encounter type is selected (Intrigue, Duel, Skirmish or Mass battle)

This commit is contained in:
Vlyan
2021-02-13 16:14:06 +01:00
parent cb0696f662
commit 95d031c7a8
8 changed files with 77 additions and 36 deletions

View File

@@ -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

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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);
}

View File

@@ -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();
}
});
}
}

View File

@@ -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));
});
}

View File

@@ -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,
});
};