Skip to content

Commit e4ec598

Browse files
committed
fix: fix numeric operations on affinities not working particularly well
- fix Foundry V11 incompatibilities
1 parent 74c9587 commit e4ec598

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

module/documents/actors/common/affinity-data-model.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { MathHelper } from '../../../helpers/math-helper.mjs';
2+
13
/**
24
* @property {number} base
35
* @property {number} current
@@ -43,14 +45,14 @@ export class AffinityDataModel extends foundry.abstract.DataModel {
4345
},
4446
set: (newValue) => {
4547
delete this.current;
46-
let value = Math.clamp(newValue, -1, 3);
48+
let value = MathHelper.clamp(newValue, -1, 3);
4749
Object.defineProperty(this, 'current', {
4850
configurable: true,
4951
enumerable: true,
5052
get: () => value,
5153
set: (newValue) => {
5254
if (Number.isNumeric(newValue)) {
53-
value = Math.clamp(Number(newValue), -1, 3);
55+
value = MathHelper.clamp(Number(newValue), -1, 3);
5456
}
5557
},
5658
});

module/documents/actors/common/attribute-data-model.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { MathHelper } from '../../../helpers/math-helper.mjs';
2+
13
/**
24
* @param {number} number
35
* @return {boolean}
@@ -26,7 +28,7 @@ export class AttributeDataModel extends foundry.abstract.DataModel {
2628
configurable: false,
2729
enumerable: true,
2830
get: () => {
29-
return Math.clamp(2 * Math.floor(current / 2), 6, 12);
31+
return MathHelper.clamp(2 * Math.floor(current / 2), 6, 12);
3032
},
3133
set: (newValue) => {
3234
if (Number.isNumeric(newValue)) {

0 commit comments

Comments
 (0)