Fix divers

This commit is contained in:
2023-04-08 09:55:08 +02:00
parent 9d3ef8cbeb
commit e95f7de0c5
7 changed files with 88 additions and 49 deletions

View File

@ -61,6 +61,7 @@ export class HeritiersActorSheet extends ActorSheet {
secretsdecouverts: await TextEditor.enrichHTML(this.object.system.biodata.secretsdecouverts, {async: true}),
questions: await TextEditor.enrichHTML(this.object.system.biodata.questions, {async: true}),
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}),
playernotes: await TextEditor.enrichHTML(this.object.system.biodata.playernotes, {async: true}),
options: this.options,
owner: this.document.isOwner,
editScore: this.options.editScore,

View File

@ -67,17 +67,29 @@ export const HERITIERS_CONFIG = {
"0": "Aucun/Non applicable",
"5": "Enfantine",
"6": "Triviale",
"7": "Moins Triviale",
"8": "Aisée",
"7": "Moins Aisée",
"10": "Normale",
"11": "Moins Normale",
"12": "Compliquée",
"13": "Plus Compliquée",
"14": "Difficile",
"15": "Plus Difficile",
"16": "Très Difficile",
"17": "Très Très Difficile",
"18": "Critique",
"19": "Plus Critique",
"20": "Insurmontable",
"20": "Très Insurmontable",
"22": "Surhumaine",
"23": "Très Surhumaine",
"24": "Epique",
"25": "Plus Epique",
"26": "Légendaire",
"26": "Très Légendaire",
"28": "Mythique",
"29": "Plus Mythique",
"30": "Divine"
},

View File

@ -42,12 +42,12 @@ export class HeritiersUtility {
/* -------------------------------------------- */
static sortByName(table) {
static sortByName(table) {
return table.sort(function (a, b) {
return a.name.localeCompare(b.name);
})
}
/* -------------------------------------------- */
static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => {
@ -269,63 +269,71 @@ export class HeritiersUtility {
/* -------------------------------------------- */
static computeMonnaieDetails(valueSC) {
let po = Math.floor(valueSC / 400)
let pa = Math.floor((valueSC - (po*400)) / 20)
let sc = valueSC - (po*400) - (pa*20)
let pa = Math.floor((valueSC - (po * 400)) / 20)
let sc = valueSC - (po * 400) - (pa * 20)
return {
po: po, pa: pa, sc: sc, valueSC: valueSC
po: po, pa: pa, sc: sc, valueSC: valueSC
}
}
/* -------------------------------------------- */
static incDecHeritage() {
}
/* -------------------------------------------- */
static computeResult(actor, rollData) {
rollData.diceResult = -1
let resTab = []
for ( let res of rollData.roll.terms[0].results) {
rollData.diceResult = Math.max(res.result, rollData.diceResult)
resTab.push(res.result)
}
let isFailure = false
if (rollData.mainDice.includes("d10")) {
if ( rollData.diceResult == 1) {
rollData.finalResult -= 3
isFailure = true
}
}
if (rollData.mainDice.includes("d12")) {
if ( rollData.diceResult == 1 || rollData.diceResult == 2) {
rollData.finalResult -= 5
isFailure = true
}
}
// Heritage/Tricherie management
let isTricherieHeritage = rollData.useHeritage || rollData.useTricherie
rollData.marge = 0
if (!isFailure && (rollData.useHeritage || rollData.useTricherie)) {
if (isTricherieHeritage) {
let resTab = [ rollData.roll.terms[0].results[0].result, rollData.roll.terms[0].results[1].result, rollData.roll.terms[0].results[2].result ]
rollData.diceResult = resTab[0] + "," + resTab[1] + "," + resTab[2]
let subResult = Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
if (resTab[1] == 1) { resTab[1] -= 4 }
if (resTab[2] == 1) { resTab[2] -= 6 }
if (resTab[2] == 2) { resTab[2] -= 7 }
rollData.finalResult = rollData.roll.total - subResult + Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
// Gestion des résultats spéciaux
resTab = resTab.sort()
if ( (resTab[0] == resTab[1]) && (resTab[1] == resTab[2])) {
if ((resTab[0] == resTab[1]) && (resTab[1] == resTab[2])) {
rollData.marge = 7
rollData.isSuccess = true
rollData.isCriticalSuccess = true
rollData.isCriticalSuccess = true
rollData.isBrelan = true
}
if ((resTab[0]+1 == resTab[1]) && (resTab[1]+1 == resTab[2]) ) {
if ((resTab[0] + 1 == resTab[1]) && (resTab[1] + 1 == resTab[2])) {
rollData.marge = 7
rollData.isSuccess = true
rollData.isCriticalSuccess = true
}
if ( rollData.useTricherie) {
rollData.isCriticalSuccess = true
rollData.isSuite = true
}
if (rollData.useTricherie) {
actor.incDecTricherie(-1)
}
if ( rollData.useHeritage) {
if (rollData.useHeritage) {
this.incDecHeritage()
}
} else {
rollData.finalResult = rollData.roll.total
if (rollData.mainDice.includes("d10")) {
if (rollData.diceResult == 1) {
rollData.finalResult -= 3 + rollData.diceResult // substract 3 and the 1 value that has been added
}
}
if (rollData.mainDice.includes("d12")) {
if (rollData.diceResult == 1 || rollData.diceResult == 2) {
rollData.finalResult -= 5 + rollData.diceResult // Remove also the dice result has it has been added already
}
}
}
//rollData.finalResult = Math.max(rollData.finalResult, 0)
//console.log("Result : ", rollData)
if (rollData.marge == 0 && rollData.sdValue > 0 ) {
if (rollData.marge == 0 && rollData.sdValue > 0) {
rollData.marge = rollData.finalResult - rollData.sdValue
rollData.isSuccess = (rollData.finalResult >= rollData.sdValue)
rollData.isCriticalSuccess = ((rollData.finalResult - rollData.sdValue) >= 7)
@ -338,7 +346,7 @@ export class HeritiersUtility {
let actor = this.getActorFromRollData(rollData)
if ( typeof(rollData.pvMalus) != "number" ) {
if (typeof (rollData.pvMalus) != "number") {
ui.notifications.warn("Votre personnage est Moribond(e). Aucun jet autorisé")
return
}
@ -346,14 +354,16 @@ export class HeritiersUtility {
//rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey])
rollData.nbDice = (rollData.useTricherie || rollData.useHeritage) ? 3 : 1
rollData.diceFormula = rollData.nbDice + rollData.mainDice + "kh1"
//console.log("BEFORE COMP", rollData)
if (rollData.useTricherie || rollData.useHeritage) {
rollData.diceFormula = "{1d8, 1d10, 1d12}"
} else {
rollData.diceFormula = "1" + rollData.mainDice + "kh1"
}
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
@ -369,9 +379,8 @@ export class HeritiersUtility {
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll
console.log(">>>> ", myRoll)
rollData.finalResult = myRoll.total
this.computeResult(actor, rollData)
if (rollData.mode == "init") {
actor.setFlag("world", "last-initiative", rollData.finalResult)
}
@ -379,10 +388,10 @@ export class HeritiersUtility {
// Compute damages, cf p 187
if (rollData.arme && rollData.isSuccess) {
rollData.degatsArme = rollData.arme.system.degats + rollData.marge
if (rollData.arme.system.categorie == "lourde" ) {
if (rollData.arme.system.categorie == "lourde") {
rollData.degatsArme += actor.system.caracteristiques.for.value
}
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise" ) {
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise") {
rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2)
}
}