This commit is contained in:
sladecraven 2022-09-27 14:16:11 +02:00
parent 5346debdbb
commit 0386f5e272
5 changed files with 26 additions and 7 deletions

View File

@ -2171,7 +2171,27 @@ export class PegasusActor extends Actor {
activateVehicleModule(itemId) { activateVehicleModule(itemId) {
let mod = this.items.get(itemId) let mod = this.items.get(itemId)
if (mod) { if (mod) {
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 }]) 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 }])
}
} }
} }

View File

@ -41,7 +41,6 @@ export class PegasusVehicleSheet extends ActorSheet {
limited: this.object.limited, limited: this.object.limited,
optionsDiceList: PegasusUtility.getOptionsDiceList(), optionsDiceList: PegasusUtility.getOptionsDiceList(),
vmsAvailable: objectData.system.modules.totalvms - objectData.system.modules.vmsused, vmsAvailable: objectData.system.modules.totalvms - objectData.system.modules.vmsused,
avgNRG: objectData.system.statistics.pc.maxnrg - objectData.system.statistics.pc.curnrg,
crewList: this.actor.getCrewList(), crewList: this.actor.getCrewList(),
totalCost: this.actor.getTotalCost(), totalCost: this.actor.getTotalCost(),
optionsLevel: PegasusUtility.getOptionsLevel(), optionsLevel: PegasusUtility.getOptionsLevel(),

View File

@ -49,8 +49,8 @@
{ {
"type": "Item", "type": "Item",
"label": "Perks", "label": "Perks",
"name": "perk", "name": "perks",
"path": "packs/perk.db", "path": "packs/perks.db",
"system": "fvtt-pegasus-rpg", "system": "fvtt-pegasus-rpg",
"private": false, "private": false,
"flags": {} "flags": {}

View File

@ -233,7 +233,7 @@
"abbrev": "pc", "abbrev": "pc",
"level": 0, "level": 0,
"currentlevel": 0, "currentlevel": 0,
"avgnrg": 0, "actnrg": 0,
"curnrg": 0, "curnrg": 0,
"maxnrg": 0, "maxnrg": 0,
"col": 2 "col": 2

View File

@ -64,9 +64,9 @@
<a class="vehicle-current-nrg-minus plus-minus-button">&nbsp;-</a> <a class="vehicle-current-nrg-minus plus-minus-button">&nbsp;-</a>
</span> </span>
<span class="stat-label stat-margin" name="{{key}}">Act NRG</span> <span class="stat-label stat-margin" name="{{key}}">Act NRG</span>
<input type="text" class="input-numeric-short" value="{{@root.avgNRG}}" data-dtype="Number" disabled/> <input type="text" class="input-numeric-short" value="{{stat.actnrg}}" data-dtype="Number" disabled/>
<span class="stat-label stat-margin" name="{{key}}">Max NRG</span> <span class="stat-label stat-margin" name="{{key}}">Max NRG</span>
<input type="text" class="input-numeric-short" name="system.statistics.{{key}}.maxnrg" value="{{stat.maxnrg}}" data-dtype="Number" disabled /> <input type="text" class="input-numeric-short" value="{{stat.maxnrg}}" data-dtype="Number" disabled />
</div> </div>
{{/if}} {{/if}}