Skip to content

Commit

Permalink
feat(compatibility): was added retro compatibility between v11 and v1…
Browse files Browse the repository at this point in the history
…2 core versions of Foundry

Math.clamped and Math.clamp functions are used according to the foundry core versions
  • Loading branch information
SouOWendel committed May 22, 2024
1 parent 9aa91b6 commit 78e92d7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions module/documents/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down

0 comments on commit 78e92d7

Please sign in to comment.