Add charmes/tours management

This commit is contained in:
2023-11-29 22:04:17 +01:00
parent 06d0d9b24d
commit 3e394734ce
63 changed files with 334 additions and 252 deletions

View File

@@ -2,6 +2,20 @@
import { WastelandCombat } from "./wasteland-combat.js";
import { WastelandCommands } from "./wasteland-commands.js";
/* -------------------------------------------- */
const __contrecouptCharme = {
1 : {name: "Effet chromatique", description: "" },
3 : {name: "Enivrement Kobold", description: "" },
5 : {name: "Mutisme superstitieux", description: "" },
7 : {name: "Agité!", description: "" },
9 : {name: "Somnolence", description: "" },
11 : {name: "Manie incontrôlable", description: "" },
13 : {name: "Malédiction des Ternes", description: "" },
15 : {name: "La petite Mort", description: "" },
17 : {name: "Angoisse cauchemardesque", description: "" },
19 : {name: "Anémie Kobold", description: "" }
}
/* -------------------------------------------- */
export class WastelandUtility {
@@ -279,25 +293,44 @@ export class WastelandUtility {
/* -------------------------------------------- */
static computeResult(rollData) {
if (rollData.mainDice == "1d20") {
let diceValue = rollData.roll.terms[0].results[0].result
diceValue *= (rollData.doubleD20) ? 2 : 1
//console.log("PAIR/IMP", diceValue)
if (diceValue % 2 == 1) {
//console.log("PAIR/IMP2", diceValue)
rollData.finalResult -= rollData.roll.terms[0].results[0].result // Substract value
if (diceValue == 1 || diceValue == 11) {
rollData.isDramatique = true
rollData.isSuccess = false
if (rollData.charme) {
let resultIndex = false
let resTab = duplicate(rollData.charme.system.resultats)
for(let id in resTab) {
let res = resTab[id]
if (!resultIndex && rollData.finalResult >= res.value) {
resultIndex = id;
}
}
}
//console.log("Result : ", rollData)
if (rollData.difficulte > 0 && !rollData.isDramatique) {
rollData.isSuccess = (rollData.finalResult >= rollData.difficulte)
rollData.isHeroique = ((rollData.finalResult - rollData.difficulte) >= 10)
rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10)
if (resultIndex) {
rollData.charmeDuree = rollData.charme.system.resultats[resultIndex].description
}
let effectRoll = new Roll(rollData.charmeDice).roll({ async: false })
rollData.contrecoupResult = effectRoll.total
if (rollData.contrecoupResult % 2 == 1) {
rollData.contrecoup = __contrecouptCharme[rollData.contrecoupResult]
}
} else {
if (rollData.mainDice == "1d20") {
let diceValue = rollData.roll.terms[0].results[0].result
diceValue *= (rollData.doubleD20) ? 2 : 1
//console.log("PAIR/IMP", diceValue)
if (diceValue % 2 == 1) {
//console.log("PAIR/IMP2", diceValue)
rollData.finalResult -= rollData.roll.terms[0].results[0].result // Substract value
if (diceValue == 1 || diceValue == 11) {
rollData.isDramatique = true
rollData.isSuccess = false
}
}
}
//console.log("Result : ", rollData)
if (rollData.difficulte > 0 && !rollData.isDramatique) {
rollData.isSuccess = (rollData.finalResult >= rollData.difficulte)
rollData.isHeroique = ((rollData.finalResult - rollData.difficulte) >= 10)
rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10)
}
}
}
@@ -313,13 +346,18 @@ export class WastelandUtility {
rollData.attr = duplicate(actor.system.attributs[rollData.attrKey])
}
rollData.diceFormula = rollData.mainDice
if (rollData.doubleD20) { // Multiply result !
rollData.diceFormula += "*2"
if (!rollData.isReroll) {
actor.changeEclat(-1)
}
if (rollData.charme) {
rollData.diceFormula = rollData.charmeDice
} else {
rollData.diceFormula = rollData.mainDice
if (rollData.doubleD20) { // Multiply result !
rollData.diceFormula += "*2"
if (!rollData.isReroll) {
actor.changeEclat(-1)
}
}
}
//console.log("BEFORE COMP", rollData)
if (rollData.competence) {
rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => !pred.used) || [])
@@ -328,21 +366,10 @@ export class WastelandUtility {
} else {
rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}`
}
if (rollData.arme && rollData.arme.type == "arme") {
rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}`
}
if (rollData.rune) {
rollData.runeduree = Math.ceil((rollData.runeame + 3) / 3)
if (rollData.runemode == "inscrire") {
rollData.runeduree *= 2
}
if (rollData.runemode == "prononcer") {
rollData.runeduree = 1
}
}
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = duplicate(myRoll)
@@ -352,14 +379,6 @@ export class WastelandUtility {
rollData.finalResult = myRoll.total
this.computeResult(rollData)
if (rollData.rune) {
let subAme = rollData.runeame
if (rollData.isEchec && !rollData.isDramatique) {
subAme = Math.ceil((subAme + 1) / 2)
}
actor.subPointsAme(rollData.runemode, subAme)
}
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-wasteland/templates/chat-generic-result.html`, rollData)
}, rollData)