Fix #49
This commit is contained in:
@@ -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(),
|
||||
|
Reference in New Issue
Block a user