#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.system.combat.hindrancedice = hindrance
this.getTraumaState() this.getTraumaState()
this.cleanupPerksIfTrauma() 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') let effects = this.items.filter(item => item.type == 'effect')
for (let effect of effects) { for (let effect of effects) {
effect = duplicate(effect) 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 != "notapplicable" || effect.system.specaffected.length > 0)
&& effect.system.stataffected != "special" && effect.system.stataffected != "special"
&& effect.system.stataffected != "powerroll" && effect.system.stataffected != "powerroll"
@ -1660,7 +1679,10 @@ export class PegasusActor extends Actor {
if (statKey) { if (statKey) {
rollData.statKey = statKey rollData.statKey = statKey
rollData.stat = this.getStat(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 rollData.statMod = rollData.stat.mod
if (vehicle) { if (vehicle) {
rollData.vehicle = duplicate(vehicle) rollData.vehicle = duplicate(vehicle)

View File

@ -59,6 +59,13 @@ export class PegasusUtility {
Handlebars.registerHelper('mul', function (a, b) { Handlebars.registerHelper('mul', function (a, b) {
return parseInt(a) * parseInt(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", "abbrev": "AGI",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"mod": 0, "mod": 0,
"col": 1 "col": 1
}, },
@ -57,6 +58,7 @@
"abbrev": "MND", "abbrev": "MND",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 1, "col": 1,
"mod": 0 "mod": 0
}, },
@ -65,6 +67,7 @@
"abbrev": "SOC", "abbrev": "SOC",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 1, "col": 1,
"mod": 0 "mod": 0
}, },
@ -73,6 +76,7 @@
"abbrev": "STR", "abbrev": "STR",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 1, "col": 1,
"mod": 0 "mod": 0
}, },
@ -81,6 +85,7 @@
"abbrev": "PHY", "abbrev": "PHY",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 1, "col": 1,
"mod": 0 "mod": 0
}, },
@ -89,6 +94,7 @@
"abbrev": "COM", "abbrev": "COM",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 2, "col": 2,
"mod": 0 "mod": 0
}, },
@ -97,6 +103,7 @@
"abbrev": "DEF", "abbrev": "DEF",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 2, "col": 2,
"mod": 0 "mod": 0
}, },
@ -105,6 +112,7 @@
"abbrev": "STL", "abbrev": "STL",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 2, "col": 2,
"mod": 0 "mod": 0
}, },
@ -113,6 +121,7 @@
"abbrev": "PER", "abbrev": "PER",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 2, "col": 2,
"mod": 0 "mod": 0
}, },
@ -121,6 +130,7 @@
"abbrev": "FOC", "abbrev": "FOC",
"level": 1, "level": 1,
"value": 1, "value": 1,
"bonuseffect": 0,
"col": 2, "col": 2,
"mod": 0 "mod": 0
} }
@ -208,6 +218,7 @@
"label": "FC", "label": "FC",
"abbrev": "fc", "abbrev": "fc",
"level": 0, "level": 0,
"bonuseffect": 0,
"currentlevel": 0, "currentlevel": 0,
"col": 1 "col": 1
}, },
@ -216,6 +227,7 @@
"abbrev": "man", "abbrev": "man",
"dicevalue": "", "dicevalue": "",
"level": 0, "level": 0,
"bonuseffect": 0,
"currentlevel": 0, "currentlevel": 0,
"turningarc45": 0, "turningarc45": 0,
"col": 1 "col": 1
@ -224,6 +236,7 @@
"label": "HR", "label": "HR",
"abbrev": "hr", "abbrev": "hr",
"level": 0, "level": 0,
"bonuseffect": 0,
"currentlevel": 0, "currentlevel": 0,
"size": 0, "size": 0,
"col": 2 "col": 2
@ -232,6 +245,7 @@
"label": "PC", "label": "PC",
"abbrev": "pc", "abbrev": "pc",
"level": 0, "level": 0,
"bonuseffect": 0,
"currentlevel": 0, "currentlevel": 0,
"actnrg": 0, "actnrg": 0,
"curnrg": 0, "curnrg": 0,
@ -242,6 +256,7 @@
"label": "MR", "label": "MR",
"abbrev": "mr", "abbrev": "mr",
"level": 0, "level": 0,
"bonuseffect": 0,
"currentlevel": 0, "currentlevel": 0,
"col": 3 "col": 3
}, },
@ -249,6 +264,7 @@
"label": "A/D", "label": "A/D",
"abbrev": "ad", "abbrev": "ad",
"level": 0, "level": 0,
"bonuseffect": 0,
"currentlevel": 0, "currentlevel": 0,
"accmode": "", "accmode": "",
"currentspeed": "", "currentspeed": "",

View File

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