Fix divers

This commit is contained in:
LeRatierBretonnien 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

@ -283,38 +283,32 @@ export class HeritiersUtility {
/* -------------------------------------------- */
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])) {
rollData.marge = 7
rollData.isSuccess = true
rollData.isCriticalSuccess = true
rollData.isBrelan = true
}
if ((resTab[0] + 1 == resTab[1]) && (resTab[1] + 1 == resTab[2])) {
rollData.marge = 7
rollData.isSuccess = true
rollData.isCriticalSuccess = true
rollData.isSuite = true
}
if (rollData.useTricherie) {
actor.incDecTricherie(-1)
@ -322,7 +316,21 @@ export class HeritiersUtility {
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) {
@ -346,9 +354,11 @@ 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) {
@ -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)
}

View File

@ -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",

View File

@ -36,6 +36,7 @@
"habitat": "",
"notes": "",
"statut": "",
"playernotes":"",
"gmnotes": ""
}
},

View File

@ -645,18 +645,28 @@
<div class="medium-editor item-text-long-line">
{{editor description target="system.biodata.description" button=true owner=owner editable=editable}}
</div>
<span>
<h3>Notes diverses</h3>
</span>
<div class="medium-editor item-text-long-line">
{{editor playernotes target="system.biodata.playernotes" button=true owner=owner editable=editable}}
</div>
<span>
<h3>Rêves étranges</h3>
</span>
<div class="medium-editor item-text-long-line">
{{editor revesetranges target="system.biodata.revesetranges" button=true owner=owner editable=editable}}
</div>
<span>
<h3>Secrets découverts</h3>
</span>
<div class="medium-editor item-text-long-line">
{{editor secretsdecouverts target="system.biodata.secretsdecouverts" button=true owner=owner editable=editable}}
</div>
<span>
<h3>Questions en suspens</h3>
</span>

View File

@ -44,10 +44,9 @@
<li>Résultat du dé : {{diceResult}} </li>
<li>Total : {{finalResult}} (Marge : {{marge}})</li>
{{#if sdValue}}
{{#if isSuccess}}
<li class="chat-success">Succés...
<li class="chat-success">Succès...
{{#if arme}}
<li>Dégats : {{degatsArme}}</li>
{{/if}}
@ -57,6 +56,13 @@
{{/if}}
{{/if}}
{{#if isBrelan}}
<li class="chat-success">Brelan sur 3 dés !</li>
{{/if}}
{{#if isSuite}}
<li class="chat-success">Suite sur 3 dés !</li>
{{/if}}
{{#if isCriticalSuccess}}
<li class="chat-success">Réussite Critique !!!</li>
{{#if arme}}