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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user