New v5 fixes

This commit is contained in:
2022-07-21 22:52:17 +02:00
parent aa4409be28
commit e7f5a17096
6 changed files with 50 additions and 29 deletions

View File

@ -809,11 +809,12 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
async cleanupPerksIfTrauma() {
if ( this.getTraumaState == "severetrauma") {
if ( this.getTraumaState() == "severetrauma") {
for (let perk of this.data.items) {
if (perk.type == "perk") {
this.cleanPerkEffects(perk.id)
this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used2': false, 'data.used3': false }])
this.updateEmbeddedDocuments('Item', [{ _id: perk.id, 'data.status': "ready", 'data.used1': false, 'data.used2': false, 'data.used3': false }])
ChatMessage.create({ content: `Perk ${perk.name} has been deactivated due to Severe Trauma state !` } )
}
}
}
@ -835,6 +836,7 @@ export class PegasusActor extends Actor {
}
chatData.content = `<div>${this.name} is suffering from Severe Trauma and cannot use Perks at this time.</div`
ChatMessage.create(chatData)
this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.status': "ready", 'data.used1': false, 'data.used2': false, 'data.used3': false }])
return
}
@ -999,7 +1001,7 @@ export class PegasusActor extends Actor {
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
@ -1026,6 +1028,17 @@ export class PegasusActor extends Actor {
updates['data.mr.value'] = mrLevel
}
let moralitythreshold = Number(PegasusUtility.getDiceValue(this.data.data.statistics.foc.value)) + Number(this.data.data.statistics.foc.mod)
moralitythreshold = (moralitythreshold < 1) ? 1 : moralitythreshold;
if (moralitythreshold != this.data.data.biodata.moralitythreshold) {
updates['data.biodata.moralitythreshold'] = moralitythreshold
}
if (!this.warnMorality && this.data.data.biodata.morality >= moralitythreshold-2) {
ChatMessage.create( {content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!"} )
this.warnMorality = true
}
let race = this.getRace()
if (race && race.name && (race.name != this.data.data.biodata.racename)) {
updates['data.biodata.racename'] = race.name
@ -1232,6 +1245,9 @@ export class PegasusActor extends Actor {
if (overCapacity > 0) {
effectsList.push({ label: "Encumbrance Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: overCapacity })
}
if (this.data.data.biodata.morality <= 0) {
effectsList.push({ label: "Morality Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: 3 })
}
let effects = this.data.items.filter(item => item.type == 'effect')
for (let effect of effects) {
effect = duplicate(effect)