v12 fixes
- Removal of async - CHAT_MESSAGE_TYPES to CHAT_MESSAGE_STYLES : roll removed - Math.clamped to Math.clamp - fixed debounce scope
This commit is contained in:
@@ -79,14 +79,14 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
* @return {L5rBaseDie} The evaluated RollTerm
|
* @return {L5rBaseDie} The evaluated RollTerm
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
async evaluate({ minimize = false, maximize = false, async = true } = {}) {
|
async evaluate({ minimize = false, maximize = false } = {}) {
|
||||||
if (this._evaluated) {
|
if (this._evaluated) {
|
||||||
throw new Error(`This ${this.constructor.name} has already been evaluated and is immutable`);
|
throw new Error(`This ${this.constructor.name} has already been evaluated and is immutable`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Roll the initial number of dice
|
// Roll the initial number of dice
|
||||||
for (let n = 1; n <= this.number; n++) {
|
for (let n = 1; n <= this.number; n++) {
|
||||||
await this.roll({ minimize, maximize, async });
|
await this.roll({ minimize, maximize });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply modifiers
|
// Apply modifiers
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
get isOwner() {
|
get isOwner() {
|
||||||
return this._message?.isAuthor || this.messageRoll.l5r5e.actor?.isOwner || this._message?.isOwner || false;
|
return this._message?.isAuthor || this.messageRoll?.l5r5e.actor?.isOwner || this._message?.isOwner || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class RollL5r5e extends Roll {
|
|||||||
* Execute the Roll, replacing dice and evaluating the total result
|
* Execute the Roll, replacing dice and evaluating the total result
|
||||||
* @override
|
* @override
|
||||||
**/
|
**/
|
||||||
async evaluate({ minimize = false, maximize = false, async = true } = {}) {
|
async evaluate({ minimize = false, maximize = false } = {}) {
|
||||||
if (this._evaluated) {
|
if (this._evaluated) {
|
||||||
throw new Error("This Roll object has already been rolled.");
|
throw new Error("This Roll object has already been rolled.");
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ export class RollL5r5e extends Roll {
|
|||||||
this._total = 0;
|
this._total = 0;
|
||||||
|
|
||||||
// Roll
|
// Roll
|
||||||
await super.evaluate({ minimize, maximize, async });
|
await super.evaluate({ minimize, maximize });
|
||||||
this._evaluated = true;
|
this._evaluated = true;
|
||||||
|
|
||||||
// Save initial formula
|
// Save initial formula
|
||||||
@@ -132,7 +132,7 @@ export class RollL5r5e extends Roll {
|
|||||||
|
|
||||||
// Store final outputs
|
// Store final outputs
|
||||||
this.l5r5e.dicesTypes.std = this.dice.some(
|
this.l5r5e.dicesTypes.std = this.dice.some(
|
||||||
(term) => term instanceof DiceTerm && !(term instanceof game.l5r5e.L5rBaseDie)
|
(term) => term instanceof foundry.dice.terms.DiceTerm && !(term instanceof game.l5r5e.L5rBaseDie)
|
||||||
); // ignore math symbols
|
); // ignore math symbols
|
||||||
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof game.l5r5e.L5rBaseDie);
|
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof game.l5r5e.L5rBaseDie);
|
||||||
summary.totalBonus = Math.max(0, summary.totalSuccess - this.l5r5e.difficulty);
|
summary.totalBonus = Math.max(0, summary.totalSuccess - this.l5r5e.difficulty);
|
||||||
@@ -346,7 +346,6 @@ export class RollL5r5e extends Roll {
|
|||||||
messageData = foundry.utils.mergeObject(
|
messageData = foundry.utils.mergeObject(
|
||||||
{
|
{
|
||||||
user: game.user.id,
|
user: game.user.id,
|
||||||
type: CONST.CHAT_MESSAGE_TYPES.ROLL,
|
|
||||||
content,
|
content,
|
||||||
sound: CONFIG.sounds.dice,
|
sound: CONFIG.sounds.dice,
|
||||||
speaker: {
|
speaker: {
|
||||||
|
|||||||
@@ -705,29 +705,27 @@ export class HelpersL5r5e {
|
|||||||
* @return {(function(...[*]=): void)|*}
|
* @return {(function(...[*]=): void)|*}
|
||||||
*/
|
*/
|
||||||
static debounce(id, callback, timeout = 500, leading = false) {
|
static debounce(id, callback, timeout = 500, leading = false) {
|
||||||
/* eslint-disable no-undef */
|
if (!this.debounce.timeId) {
|
||||||
if (!debounce.timeId) {
|
this.debounce.timeId = {};
|
||||||
debounce.timeId = {};
|
|
||||||
}
|
}
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
if (leading) {
|
if (leading) {
|
||||||
// callback will be executed only at the first debounced-function call
|
// callback will be executed only at the first debounced-function call
|
||||||
if (!debounce.timeId[id]) {
|
if (!this.debounce.timeId[id]) {
|
||||||
callback.apply(this, args);
|
callback.apply(this, args);
|
||||||
}
|
}
|
||||||
clearTimeout(debounce.timeId[id]);
|
clearTimeout(this.debounce.timeId[id]);
|
||||||
debounce.timeId[id] = setTimeout(() => {
|
this.debounce.timeId[id] = setTimeout(() => {
|
||||||
debounce.timeId[id] = undefined;
|
this.debounce.timeId[id] = undefined;
|
||||||
}, timeout);
|
}, timeout);
|
||||||
} else {
|
} else {
|
||||||
// callback will only be executed `delay` milliseconds after the last debounced-function call
|
// callback will only be executed `delay` milliseconds after the last debounced-function call
|
||||||
clearTimeout(debounce.timeId[id]);
|
clearTimeout(this.debounce.timeId[id]);
|
||||||
debounce.timeId[id] = setTimeout(() => {
|
this.debounce.timeId[id] = setTimeout(() => {
|
||||||
callback.apply(this, args);
|
callback.apply(this, args);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* eslint-enable no-undef */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ Hooks.once("init", async () => {
|
|||||||
const reverseBar = data.attribute === "fatigue" && game.settings.get(L5R5E.namespace, "token-reverseFatigueBar");
|
const reverseBar = data.attribute === "fatigue" && game.settings.get(L5R5E.namespace, "token-reverseFatigueBar");
|
||||||
|
|
||||||
// Bar value
|
// Bar value
|
||||||
const pct = Math.clamped(Number(data.value), 0, data.max) / data.max;
|
const pct = Math.clamp(Number(data.value), 0, data.max) / data.max;
|
||||||
|
|
||||||
// Modify color
|
// Modify color
|
||||||
let color = number === 0 ? [pct / 1.2, 1 - pct, 0] : [0.5 * pct, 0.7 * pct, 0.5 + pct / 2];
|
let color = number === 0 ? [pct / 1.2, 1 - pct, 0] : [0.5 * pct, 0.7 * pct, 0.5 + pct / 2];
|
||||||
|
|||||||
Reference in New Issue
Block a user