From 343ac6ab9d7542b22cef13bba198ac07d981a8ff Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 18 Sep 2022 17:30:15 +0200 Subject: [PATCH] NRG stuff --- modules/pegasus-actor.js | 36 +++++++++++++++++++++-- modules/pegasus-vehicle-sheet.js | 2 ++ system.json | 2 +- template.json | 1 + templates/partial-vehicle-stat-block.html | 6 ++-- templates/vehicle-sheet.html | 22 ++++++++++---- 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 44b1663..da4b737 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -23,6 +23,7 @@ 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} /* -------------------------------------------- */ /** @@ -628,6 +629,10 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ async preprocessItem(event, item, onDrop = false) { + if ( item.type != "effect" && __isVehicle[item.type]) { + ui.notifications.warn("You can't drop Vehicles item over a character sheet.") + return + } // Pre-filter effects if (item.type == 'effect') { @@ -649,6 +654,7 @@ export class PegasusActor extends Actor { } } + if (item.type == 'race') { this.applyRace(item.system) } else if (item.type == 'role') { @@ -1851,7 +1857,7 @@ export class PegasusActor extends Actor { modules.totalvms = Number(hull.system.vms) } else { modules.totalvms = 0 - } + } let spaceList = this.items.filter(item => item.type == "vehiclemodule") || [] spaceList = spaceList.concat(this.items.filter(item => item.type == "vehicleweaponmodule") || []) let space = 0 @@ -1868,11 +1874,29 @@ export class PegasusActor extends Actor { } - // Manage top speed } + /* -------------------------------------------- */ + getTotalCost( ) { + let sumCost = 0 + for( let item of this.items) { + if ( __isVehicle[item.type]) { + if (item.system.cost) { + sumCost += Number(item.system.cost) + } + } + } + return sumCost + } + /* -------------------------------------------- */ async preprocessItemVehicle(event, item, onDrop = false) { + + if ( item.type != "effect" && !__isVehicle[item.type]) { + ui.notifications.warn("You can't drop Character items over a vehicle sheet.") + return + } + //console.log(">>>>> item", item.type, __isVehicleUnique[item.type]) if ( __isVehicleUnique[item.type] ) { let toDelList = [] @@ -1886,7 +1910,13 @@ export class PegasusActor extends Actor { await this.deleteEmbeddedDocuments('Item', toDelList) } } - + // Check size + if (item.type == "vehiclemodule" || item.type == "vehicleweaponmodule") { + if ( this.system.modules.usedvms + Number(item.system.space) > this.system.modules.totalvms ) { + ChatMessage.create( { content: `No more room available to host module ${item.name}. Module is not added to the vehicle.`}) + return false + } + } return true } diff --git a/modules/pegasus-vehicle-sheet.js b/modules/pegasus-vehicle-sheet.js index f4f2ff1..1b9125b 100644 --- a/modules/pegasus-vehicle-sheet.js +++ b/modules/pegasus-vehicle-sheet.js @@ -40,6 +40,8 @@ export class PegasusVehicleSheet extends ActorSheet { effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, optionsDiceList: PegasusUtility.getOptionsDiceList(), + vmsAvailable: objectData.system.modules.totalvms - objectData.system.modules.vmsused, + totalCost: this.actor.getTotalCost(), optionsLevel: PegasusUtility.getOptionsLevel(), subActors: duplicate(this.actor.getSubActors()), effects: duplicate(this.actor.getEffects()), diff --git a/system.json b/system.json index 440ab05..7d7f196 100644 --- a/system.json +++ b/system.json @@ -254,6 +254,6 @@ ], "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "10.0.8", + "version": "10.0.9", "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" } \ No newline at end of file diff --git a/template.json b/template.json index 5bd0305..6f06067 100644 --- a/template.json +++ b/template.json @@ -233,6 +233,7 @@ "currentlevel": 0, "avgnrg": 0, "curnrg": 0, + "maxnrg": 0, "col": 2 }, "mr": { diff --git a/templates/partial-vehicle-stat-block.html b/templates/partial-vehicle-stat-block.html index 1712089..340ce9e 100644 --- a/templates/partial-vehicle-stat-block.html +++ b/templates/partial-vehicle-stat-block.html @@ -45,14 +45,16 @@ {{#if (eq key "pc")}}
- Av NRG - Cur NRG +  - + Av NRG + + Max NRG +
{{/if}} diff --git a/templates/vehicle-sheet.html b/templates/vehicle-sheet.html index 81a609e..c520fff 100644 --- a/templates/vehicle-sheet.html +++ b/templates/vehicle-sheet.html @@ -253,16 +253,26 @@
- -

VMS

-
  • + VDP + + Vehicle Value + + Total cost + + VMS Total - + + Available + Used -