Skip to content

Commit 46d4a9f

Browse files
joesinghausclevett
authored andcommitted
[ChatSetAttr] Fix bug in --mod option (Roll20#846)
* [ChatSetAttr] Fix bug in --mod option A maximum value of 0 would (wrongly) be treated as infinity. * [ChatSetAttr] Actually fix the problem
1 parent f66c6ce commit 46d4a9f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ChatSetAttr/1.9/ChatSetAttr.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ const ChatSetAttr = (function () {
262262
let moddedValue = parseFloat(v) + parseFloat(attr.get(k) || "0");
263263
if (!_.isNaN(moddedValue)) {
264264
if (opts.modb && k === "current") {
265-
moddedValue = Math.min(Math.max(moddedValue, 0), parseFloat(attr.get("max")) || Infinity);
265+
const parsedMax = parseFloat(attr.get("max"));
266+
moddedValue = Math.min(Math.max(moddedValue, 0), _.isNaN(parsedMax) ? Infinity : parsedMax);
266267
}
267268
newValue[k] = moddedValue;
268269
} else {

ChatSetAttr/ChatSetAttr.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ const ChatSetAttr = (function () {
262262
let moddedValue = parseFloat(v) + parseFloat(attr.get(k) || "0");
263263
if (!_.isNaN(moddedValue)) {
264264
if (opts.modb && k === "current") {
265-
moddedValue = Math.min(Math.max(moddedValue, 0), parseFloat(attr.get("max")) || Infinity);
265+
const parsedMax = parseFloat(attr.get("max"));
266+
moddedValue = Math.min(Math.max(moddedValue, 0), _.isNaN(parsedMax) ? Infinity : parsedMax);
266267
}
267268
newValue[k] = moddedValue;
268269
} else {

0 commit comments

Comments
 (0)