From 392c76f86a2badf0e14869af90f00a39785055ae Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 25 Sep 2022 15:48:11 +0200 Subject: [PATCH] Fix #24 #25 Cargo capacity --- modules/pegasus-actor.js | 16 ++++++++++- modules/pegasus-vehicle-sheet.js | 6 ++++ templates/partial-actor-equipment.html | 22 ++++++++------- templates/vehicle-sheet.html | 38 ++++++++++++++------------ 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index c185a2b..e0b93e4 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -23,7 +23,8 @@ const __statBuild = [ const __isVehicleUnique = { vehiclehull: 1, powercoremodule: 1, mobilitymodule: 1, propulsionmodule: 1, combatmodule: 1 } const __speed2Num = { fullstop: 0, crawling: 1, slow: 2, average: 3, fast: 4, extfast: 5 } const __num2speed = ["fullstop", "crawling", "slow", "average", "fast", "extfast"] -const __isVehicle = { vehiclehull: 1, powercoremodule: 1, mobilitymodule: 1, combatmodule: 1, propulsionmodule: 1, vehiclemodule: 1, vehicleweaponmodule: 1, effect: 1 } +const __isVehicle = { vehiclehull: 1, powercoremodule: 1, mobilitymodule: 1, combatmodule: 1, + propulsionmodule: 1, vehiclemodule: 1, vehicleweaponmodule: 1, effect: 1, equipment: 1, weapon: 1, armor: 1, shield:1, money: 1 } const __bonusEffect = { name: "Crawling MAN Bonus", type: "effect", img: "systems/fvtt-pegasus-rpg/images/icons/icon_effect.webp", system: { @@ -2154,4 +2155,17 @@ export class PegasusActor extends Actor { this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }]) } } + + /* -------------------------------------------- */ + getCurrentCargoCapacity( ) { + let capacity = 0 + for (let cargo of this.items) { + if (cargo.type == "equipment" || cargo.type == "weapon" || cargo.type == "armor" || cargo.type == "money" || cargo.type == "shield" ) { + let q = cargo.system.quantity || 1 + capacity += q * cargo.system.weight + } + } + return capacity + } + } diff --git a/modules/pegasus-vehicle-sheet.js b/modules/pegasus-vehicle-sheet.js index 72b771a..1c0cdad 100644 --- a/modules/pegasus-vehicle-sheet.js +++ b/modules/pegasus-vehicle-sheet.js @@ -54,6 +54,12 @@ export class PegasusVehicleSheet extends ActorSheet { propulsionModules: duplicate(this.actor.getPropulsionModules()), vehicleModules: duplicate(this.actor.getVehicleModules()), vehicleWeaponModules: duplicate(this.actor.getVehicleWeaponModules()), + weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ), + armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())), + shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields()) ), + equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ), + cargoCurrent: this.actor.getCurrentCargoCapacity(), + moneys: duplicate(this.actor.getMoneys()), options: this.options, owner: this.document.isOwner, editScore: this.options.editScore, diff --git a/templates/partial-actor-equipment.html b/templates/partial-actor-equipment.html index 95abddf..bd6a544 100644 --- a/templates/partial-actor-equipment.html +++ b/templates/partial-actor-equipment.html @@ -7,14 +7,14 @@ {{/if}} - {{#if (count equip.data.effects)}} - {{#if equip.data.activated}} + {{#if (count equip.system.effects)}} + {{#if equip.system.activated}} Deactivate {{else}} Activate @@ -25,14 +25,14 @@ {{#if equip.data.iscontainer}} - {{equip.data.contentsEnc}} + {{equip.system.contentsEnc}} {{else}} - {{mul equip.data.weight equip.data.quantity}} + {{mul equip.system.weight equip.system.quantity}} {{/if}} - {{#if equip.data.idrDice}} - {{equip.data.idrDice}} + {{#if equip.system.idrDice}} + {{equip.system.idrDice}} {{else}}  -  {{/if}} @@ -40,9 +40,11 @@
 
- {{#if (eq level 1)}} - {{#if equip.data.equipped}}{{else}}{{/if}} + {{#if canequip}} + {{#if (eq level 1)}} + {{#if equip.system.equipped}}{{else}}{{/if}} + {{/if}} {{/if}}
diff --git a/templates/vehicle-sheet.html b/templates/vehicle-sheet.html index 42e2048..80f44dd 100644 --- a/templates/vehicle-sheet.html +++ b/templates/vehicle-sheet.html @@ -592,11 +592,17 @@ {{!-- Cargo Tab --}}
-
-

Encumbrance

- Current : {{encCurrent}} - Capacity : {{encCapacity}} - Hindrance : {{encHindrance}} +
+
    +
  • + Cargo Capacity + + Total Cargo Capacity + +
  • +
- {{#each containersTree as |equip key|}} - {{> systems/fvtt-pegasus-rpg/templates/partial-actor-equipment.html equip=equip level=1}} -
    - {{#each equip.system.contents as |subgear key|}} - {{> systems/fvtt-pegasus-rpg/templates/partial-actor-equipment.html equip=subgear level=2}} - {{/each}} -
+ {{#each equipments as |equip key|}} + {{> systems/fvtt-pegasus-rpg/templates/partial-actor-equipment.html equip=equip level=1 canequip=false}} {{/each}}
+

Cargo information :

+
+ {{editor data.cargo.cargoinformation target="system.cargo.cargoinformation" button=true owner=owner + editable=editable}} +
+ +