From 78e92d736bbe99ebb1cdc794ebb13519e9224983 Mon Sep 17 00:00:00 2001 From: "Wendel Henrique (SouOWendel)" Date: Wed, 22 May 2024 20:11:51 -0300 Subject: [PATCH] feat(compatibility): was added retro compatibility between v11 and v12 core versions of Foundry Math.clamped and Math.clamp functions are used according to the foundry core versions --- module/documents/actor.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index c236048..03ba985 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -178,14 +178,19 @@ export class OrdemActor extends Actor { spaces.value += spaces.bonus.value; spaces.max += spaces.bonus.max; - spaces.pct = Math.clamp((spaces.value * 100) / spaces.max, 0, 100); + // TODO: V11 AND V12 SPACE/WEIGHT RETRO COMPATIBILITY + if (game.version >= 12) spaces.pct = Math.clamp((spaces.value * 100) / spaces.max, 0, 100); + else spaces.pct = Math.clamped((spaces.value * 100) / spaces.max, 0, 100); // Apply the debuffs if (spaces.value > spaces.max) { spaces.over = spaces.value - spaces.max; system.desloc.value += -3; system.defense.value += -5; - spaces.pctMax = Math.clamp((spaces.over * 100) / spaces.max, 0, 100); + + // TODO: V11 AND V12 SPACE/WEIGHT RETRO COMPATIBILITY + if (game.version >= 12) spaces.pctMax = Math.clamp((spaces.over * 100) / spaces.max, 0, 100); + else spaces.pctMax = Math.clamped((spaces.over * 100) / spaces.max, 0, 100); } if (spaces.value > spaces.max * 2) ui.notifications.warn(game.i18n.localize('WARN.overWeight')); }