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}), secretsdecouverts: await TextEditor.enrichHTML(this.object.system.biodata.secretsdecouverts, {async: true}),
questions: await TextEditor.enrichHTML(this.object.system.biodata.questions, {async: true}), questions: await TextEditor.enrichHTML(this.object.system.biodata.questions, {async: true}),
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {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, options: this.options,
owner: this.document.isOwner, owner: this.document.isOwner,
editScore: this.options.editScore, editScore: this.options.editScore,

View File

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

View File

@ -42,12 +42,12 @@ export class HeritiersUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static sortByName(table) { static sortByName(table) {
return table.sort(function (a, b) { return table.sort(function (a, b) {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}) })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static sortArrayObjectsByName(myArray) { static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => { myArray.sort((a, b) => {
@ -269,63 +269,71 @@ export class HeritiersUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeMonnaieDetails(valueSC) { static computeMonnaieDetails(valueSC) {
let po = Math.floor(valueSC / 400) let po = Math.floor(valueSC / 400)
let pa = Math.floor((valueSC - (po*400)) / 20) let pa = Math.floor((valueSC - (po * 400)) / 20)
let sc = valueSC - (po*400) - (pa*20) let sc = valueSC - (po * 400) - (pa * 20)
return { return {
po: po, pa: pa, sc: sc, valueSC: valueSC po: po, pa: pa, sc: sc, valueSC: valueSC
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static incDecHeritage() { static incDecHeritage() {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeResult(actor, rollData) { static computeResult(actor, rollData) {
rollData.diceResult = -1 let isTricherieHeritage = rollData.useHeritage || rollData.useTricherie
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
rollData.marge = 0 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() 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.marge = 7
rollData.isSuccess = true 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.marge = 7
rollData.isSuccess = true rollData.isSuccess = true
rollData.isCriticalSuccess = true rollData.isCriticalSuccess = true
} rollData.isSuite = true
if ( rollData.useTricherie) { }
if (rollData.useTricherie) {
actor.incDecTricherie(-1) actor.incDecTricherie(-1)
} }
if ( rollData.useHeritage) { if (rollData.useHeritage) {
this.incDecHeritage() 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) //rollData.finalResult = Math.max(rollData.finalResult, 0)
//console.log("Result : ", rollData) //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.marge = rollData.finalResult - rollData.sdValue
rollData.isSuccess = (rollData.finalResult >= rollData.sdValue) rollData.isSuccess = (rollData.finalResult >= rollData.sdValue)
rollData.isCriticalSuccess = ((rollData.finalResult - rollData.sdValue) >= 7) rollData.isCriticalSuccess = ((rollData.finalResult - rollData.sdValue) >= 7)
@ -338,7 +346,7 @@ export class HeritiersUtility {
let actor = this.getActorFromRollData(rollData) 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é") ui.notifications.warn("Votre personnage est Moribond(e). Aucun jet autorisé")
return return
} }
@ -346,14 +354,16 @@ export class HeritiersUtility {
//rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp" //rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey]) rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey])
rollData.nbDice = (rollData.useTricherie || rollData.useHeritage) ? 3 : 1 if (rollData.useTricherie || rollData.useHeritage) {
rollData.diceFormula = rollData.nbDice + rollData.mainDice + "kh1" rollData.diceFormula = "{1d8, 1d10, 1d12}"
//console.log("BEFORE COMP", rollData) } else {
rollData.diceFormula = "1" + rollData.mainDice + "kh1"
}
let rangValue = 0 let rangValue = 0
if (rollData.rang) { if (rollData.rang) {
rangValue = rollData.rang.value rangValue = rollData.rang.value
} }
if (rollData.competence) { if (rollData.competence) {
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0 let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
let specBonus = (rollData.useSpecialite) ? 1 : 0 let specBonus = (rollData.useSpecialite) ? 1 : 0
@ -369,9 +379,8 @@ export class HeritiersUtility {
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll rollData.roll = myRoll
console.log(">>>> ", myRoll) console.log(">>>> ", myRoll)
rollData.finalResult = myRoll.total
this.computeResult(actor, rollData) this.computeResult(actor, rollData)
if (rollData.mode == "init") { if (rollData.mode == "init") {
actor.setFlag("world", "last-initiative", rollData.finalResult) actor.setFlag("world", "last-initiative", rollData.finalResult)
} }
@ -379,10 +388,10 @@ export class HeritiersUtility {
// Compute damages, cf p 187 // Compute damages, cf p 187
if (rollData.arme && rollData.isSuccess) { if (rollData.arme && rollData.isSuccess) {
rollData.degatsArme = rollData.arme.system.degats + rollData.marge 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 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) rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2)
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "fvtt-les-heritiers", "id": "fvtt-les-heritiers",
"description": "Les Héritiers pour FoundryVTT", "description": "Les Héritiers pour FoundryVTT",
"version": "10.0.32", "version": "10.0.33",
"authors": [ "authors": [
{ {
"name": "Uberwald/LeRatierBretonnien", "name": "Uberwald/LeRatierBretonnien",
@ -19,7 +19,7 @@
"gridUnits": "m", "gridUnits": "m",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json", "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": [ "languages": [
{ {
"lang": "fr", "lang": "fr",

View File

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

View File

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

View File

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