#68 : Process stat effects automatically

This commit is contained in:
sladecraven 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)

View File

@ -59,6 +59,13 @@ export class PegasusUtility {
Handlebars.registerHelper('mul', function (a, b) {
return parseInt(a) * parseInt(b);
})
Handlebars.registerHelper('add', function (a, b) {
return parseInt(a) + parseInt(b);
});
Handlebars.registerHelper('sub', function (a, b) {
return parseInt(a) - parseInt(b);
})
}
/* -------------------------------------------- */

View File

@ -49,6 +49,7 @@
"abbrev": "AGI",
"level": 1,
"value": 1,
"bonuseffect": 0,
"mod": 0,
"col": 1
},
@ -57,6 +58,7 @@
"abbrev": "MND",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 1,
"mod": 0
},
@ -65,6 +67,7 @@
"abbrev": "SOC",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 1,
"mod": 0
},
@ -73,6 +76,7 @@
"abbrev": "STR",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 1,
"mod": 0
},
@ -81,6 +85,7 @@
"abbrev": "PHY",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 1,
"mod": 0
},
@ -89,6 +94,7 @@
"abbrev": "COM",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 2,
"mod": 0
},
@ -97,6 +103,7 @@
"abbrev": "DEF",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 2,
"mod": 0
},
@ -105,6 +112,7 @@
"abbrev": "STL",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 2,
"mod": 0
},
@ -113,6 +121,7 @@
"abbrev": "PER",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 2,
"mod": 0
},
@ -121,6 +130,7 @@
"abbrev": "FOC",
"level": 1,
"value": 1,
"bonuseffect": 0,
"col": 2,
"mod": 0
}
@ -208,6 +218,7 @@
"label": "FC",
"abbrev": "fc",
"level": 0,
"bonuseffect": 0,
"currentlevel": 0,
"col": 1
},
@ -216,6 +227,7 @@
"abbrev": "man",
"dicevalue": "",
"level": 0,
"bonuseffect": 0,
"currentlevel": 0,
"turningarc45": 0,
"col": 1
@ -224,6 +236,7 @@
"label": "HR",
"abbrev": "hr",
"level": 0,
"bonuseffect": 0,
"currentlevel": 0,
"size": 0,
"col": 2
@ -232,6 +245,7 @@
"label": "PC",
"abbrev": "pc",
"level": 0,
"bonuseffect": 0,
"currentlevel": 0,
"actnrg": 0,
"curnrg": 0,
@ -242,6 +256,7 @@
"label": "MR",
"abbrev": "mr",
"level": 0,
"bonuseffect": 0,
"currentlevel": 0,
"col": 3
},
@ -249,6 +264,7 @@
"label": "A/D",
"abbrev": "ad",
"level": 0,
"bonuseffect": 0,
"currentlevel": 0,
"accmode": "",
"currentspeed": "",

View File

@ -7,7 +7,7 @@
</span>
<select class="status-small-label color-class-common" type="text" name="system.statistics.{{key}}.value" value="{{stat.value}}"
data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
{{#select stat.value}}
{{#select (add stat.value stat.bonuseffect)}}
{{{@root.optionsDiceList}}}
{{/select}}
</select>