diff --git a/src/acks.css b/src/acks.css index 02103f0..027e8db 100644 --- a/src/acks.css +++ b/src/acks.css @@ -900,15 +900,6 @@ display: block; position: absolute; } -.acks.sheet.actor.character .encumbrance .encumbrance-breakpoint.encumbrance-25 { - left: 24.4%; -} -.acks.sheet.actor.character .encumbrance .encumbrance-breakpoint.encumbrance-35 { - left: 34.4%; -} -.acks.sheet.actor.character .encumbrance .encumbrance-breakpoint.encumbrance-50 { - left: 49.4%; -} .acks.sheet.actor.character .encumbrance .arrow-up { bottom: 0; width: 0; diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index 764ab00..55da6f6 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -50,7 +50,6 @@ export class AcksActorSheetCharacter extends AcksActorSheet { data.config.ascendingAC = game.settings.get("acks", "ascendingAC"); data.config.initiative = game.settings.get("acks", "initiative") != "group"; - data.config.encumbrance = game.settings.get("acks", "encumbranceOption"); data.config.BHR = game.settings.get("acks", "bhr"); data.config.removeMagicBonus = game.settings.get("acks", "removeMagicBonus"); diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index 10db389..dcd15ef 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -608,92 +608,67 @@ export class AcksActor extends Actor { } computeEncumbrance() { - if (this.data.type != "character") { + if (this.data.type !== "character") { return; } - const data = this.data.data; - let option = game.settings.get("acks", "encumbranceOption"); - // Compute encumbrance - let totalWeight = 0; - let hasItems = false; - Object.values(this.data.items).forEach((item) => { - if (item.type == "item" && !item.data.treasure) { - if (option === "detailed") totalWeight += 166.6; - -// hasItems = true; - } - if ( - item.type == "item" && - (["complete", "disabled"].includes(option) || item.data.treasure) - ) { - totalWeight += item.data.quantity.value * item.data.weight; - } else if (option != "basic" && ["weapon", "armor"].includes(item.type)) { - totalWeight += item.data.weight; + const option = game.settings.get("acks", "encumbranceOption"); + + let totalEncumbrance = 0; + + this.data.items.forEach((item) => { + if (item.type === "item") { + if (option === "detailed") { + if (item.data.data.treasure) { + totalEncumbrance += item.data.data.weight * item.data.data.quantity.value; + } else { + totalEncumbrance += item.data.data.weight; + } + } else { + if (item.data.data.treasure) { + totalEncumbrance += 1000 * item.data.data.quantity.value; + } else { + totalEncumbrance += 1000; + } + } + } else if (["weapon", "armor"].includes(item.type)) { + if (option === "detailed") { + totalEncumbrance += item.data.data.weight; + } else { + totalEncumbrance += 1000; + } } }); -// if (option === "detailed" && hasItems) totalWeight += 166.6; - data.encumbrance = { + const maxEncumbrance = 20000 + (this.data.data.scores.str.mod * 1000); + + this.data.data.encumbrance = { pct: Math.clamped( -// To correct for percentage bar not lining up with movement rates. -// (100 * parseFloat(totalWeight)) / data.encumbrance.max, - (100 * parseFloat(totalWeight)) / 20000, + (totalEncumbrance / maxEncumbrance) * 100, 0, 100 ), - max: data.encumbrance.max, - encumbered: totalWeight > data.encumbrance.max, - value: Math.round(totalWeight), + max: maxEncumbrance, + encumbered: totalEncumbrance > maxEncumbrance, + value: Math.round(totalEncumbrance), }; - if (data.config.movementAuto && option != "disabled") { + if (this.data.data.config.movementAuto) { this._calculateMovement(); } } _calculateMovement() { - const data = this.data.data; - let option = game.settings.get("acks", "encumbranceOption"); - let weight = data.encumbrance.value; - if (["detailed", "complete"].includes(option)) { - if (weight > data.encumbrance.max) { - data.movement.base = 0; - } else if (weight > 10000) { - data.movement.base = 30; - } else if (weight > 7000) { - data.movement.base = 60; - } else if (weight > 5000) { - data.movement.base = 90; - } else { - data.movement.base = 120; - } - } else if (option == "basic") { - const armors = this.data.items.filter((i) => i.type == "armor"); - let heaviest = 0; - armors.forEach((a) => { - if (a.data.equipped) { - if (a.data.type == "light" && heaviest == 0) { - heaviest = 1; - } else if (a.data.type == "heavy") { - heaviest = 2; - } - } - }); - switch (heaviest) { - case 0: - data.movement.base = 120; - break; - case 1: - data.movement.base = 90; - break; - case 2: - data.movement.base = 60; - break; - } - if (weight > game.settings.get("acks", "significantTreasure")) { - data.movement.base -= 30; - } + if (this.data.data.encumbrance.value > this.data.data.encumbrance.max) { + this.data.data.movement.base = 0; + } else if (this.data.data.encumbrance.value > 10000) { + this.data.data.movement.base = 30; + } else if (this.data.data.encumbrance.value > 7000) { + this.data.data.movement.base = 60; + } else if (this.data.data.encumbrance.value > 5000) { + this.data.data.movement.base = 90; + } else { + this.data.data.movement.base = 120; } } diff --git a/src/module/helpers.js b/src/module/helpers.js index 7dd4479..d54ff4a 100644 --- a/src/module/helpers.js +++ b/src/module/helpers.js @@ -23,13 +23,21 @@ export const registerHelpers = async function () { }); Handlebars.registerHelper("subtract", function (lh, rh) { - return parseInt(rh) - parseInt(lh); + return parseInt(lh) - parseInt(rh); }); + Handlebars.registerHelper("fsubtract", (lh, rh) => { + return parseFloat(lh) - parseFloat(rh); + }) + Handlebars.registerHelper("divide", function (lh, rh) { return Math.floor(parseFloat(lh) / parseFloat(rh)); }); + Handlebars.registerHelper("fdivide", (lh, rh) => { + return parseFloat(lh) / parseFloat(rh); + }); + Handlebars.registerHelper("mult", function (lh, rh) { return parseFloat(lh) * parseFloat(rh); }); diff --git a/src/templates/actors/partials/character-inventory-tab.html b/src/templates/actors/partials/character-inventory-tab.html index 66df75d..c8ac380 100644 --- a/src/templates/actors/partials/character-inventory-tab.html +++ b/src/templates/actors/partials/character-inventory-tab.html @@ -35,7 +35,7 @@ {{/each}}
- {{#if (eq @root.config.encumbrance "basic")}}_{{else}}{{item.data.weight}}{{/if}} + {{#if (eq @root.config.encumbrance "detailed")}}{{item.data.weight}}{{else}}_{{/if}}
{{#if ../owner}} @@ -87,7 +87,7 @@ {{/if}}
- {{#if (eq @root.config.encumbrance "basic")}}_{{else}}{{item.data.weight}}{{/if}} + {{#if (eq @root.config.encumbrance "detailed")}}{{item.data.weight}}{{else}}_{{/if}}
{{#if ../owner}} @@ -134,7 +134,7 @@ placeholder="0" />{{#if item.data.quantity.max}}/{{item.data.quantity.max}}{{/if}}
- {{#if (eq @root.config.encumbrance "basic")}}_{{else if (eq @root.config.encumbrance "detailed")}}_{{else}}{{item.data.weight}}{{/if}} + {{#if (eq @root.config.encumbrance "detailed")}}{{item.data.weight}}{{else}}_{{/if}}
{{#if ../owner}} @@ -157,7 +157,7 @@
-
@@ -180,7 +180,7 @@ placeholder="0" />{{#if item.data.quantity.max}}/{{item.data.quantity.max}}{{/if}}
- {{mult item.data.quantity.value item.data.weight}} + {{#if (eq @root.config.encumbrance "detailed")}}{{mult item.data.quantity.value item.data.weight}}{{else}}_{{/if}}
{{#if ../owner}} @@ -200,12 +200,12 @@
{{value}} / {{max}} - - - - - - + + + + + + {{/with}}
\ No newline at end of file