#68 : Process stat effects automatically

This commit is contained in:
2022-09-28 16:27:16 +02:00
parent e3674f076c
commit 7977233d93
4 changed files with 48 additions and 3 deletions

View File

@ -1330,6 +1330,25 @@ export class PegasusActor extends Actor {
this.system.combat.hindrancedice = hindrance
this.getTraumaState()
this.cleanupPerksIfTrauma()
this.parseStatEffects()
}
}
/* -------------------------------------------- */
parseStatEffects() {
let effects = this.items.filter(effect => effect.type == "effect" && effect.system.genre == "positive" && effect.system.statdice )
for (let statKey in this.system.statistics) {
let stat = duplicate(this.system.statistics[statKey])
let bonus = 0
for (let effect of effects) {
if (effect.system.stataffected == statKey) {
bonus += Number(effect.system.effectlevel)
}
}
if ( bonus != stat.bonuseffect) {
stat.bonuseffect = bonus
this.update( { [`system.statistics.${statKey}`]: stat} )
}
}
}
@ -1568,7 +1587,7 @@ export class PegasusActor extends Actor {
let effects = this.items.filter(item => item.type == 'effect')
for (let effect of effects) {
effect = duplicate(effect)
if (!effect.system.hindrance
if (!effect.system.hindrance && !effect.system.statdice
&& (effect.system.stataffected != "notapplicable" || effect.system.specaffected.length > 0)
&& effect.system.stataffected != "special"
&& effect.system.stataffected != "powerroll"
@ -1660,7 +1679,10 @@ export class PegasusActor extends Actor {
if (statKey) {
rollData.statKey = statKey
rollData.stat = this.getStat(statKey)
rollData.statDicesLevel = rollData.stat.value || rollData.stat.level
if ( rollData.stat.value != undefined ) {
rollData.stat.level = rollData.stat.value // Normalize
}
rollData.statDicesLevel = rollData.stat.level + rollData.stat.bonuseffect
rollData.statMod = rollData.stat.mod
if (vehicle) {
rollData.vehicle = duplicate(vehicle)