diff --git a/modules/heritiers-actor-sheet.js b/modules/heritiers-actor-sheet.js index 01dab45..d059541 100644 --- a/modules/heritiers-actor-sheet.js +++ b/modules/heritiers-actor-sheet.js @@ -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, diff --git a/modules/heritiers-config.js b/modules/heritiers-config.js index d4120bb..819fc28 100644 --- a/modules/heritiers-config.js +++ b/modules/heritiers-config.js @@ -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" }, diff --git a/modules/heritiers-utility.js b/modules/heritiers-utility.js index d00feee..bc5bf2c 100644 --- a/modules/heritiers-utility.js +++ b/modules/heritiers-utility.js @@ -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) } } diff --git a/system.json b/system.json index 3a08425..a733d21 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-les-heritiers", "description": "Les Héritiers pour FoundryVTT", - "version": "10.0.32", + "version": "10.0.33", "authors": [ { "name": "Uberwald/LeRatierBretonnien", @@ -19,7 +19,7 @@ "gridUnits": "m", "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.32.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.33.zip", "languages": [ { "lang": "fr", diff --git a/template.json b/template.json index 9580e67..7e77ae6 100644 --- a/template.json +++ b/template.json @@ -36,6 +36,7 @@ "habitat": "", "notes": "", "statut": "", + "playernotes":"", "gmnotes": "" } }, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index c4939c6..18839cd 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -645,18 +645,28 @@
{{editor description target="system.biodata.description" button=true owner=owner editable=editable}}
+ + +

Notes diverses

+
+
+ {{editor playernotes target="system.biodata.playernotes" button=true owner=owner editable=editable}} +
+

Rêves étranges

{{editor revesetranges target="system.biodata.revesetranges" button=true owner=owner editable=editable}}
+

Secrets découverts

{{editor secretsdecouverts target="system.biodata.secretsdecouverts" button=true owner=owner editable=editable}}
+

Questions en suspens

diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index 864b742..eedea7a 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -44,10 +44,9 @@
  • Résultat du dé : {{diceResult}}
  • Total : {{finalResult}} (Marge : {{marge}})
  • - {{#if sdValue}} {{#if isSuccess}} -
  • Succés... +
  • Succès... {{#if arme}}
  • Dégats : {{degatsArme}}
  • {{/if}} @@ -57,6 +56,13 @@ {{/if}} {{/if}} + {{#if isBrelan}} +
  • Brelan sur 3 dés !
  • + {{/if}} + {{#if isSuite}} +
  • Suite sur 3 dés !
  • + {{/if}} + {{#if isCriticalSuccess}}
  • Réussite Critique !!!
  • {{#if arme}}