diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 2dd7a25..5383579 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -24,7 +24,8 @@ const __isVehicleUnique = { vehiclehull: 1, powercoremodule: 1, mobilitymodule: 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, equipment: 1, weapon: 1, armor: 1, shield:1, money: 1 } + propulsionmodule: 1, vehiclemodule: 1, vehicleweaponmodule: 1, effect: 1, equipment: 1, weapon: 1, armor: 1, shield:1, money: 1, cargo: 1 } +const __isVehicleCargo = {equipment: 1, weapon: 1, armor: 1, shield:1, money: 1, cargo: 1} const __bonusEffect = { name: "Crawling MAN Bonus", type: "effect", img: "systems/fvtt-pegasus-rpg/images/icons/icon_effect.webp", system: { @@ -159,32 +160,30 @@ export class PegasusActor extends Actor { let comp = this.items.filter(item => item.type == 'combatmodule'); return comp; } - /* -------------------------------------------- */ + getCargos() { + let comp = this.items.filter(item => item.type == 'cargo'); + return comp; + } getVehicleHull() { let comp = this.items.filter(item => item.type == 'vehiclehull'); return comp; } - /* -------------------------------------------- */ getPowercoreModules() { let comp = this.items.filter(item => item.type == 'powercoremodule'); return comp; } - /* -------------------------------------------- */ getMobilityModules() { let comp = this.items.filter(item => item.type == 'mobilitymodule'); return comp; } - /* -------------------------------------------- */ getPropulsionModules() { let comp = this.items.filter(item => item.type == 'propulsionmodule'); return comp; } - /* -------------------------------------------- */ getVehicleModules() { let comp = this.items.filter(item => item.type == 'vehiclemodule'); return comp; } - /* -------------------------------------------- */ getVehicleWeaponModules() { let comp = this.items.filter(item => item.type == 'vehicleweaponmodule'); return comp; @@ -2050,6 +2049,20 @@ export class PegasusActor extends Actor { return false } } + if( __isVehicleCargo[item.type]) { + let capacity = this.getCurrentCargoCapacity() + if ( item.type == "cargo") { + capacity += Number(item.system.capacity) + } else { + let q = item.system.quantity || 1 + capacity += Number(q) * Number(item.system.weight) + } + console.log("capa", capacity, this.system.cargo.cargocapacity) + if ( capacity > this.system.cargo.cargocapacity) { + ui.notifications.warn("Your cargo capacity is already full, unable to add this content : " + item.name) + return false + } + } return true } @@ -2163,7 +2176,10 @@ export class PegasusActor extends Actor { 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 + capacity += Number(q) * Number(cargo.system.weight) + } + if (cargo.type == "cargo" ) { + capacity += Number(cargo.system.capacity) } } return capacity diff --git a/modules/pegasus-vehicle-sheet.js b/modules/pegasus-vehicle-sheet.js index ef978f6..e7695f9 100644 --- a/modules/pegasus-vehicle-sheet.js +++ b/modules/pegasus-vehicle-sheet.js @@ -58,6 +58,7 @@ export class PegasusVehicleSheet extends ActorSheet { armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())), shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields()) ), equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ), + cargos: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getCargos()) ), cargoCurrent: this.actor.getCurrentCargoCapacity(), moneys: duplicate(this.actor.getMoneys()), options: this.options, diff --git a/system.json b/system.json index 0dcbb83..604a7a5 100644 --- a/system.json +++ b/system.json @@ -253,7 +253,7 @@ ], "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "10.0.17", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.0.17.zip", + "version": "10.0.18", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.0.18.zip", "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" } \ No newline at end of file diff --git a/templates/vehicle-sheet.html b/templates/vehicle-sheet.html index 80f44dd..f6df65c 100644 --- a/templates/vehicle-sheet.html +++ b/templates/vehicle-sheet.html @@ -596,7 +596,7 @@