Various fixes
This commit is contained in:
@ -477,7 +477,7 @@ export class PegasusActor extends Actor {
|
||||
effects.push(item.id)
|
||||
}
|
||||
}
|
||||
if (effects.length) {
|
||||
if (effects.length > 0) {
|
||||
await this.deleteEmbeddedDocuments('Item', effects)
|
||||
}
|
||||
}
|
||||
@ -491,12 +491,18 @@ export class PegasusActor extends Actor {
|
||||
item = this.items.get(itemId) // Refresh
|
||||
if (item.data.data.nbuse == "next1action" && item.data.data.used1) {
|
||||
this.cleanPerkEffects(itemId)
|
||||
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
|
||||
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
|
||||
}
|
||||
if (item.data.data.nbuse == "next2action" && item.data.data.used1 && item.data.data.used2) {
|
||||
this.cleanPerkEffects(itemId)
|
||||
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
|
||||
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
|
||||
}
|
||||
if (item.data.data.nbuse == "next3action" && item.data.data.used1 && item.data.data.used2 && item.data.data.used3) {
|
||||
this.cleanPerkEffects(itemId)
|
||||
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
|
||||
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -519,8 +525,10 @@ export class PegasusActor extends Actor {
|
||||
|
||||
let updateOK = true
|
||||
if (status == "ready") {
|
||||
console.log("Cleaning effects")
|
||||
this.cleanPerkEffects(itemId)
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used3': false, 'data.used3': false }] ) // Reset on Ready
|
||||
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
|
||||
{ _id: itemId, 'data.used2': false}, { _id: itemId,'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
|
||||
@ -529,17 +537,20 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
if (item.data.data.features.bonushealth.flag) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus -= Number(item.data.data.features.bonushealth.value) || 0
|
||||
health.value -= Number(item.data.data.features.bonushealth.value) || 0
|
||||
health.max -= 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.secondary.delirium)
|
||||
delirium.bonus -= Number(item.data.data.features.bonusdelirium.value) || 0
|
||||
delirium.value -= Number(item.data.data.features.bonusdelirium.value) || 0
|
||||
delirium.max -= 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 -= Number(item.data.data.features.bonusnrg.value) || 0
|
||||
nrg.value -= Number(item.data.data.features.bonusnrg.value) || 0
|
||||
nrg.max -= Number(item.data.data.features.bonusnrg.value) || 0
|
||||
this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
this.disableWeaverPerk(item)
|
||||
@ -570,17 +581,20 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
if (item.data.data.features.bonushealth.flag) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus += Number(item.data.data.features.bonushealth.value) || 0
|
||||
health.value += Number(item.data.data.features.bonushealth.value) || 0
|
||||
health.max += 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.secondary.delirium)
|
||||
delirium.bonus += Number(item.data.data.features.bonusdelirium.value) || 0
|
||||
delirium.value += Number(item.data.data.features.bonusdelirium.value) || 0
|
||||
delirium.max += 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 += Number(item.data.data.features.bonusnrg.value) || 0
|
||||
nrg.value += Number(item.data.data.features.bonusnrg.value) || 0
|
||||
nrg.max += Number(item.data.data.features.bonusnrg.value) || 0
|
||||
this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
this.enableWeaverPerk(item)
|
||||
@ -606,35 +620,47 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async computeNRGHealth() {
|
||||
async computeNRGHealth( ) {
|
||||
if (this.isToken) return
|
||||
if (this.isOwner || game.user.isGM) {
|
||||
let updates = {}
|
||||
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
|
||||
if (this.computeValue) {
|
||||
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
|
||||
if (this.computeValue) {
|
||||
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
|
||||
if (this.computeValue) {
|
||||
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
|
||||
if (this.computeValue) {
|
||||
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.absolutemax) {
|
||||
updates['data.nrg.absolutemax'] = nrgValue
|
||||
if (this.computeValue) {
|
||||
updates['data.nrg.max'] = nrgValue
|
||||
updates['data.nrg.value'] = nrgValue
|
||||
}
|
||||
}
|
||||
nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.statistics.foc.mod;
|
||||
if (nrgValue != this.data.data.combat.stunthreshold) {
|
||||
@ -852,7 +878,10 @@ export class PegasusActor extends Actor {
|
||||
if (!effect.data.hindrance
|
||||
&& effect.data.stataffected != "notapplicable"
|
||||
&& effect.data.stataffected != "special") {
|
||||
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
|
||||
if ( effect.data.effectstatlevel && effect.data.effectstat == rollData.statKey) {
|
||||
effect.data.effectlevel = rollData.statDicesLevel
|
||||
}
|
||||
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -982,6 +1011,7 @@ export class PegasusActor extends Actor {
|
||||
rollData.title = `Spec. : ${spec.name} `
|
||||
rollData.specList = [spec]
|
||||
rollData.selectedSpec = spec._id
|
||||
rollData.specName = spec.name
|
||||
rollData.specDicesLevel = spec.data.level
|
||||
this.startRoll(rollData)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user