Fix #112 shield/armors for arc
This commit is contained in:
parent
329b7839da
commit
7d05ef495b
@ -2487,6 +2487,34 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addVehicleModuleEffects( mod) {
|
||||
let effects = []
|
||||
for (let effect of mod.system.effects) {
|
||||
if (!effect.system) {
|
||||
effect.system = effect.data
|
||||
}
|
||||
effect.system.effectId = mod.id // Link to the perk, in order to dynamically remove them
|
||||
effects.push(effect)
|
||||
}
|
||||
if (effects.length) {
|
||||
await this.createEmbeddedDocuments('Item', effects)
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async removeVehicleModuleEffects( mod) {
|
||||
let toRem = []
|
||||
for (let item of this.items) {
|
||||
if (item.type == 'effect' && item.system.effectId == mod.id) {
|
||||
toRem.push(item.id)
|
||||
}
|
||||
}
|
||||
console.log("TODEL", toRem)
|
||||
if (toRem.length) {
|
||||
await this.deleteEmbeddedDocuments('Item', toRem)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async activateVehicleModule(itemId) {
|
||||
let mod = this.items.get(itemId)
|
||||
@ -2503,13 +2531,20 @@ export class PegasusActor extends Actor {
|
||||
pc.maxnrg -= Number(mod.system.nrg)
|
||||
pc.curnrg -= Number(mod.system.nrg)
|
||||
this.update({ 'system.statistics.pc': pc })
|
||||
this.addVehicleModuleEffects(mod)
|
||||
} else { // Now deactivated
|
||||
pc.actnrg -= Number(mod.system.nrg)
|
||||
pc.maxnrg += Number(mod.system.nrg)
|
||||
this.update({ 'system.statistics.pc': pc })
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
||||
this.removeVehicleModuleEffects(mod)
|
||||
}
|
||||
} else {
|
||||
if ( mod.system.activated) {
|
||||
this.removeVehicleModuleEffects(mod)
|
||||
} else {
|
||||
this.addVehicleModuleEffects(mod)
|
||||
}
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
||||
}
|
||||
}
|
||||
|
@ -134,19 +134,7 @@ export class PegasusVehicleSheet extends ActorSheet {
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.activateVehicleModule( itemId)
|
||||
});
|
||||
|
||||
html.find('.equip-activate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.equipActivate( itemId)
|
||||
});
|
||||
html.find('.equip-deactivate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.equipDeactivate( itemId)
|
||||
});
|
||||
|
||||
html.find('.effect-used').click(ev => {
|
||||
html.find('.effect-used').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.perkEffectUsed( itemId)
|
||||
|
Loading…
Reference in New Issue
Block a user