Various fixes

This commit is contained in:
2023-03-11 12:11:27 +01:00
parent 02f8207fb7
commit f26cd7670c
11 changed files with 111 additions and 71 deletions

View File

@@ -44,30 +44,14 @@ export class HeritiersUtility {
/* -------------------------------------------- */
static sortByName(table) {
return table.sort(function (a, b) {
let fa = a.name.toLowerCase(),
fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
return a.name.localeCompare(b.name);
})
}
/* -------------------------------------------- */
static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => {
let fa = a.name.toLowerCase();
let fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
return a.name.localeCompare(b.name);
})
}
@@ -130,6 +114,7 @@ export class HeritiersUtility {
'systems/fvtt-les-heritiers/templates/partial-item-header.html',
'systems/fvtt-les-heritiers/templates/partial-item-description.html',
'systems/fvtt-les-heritiers/templates/partial-item-nav.html',
'systems/fvtt-les-heritiers/templates/partial-utile-skills.html',
'systems/fvtt-les-heritiers/templates/partial-list-niveau.html'
]
return loadTemplates(templatePaths);
@@ -358,14 +343,19 @@ export class HeritiersUtility {
rollData.nbDice = (rollData.useTricherie || rollData.useHeritage) ? 3 : 1
rollData.diceFormula = rollData.nbDice + rollData.mainDice + "kh1"
//console.log("BEFORE COMP", rollData)
let rangValue = 0
if (rollData.rang) {
rangValue = rollData.rang.value
}
if (rollData.competence) {
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
let specBonus = (rollData.useSpecialite) ? 1 : 0
rollData.diceFormula += `+${rollData.carac.value}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}`
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}`
} else if (rollData.pouvoirBase) {
rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rollData.bonusMalusContext}`
rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rangValue}+${rollData.bonusMalusContext}`
} else {
rollData.diceFormula += `+${rollData.carac.value}+${rollData.bonusMalusContext}`
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.bonusMalusContext}`
}
rollData.diceFormula += `+${rollData.pvMalus}`