From af792eeef8740abc10e60e6c733e1571825942db Mon Sep 17 00:00:00 2001 From: U~man Date: Thu, 30 Jul 2020 13:41:47 +0200 Subject: [PATCH] ENH: Detailed now set item weight to 80 --- src/lang/en.json | 1 + src/lang/fr.json | 1 + src/module/actor/entity.js | 9 +++++---- src/module/settings.js | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index cfbb2ca..01580ea 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -173,6 +173,7 @@ "OSE.Setting.EncumbranceDisabled": "Disabled", "OSE.Setting.EncumbranceBasic": "Basic", "OSE.Setting.EncumbranceDetailed": "Detailed", + "OSE.Setting.EncumbranceComplete": "Complete", "OSE.Setting.MovementAuto": "Calculate Movement", "OSE.Setting.SignificantTreasure": "Significant Treasure Weight", "OSE.Setting.SignificantTreasureHint": "Weight at which treasure will reduce the movement, only useful for basic encumbrance", diff --git a/src/lang/fr.json b/src/lang/fr.json index 4198b56..e4d20cd 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -173,6 +173,7 @@ "OSE.Setting.EncumbranceDisabled": "Désactivé", "OSE.Setting.EncumbranceBasic": "Basique", "OSE.Setting.EncumbranceDetailed": "Detaillé", + "OSE.Setting.EncumbranceComplete": "Complet", "OSE.Setting.MovementAuto": "Calculer Déplacement", "OSE.Setting.SignificantTreasure": "Poids d'un Trésor Significatif", "OSE.Setting.SignificantTreasureHint": "Poids auquel le Trésor réduit le déplacement. Utilisé pour l'encombrement Basique", diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index cd86506..27bdcc9 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -495,18 +495,19 @@ export class OseActor extends Actor { } const data = this.data.data; let option = game.settings.get("ose", "encumbranceOption"); - let basic = option == "basic"; // Compute encumbrance - let owned = ["weapon", "armor", "item"]; let totalWeight = 0; + let hasItems = false; Object.values(this.data.items).forEach((item) => { - if (item.type == "item" && (!basic || item.data.treasure)) { + if (item.type == "item" && (['complete', 'disabled'].includes(option) || item.data.treasure)) { totalWeight += item.data.quantity.value * item.data.weight; - } else if (!basic && owned.includes(item.type)) { + hasItems = true; + } else if (option != 'basic' && ['weapon', 'armor'].includes(item.type)) { totalWeight += item.data.weight; } }); + if (option === 'detailed' && hasItems) totalWeight += 80; data.encumbrance = { pct: Math.clamped( diff --git a/src/module/settings.js b/src/module/settings.js index 4cead3b..90cc247 100644 --- a/src/module/settings.js +++ b/src/module/settings.js @@ -45,6 +45,7 @@ export const registerSettings = function () { disabled: "OSE.Setting.EncumbranceDisabled", basic: "OSE.Setting.EncumbranceBasic", detailed: "OSE.Setting.EncumbranceDetailed", + complete: "OSE.Setting.EncumbranceComplete", }, onChange: _ => window.location.reload() });