diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js
index 22309d3..51e5c29 100644
--- a/modules/pegasus-actor.js
+++ b/modules/pegasus-actor.js
@@ -150,11 +150,11 @@ export class PegasusActor extends Actor {
return ab;
}
/* -------------------------------------------- */
- getPerks() {
+ getPerks() {
let comp = duplicate(this.items.filter(item => item.type == 'perk') || [])
for (let perk of comp) {
if (perk.system.features.range.flag) {
- perk.rangeText = PegasusUtility.getRangeText( perk.system.features.range.value)
+ perk.rangeText = PegasusUtility.getRangeText(perk.system.features.range.value)
}
}
return comp;
@@ -362,19 +362,17 @@ export class PegasusActor extends Actor {
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
}
}
-
+
/* -------------------------------------------- */
updatePPP() {
let ppp = 0
- for(let power of this.items) {
+ for (let power of this.items) {
if (power.type == "power") {
ppp += Number(power.system.powerlevelcost)
}
}
- console.log("PPP update", ppp)
- if ( ppp != this.system.ppp.spentPPP) {
- console.log("PPP update2", ppp)
- this.update( { 'system.ppp.spentPPP': ppp} )
+ if (ppp != this.system.ppp.spentPPP) {
+ this.update({ 'system.ppp.spentPPP': ppp })
}
}
@@ -1689,7 +1687,7 @@ export class PegasusActor extends Actor {
rollData.statVehicle = vehicle.system.statistics.man
rollData.vehicleKey = "man"
}
- vehicle.addVehicleShields( rollData)
+ vehicle.addVehicleShields(rollData)
}
vehicle.addEffects(rollData, false, false, false)
//this.addVehiculeHindrances(rollData.effectsList, vehicle)
@@ -2114,29 +2112,6 @@ export class PegasusActor extends Actor {
}
}
- // Shield management
- if (item.type == "vehiclemodule" && item.system.category == "shield") {
- let shieldsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "shield") || []
- shieldsList.push(item)
- let level = 0
- for (let armour of shieldsList) {
- if (armour.system.shielddicevalue > 0) {
- level += Number(armour.system.shielddicevalue)
- }
- }
- let shift = 500
- for( let loc of __LocationsArmour) {
- let arcKey = loc + "arc"
- let arc = duplicate(this.system.arcs[arcKey])
- if (level != Number(arc.shieldlevel)) {
- arc.shieldlevel = level
- setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
- shift += 200
- }
- }
- }
-
-
return true
}
@@ -2224,7 +2199,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
- addVehicleArmors( rollData) {
+ addVehicleArmors(rollData) {
for (let arcKey in this.system.arcs) {
let arc = this.system.arcs[arcKey]
if (arc.armourlevel > 0) {
@@ -2249,7 +2224,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
- activateVehicleModule(itemId) {
+ async activateVehicleModule(itemId) {
let mod = this.items.get(itemId)
if (mod) {
if (mod.system.nrg && mod.system.nrg > 0) {
@@ -2259,7 +2234,7 @@ export class PegasusActor extends Actor {
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 }])
+ await 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)
@@ -2268,10 +2243,28 @@ export class PegasusActor extends Actor {
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 }])
+ await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
}
} else {
- this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
+ await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
+ }
+ }
+ // Shield management
+ let shieldsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "shield" && item.system.activated) || []
+ let level = 0
+ for (let armour of shieldsList) {
+ if (armour.system.shielddicevalue > 0) {
+ level += Number(armour.system.shielddicevalue)
+ }
+ }
+ let shift = 500
+ for (let loc of __LocationsArmour) {
+ let arcKey = loc + "arc"
+ let arc = duplicate(this.system.arcs[arcKey])
+ if (level != Number(arc.shieldlevel)) {
+ arc.shieldlevel = level
+ setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
+ shift += 200
}
}
}
diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html
index af5d7e2..7776190 100644
--- a/templates/roll-dialog-generic.html
+++ b/templates/roll-dialog-generic.html
@@ -115,8 +115,8 @@
-
+