Fix various glitches
This commit is contained in:
@ -237,7 +237,7 @@ export class PegasusActor extends Actor {
|
||||
nrg.activated += item.data.data.costspent
|
||||
nrg.value -= item.data.data.costspent
|
||||
nrg.max -= item.data.data.costspent
|
||||
this.update({ 'data.nrg': nrg })
|
||||
await this.update({ 'data.nrg': nrg })
|
||||
|
||||
let effects = []
|
||||
for (let effect of item.data.data.effectsgained) {
|
||||
@ -250,7 +250,7 @@ export class PegasusActor extends Actor {
|
||||
} else {
|
||||
nrg.activated -= item.data.data.costspent
|
||||
nrg.max += item.data.data.costspent
|
||||
this.update({ 'data.nrg': nrg })
|
||||
await this.update({ 'data.nrg': nrg })
|
||||
|
||||
let toRem = []
|
||||
for (let item of this.data.items) {
|
||||
@ -520,24 +520,26 @@ export class PegasusActor extends Actor {
|
||||
let updateOK = true
|
||||
if (status == "ready") {
|
||||
this.cleanPerkEffects(itemId)
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used3': false, 'data.used3': false }] ) // Reset on Ready
|
||||
if (item.data.data.features.nrgcost.flag) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.activated -= item.data.data.features.nrgcost.value
|
||||
this.update({ 'data.nrg': nrg })
|
||||
nrg.max += item.data.data.features.nrgcost.value
|
||||
await this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
if (item.data.data.features.bonushealth.flag) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus -= item.data.data.features.bonushealth.value
|
||||
health.bonus -= Number(item.data.data.features.bonushealth.value) || 0
|
||||
this.update({ 'data.secondary.health': health })
|
||||
}
|
||||
if (item.data.data.features.bonusdelirium.flag) {
|
||||
let delirium = duplicate(this.data.data.delirium.delirium)
|
||||
delirium.bonus -= item.data.data.features.bonusdelirium.value
|
||||
let delirium = duplicate(this.data.data.secondary.delirium)
|
||||
delirium.bonus -= Number(item.data.data.features.bonusdelirium.value) || 0
|
||||
this.update({ 'data.secondary.delirium': delirium })
|
||||
}
|
||||
if (item.data.data.features.bonusnrg.flag) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.mod -= item.data.data.features.bonusnrg.value
|
||||
nrg.mod -= Number(item.data.data.features.bonusnrg.value) || 0
|
||||
this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
this.disableWeaverPerk(item)
|
||||
@ -555,10 +557,11 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
// Manage additional flags
|
||||
if (item.data.data.features.nrgcost.flag) {
|
||||
if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) {
|
||||
if ( (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) && (this.data.data.nrg.max >= item.data.data.features.nrgcost.value)) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.activated += item.data.data.features.nrgcost.value
|
||||
nrg.value -= item.data.data.features.nrgcost.value
|
||||
nrg.max -= item.data.data.features.nrgcost.value
|
||||
this.update({ 'data.nrg': nrg })
|
||||
} else {
|
||||
updateOK = false
|
||||
@ -567,17 +570,17 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
if (item.data.data.features.bonushealth.flag) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus += item.data.data.features.bonushealth.value
|
||||
health.bonus += Number(item.data.data.features.bonushealth.value) || 0
|
||||
this.update({ 'data.secondary.health': health })
|
||||
}
|
||||
if (item.data.data.features.bonusdelirium.flag) {
|
||||
let delirium = duplicate(this.data.data.delirium.delirium)
|
||||
delirium.bonus += item.data.data.features.bonusdelirium.value
|
||||
let delirium = duplicate(this.data.data.secondary.delirium)
|
||||
delirium.bonus += Number(item.data.data.features.bonusdelirium.value) || 0
|
||||
this.update({ 'data.secondary.delirium': delirium })
|
||||
}
|
||||
if (item.data.data.features.bonusnrg.flag) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.mod += item.data.data.features.bonusnrg.value
|
||||
nrg.mod += Number(item.data.data.features.bonusnrg.value) || 0
|
||||
this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
this.enableWeaverPerk(item)
|
||||
@ -610,29 +613,28 @@ export class PegasusActor extends Actor {
|
||||
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod;
|
||||
if (phyDiceValue != this.data.data.secondary.health.max) {
|
||||
updates['data.secondary.health.max'] = phyDiceValue
|
||||
updates['data.secondary.health.value'] = phyDiceValue
|
||||
//updates['data.secondary.health.value'] = phyDiceValue
|
||||
}
|
||||
let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod;
|
||||
if (mndDiceValue != this.data.data.secondary.delirium.max) {
|
||||
updates['data.secondary.delirium.max'] = mndDiceValue
|
||||
updates['data.secondary.delirium.value'] = mndDiceValue
|
||||
//updates['data.secondary.delirium.value'] = mndDiceValue
|
||||
}
|
||||
let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod;
|
||||
if (stlDiceValue != this.data.data.secondary.stealthhealth.max) {
|
||||
updates['data.secondary.stealthhealth.max'] = stlDiceValue
|
||||
updates['data.secondary.stealthhealth.value'] = stlDiceValue
|
||||
//updates['data.secondary.stealthhealth.value'] = stlDiceValue
|
||||
}
|
||||
|
||||
let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value) + this.data.data.secondary.socialhealth.bonus + this.data.data.statistics.soc.mod;
|
||||
if (socDiceValue != this.data.data.secondary.socialhealth.max) {
|
||||
updates['data.secondary.socialhealth.max'] = socDiceValue
|
||||
updates['data.secondary.socialhealth.value'] = socDiceValue
|
||||
//updates['data.secondary.socialhealth.value'] = socDiceValue
|
||||
}
|
||||
|
||||
let nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.nrg.mod + this.data.data.statistics.foc.mod;
|
||||
if (nrgValue != this.data.data.nrg.max) {
|
||||
updates['data.nrg.max'] = nrgValue
|
||||
updates['data.nrg.value'] = nrgValue
|
||||
if (nrgValue != this.data.data.nrg.absolutemax) {
|
||||
updates['data.nrg.absolutemax'] = nrgValue
|
||||
}
|
||||
nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.statistics.foc.mod;
|
||||
if (nrgValue != this.data.data.combat.stunthreshold) {
|
||||
|
Reference in New Issue
Block a user