Domaines/Factions : calcul automatique de la valeur depuis les cases cochées
prepareDerivedData() calcule désormais : - skill.value = count(level1..level8 cochés) pour chaque domaine - faction.value = count(level1..level9 cochés) pour chaque faction - initiative recalculée après (dépend de mobilite.value et inspiration.value) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -153,7 +153,22 @@ export default class CelestopolCharacter extends foundry.abstract.TypeDataModel
|
|||||||
|
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
super.prepareDerivedData()
|
super.prepareDerivedData()
|
||||||
// Initiative PJ : 4 + Mobilité (Corps) + Inspiration (Cœur)
|
|
||||||
|
// Calcul automatique de la valeur de chaque domaine = nombre de cases cochées
|
||||||
|
for (const stat of Object.values(this.stats)) {
|
||||||
|
for (const skill of Object.values(stat)) {
|
||||||
|
if (typeof skill !== "object" || !("level1" in skill)) continue
|
||||||
|
skill.value = [1,2,3,4,5,6,7,8].filter(i => skill[`level${i}`]).length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcul automatique de la valeur de chaque faction = nombre de cases cochées
|
||||||
|
for (const faction of Object.values(this.factions)) {
|
||||||
|
if (typeof faction !== "object" || !("level1" in faction)) continue
|
||||||
|
faction.value = [1,2,3,4,5,6,7,8,9].filter(i => faction[`level${i}`]).length
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initiative PJ : 4 + Mobilité (Corps) + Inspiration (Cœur) [après calcul des domaines]
|
||||||
this.initiative = 4 + (this.stats.corps.mobilite?.value ?? 0) + (this.stats.coeur.inspiration?.value ?? 0)
|
this.initiative = 4 + (this.stats.corps.mobilite?.value ?? 0) + (this.stats.coeur.inspiration?.value ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user