From a14bd9fd425e23b4298b0bb317e7db93019dc392 Mon Sep 17 00:00:00 2001 From: U~man Date: Tue, 14 Jul 2020 17:19:25 +0200 Subject: [PATCH] ENH: Wage and Party - Fixed AC value on party sheet - Merges wage and upkeep --- src/module/actor/character-sheet.js | 15 ---------- src/module/actor/entity.js | 30 +++++++++++++++++++ src/module/dialog/party-sheet.js | 2 +- src/template.json | 3 +- .../partials/character-attributes-tab.html | 4 +-- .../actors/partials/character-header.html | 7 +---- src/templates/apps/party-sheet.html | 7 +++-- 7 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index 90b35ce..1050177 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -85,21 +85,6 @@ export class OseActorSheetCharacter extends OseActorSheet { this._calculateMovement(data, totalWeight); } - // Compute AC - let baseAc = 9; - let baseAac = 10; - let shield = 0; - data.owned.armors.forEach((a) => { - if (a.data.equipped && a.data.type != "shield") { - baseAc = a.data.ac.value; - baseAac = a.data.aac.value; - } else if (a.data.equipped && a.data.type == "shield") { - shield = a.data.ac.value; - } - }); - data.data.aac.value = baseAac + data.data.scores.dex.mod + shield; - data.data.ac.value = baseAc - data.data.scores.dex.mod - shield; - data.data.shield = shield; return data; } diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index 96d2cff..25db1a8 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -12,6 +12,7 @@ export class OseActor extends Actor { // Compute modifiers from actor scores this.computeModifiers(); this._isSlow(); + this.computeAC(); // Determine Initiative if (game.settings.get("ose", "individualInit")) { @@ -23,6 +24,7 @@ export class OseActor extends Actor { data.initiative.value = 0; } data.movement.encounter = data.movement.base / 3; + } /* -------------------------------------------- */ /* Socket Listeners and Handlers @@ -448,6 +450,31 @@ export class OseActor extends Actor { }); } + computeAC() { + if (this.data.type != "character") { + return; + } + // Compute AC + let baseAc = 9; + let baseAac = 10; + let shield = 0; + const data = this.data.data; + data.aac.naked = baseAc + data.scores.dex.mod; + data.ac.naked = baseAc - data.scores.dex.mod; + const armors = this.data.items.filter(i => i.type == 'armor'); + armors.forEach((a) => { + if (a.data.equipped && a.data.type != "shield") { + baseAc = a.data.ac.value; + baseAac = a.data.aac.value; + } else if (a.data.equipped && a.data.type == "shield") { + shield = a.data.ac.value; + } + }); + data.aac.value = baseAac + data.scores.dex.mod + shield; + data.ac.value = baseAc - data.scores.dex.mod - shield; + data.shield = shield; + } + computeModifiers() { if (this.data.type != "character") { return; @@ -489,6 +516,9 @@ export class OseActor extends Actor { data.scores.con.value ); + data.ac.naked = 9 + data.scores.dex.mod; + data.aac.naked = 10 - data.scores.dex.mod; + const capped = { 0: -2, 3: -2, diff --git a/src/module/dialog/party-sheet.js b/src/module/dialog/party-sheet.js index 4042664..cd3aa1c 100644 --- a/src/module/dialog/party-sheet.js +++ b/src/module/dialog/party-sheet.js @@ -104,7 +104,7 @@ export class OsePartySheet extends FormApplication { }, }, }, - }).render(true); + }, {height: "auto"}).render(true); } /** @override */ diff --git a/src/template.json b/src/template.json index 0fb45a5..50bdea3 100644 --- a/src/template.json +++ b/src/template.json @@ -6,8 +6,7 @@ "retainer": { "enabled": false, "loyalty": 0, - "wage": 0, - "upkeep": 0 + "wage": "" }, "hp": { "hd": "1d8", diff --git a/src/templates/actors/partials/character-attributes-tab.html b/src/templates/actors/partials/character-attributes-tab.html index ad8bb63..3b47887 100644 --- a/src/templates/actors/partials/character-attributes-tab.html +++ b/src/templates/actors/partials/character-attributes-tab.html @@ -81,11 +81,11 @@ {{#if config.ascendingAC}}
{{data.aac.value}}
- {{add 10 data.scores.dex.mod}}
+ {{data.aac.naked}} {{else}}
{{data.ac.value}}
- {{subtract data.scores.dex.mod 9}}
+ {{data.ac.naked}} {{/if}} {{#if data.shield}}
{{/if}} diff --git a/src/templates/actors/partials/character-header.html b/src/templates/actors/partials/character-header.html index 2ba60c9..726b042 100644 --- a/src/templates/actors/partials/character-header.html +++ b/src/templates/actors/partials/character-header.html @@ -6,15 +6,10 @@