Fix #49
This commit is contained in:
parent
5346debdbb
commit
0386f5e272
@ -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 }])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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": {}
|
||||
|
@ -233,7 +233,7 @@
|
||||
"abbrev": "pc",
|
||||
"level": 0,
|
||||
"currentlevel": 0,
|
||||
"avgnrg": 0,
|
||||
"actnrg": 0,
|
||||
"curnrg": 0,
|
||||
"maxnrg": 0,
|
||||
"col": 2
|
||||
|
@ -64,9 +64,9 @@
|
||||
<a class="vehicle-current-nrg-minus plus-minus-button"> -</a>
|
||||
</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>
|
||||
<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>
|
||||
{{/if}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user