diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 74dc18e..7a134bd 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -2171,7 +2171,27 @@ export class PegasusActor extends Actor { activateVehicleModule(itemId) { let mod = this.items.get(itemId) if (mod) { - this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }]) + if ( mod.system.nrg && mod.system.nrg > 0) { + let pc = duplicate( this.system.statistics.pc) + if ( !mod.system.activated ) { // Previous state was non activated -> activated now + if ( mod.system.nrg > pc.curnrg) { + ChatMessage.create( { content: `The Vehicle ${this.name} does not have enough Energy to Activate this module at this time.`}) + return + } + this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }]) + pc.actnrg += Number(mod.system.nrg) + pc.maxnrg -= Number(mod.system.nrg) + pc.curnrg -= Number(mod.system.nrg) + this.update({'system.statistics.pc': pc}) + } else { // Now deactivated + pc.actnrg -= Number(mod.system.nrg) + pc.maxnrg += Number(mod.system.nrg) + this.update({'system.statistics.pc': pc}) + this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }]) + } + } else { + this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }]) + } } } diff --git a/modules/pegasus-vehicle-sheet.js b/modules/pegasus-vehicle-sheet.js index 1bffd04..c0c4f3f 100644 --- a/modules/pegasus-vehicle-sheet.js +++ b/modules/pegasus-vehicle-sheet.js @@ -41,7 +41,6 @@ export class PegasusVehicleSheet extends ActorSheet { limited: this.object.limited, optionsDiceList: PegasusUtility.getOptionsDiceList(), vmsAvailable: objectData.system.modules.totalvms - objectData.system.modules.vmsused, - avgNRG: objectData.system.statistics.pc.maxnrg - objectData.system.statistics.pc.curnrg, crewList: this.actor.getCrewList(), totalCost: this.actor.getTotalCost(), optionsLevel: PegasusUtility.getOptionsLevel(), diff --git a/system.json b/system.json index b45617a..c23ccfe 100644 --- a/system.json +++ b/system.json @@ -49,8 +49,8 @@ { "type": "Item", "label": "Perks", - "name": "perk", - "path": "packs/perk.db", + "name": "perks", + "path": "packs/perks.db", "system": "fvtt-pegasus-rpg", "private": false, "flags": {} diff --git a/template.json b/template.json index 3a97bee..48ad441 100644 --- a/template.json +++ b/template.json @@ -233,7 +233,7 @@ "abbrev": "pc", "level": 0, "currentlevel": 0, - "avgnrg": 0, + "actnrg": 0, "curnrg": 0, "maxnrg": 0, "col": 2 diff --git a/templates/partial-vehicle-stat-block.html b/templates/partial-vehicle-stat-block.html index e432b0a..1196ff3 100644 --- a/templates/partial-vehicle-stat-block.html +++ b/templates/partial-vehicle-stat-block.html @@ -64,9 +64,9 @@  - Act NRG - + Max NRG - + {{/if}}