Add dice selection

This commit is contained in:
LeRatierBretonnien 2023-01-26 20:50:56 +01:00
parent 727db74545
commit 05f09aa3f5
3 changed files with 107 additions and 13 deletions

View File

@ -576,8 +576,10 @@ export class BoLRoll {
if (rollData.weapon && rollData.weapon.system.properties.onlymodifier) {
rollbase = 0
}
let diceData = BoLUtility.getDiceData()
const modifiers = rollbase + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus + rollData.effectModifier
const formula = (isMalus) ? rollData.nbDice + "d6kl2 + " + modifiers : rollData.nbDice + "d6kh2 + " + modifiers
const formula = (isMalus) ? rollData.nbDice + "d" + diceData.diceFormula + "kl2 + " + modifiers : rollData.nbDice + "d" + diceData.diceFormula + "kh2 + " + modifiers
rollData.formula = formula
rollData.modifiers = modifiers
@ -620,20 +622,20 @@ export class BoLDefaultRoll {
const r = new Roll(this.rollData.formula)
//console.log("Roll formula", this.rollData.formula)
await r.roll({ "async": false })
let diceData = BoLUtility.getDiceData()
console.log("DICEDATA", diceData)
const activeDice = r.terms[0].results.filter(r => r.active)
const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b)
this.rollData.roll = r
this.rollData.isSuccess = (r.total >= 9)
this.rollData.isCritical = (diceTotal === 12)
this.rollData.isRealCritical = (diceTotal === 12)
this.rollData.isHeroic = (diceTotal === 12)
this.rollData.isSuccess = (r.total >= diceData.successValue)
this.rollData.isCritical = (diceTotal >= diceData.criticalSuccessValue)
this.rollData.isRealCritical = (diceTotal >= diceData.criticalSuccessValue)
this.rollData.isHeroic = (diceTotal >= diceData.criticalSuccessValue)
this.rollData.isLegendary = false
this.rollData.isFumble = (diceTotal === 2)
this.rollData.isFumble = (diceTotal <= diceData.criticalFailureValue)
this.rollData.isFailure = !this.rollData.isSuccess
//this.rollData.isRealCritical = true
//this.rollData.isFumble = true
let actor = BoLUtility.getActorFromRollData(this.rollData)
if (this.rollData.reroll == undefined) {
this.rollData.reroll = actor.heroReroll()
@ -684,12 +686,15 @@ export class BoLDefaultRoll {
/* -------------------------------------------- */
upgradeToLegendary() {
// Force to Critical roll
let diceData = BoLUtility.getDiceData()
let maxValue = Number(diceData.diceFormula) * 2
this.rollData.isCritical = true
this.rollData.isLegendary = true
this.rollData.isRealCritical = false
this.rollData.isSuccess = true
this.rollData.isFailure = false
this.rollData.roll = new Roll("12+" + this.rollData.modifiers)
this.rollData.roll = new Roll(maxValue + "+" + this.rollData.modifiers)
this.rollData.reroll = false
this.sendChatMessage()
}
@ -697,13 +702,16 @@ export class BoLDefaultRoll {
/* -------------------------------------------- */
upgradeToHeroic() {
// Force to Critical roll
let diceData = BoLUtility.getDiceData()
let maxValue = Number(diceData.diceFormula) * 2
this.rollData.isCritical = true
this.rollData.isHeroic = true
this.rollData.isLegendary = false
this.rollData.isRealCritical = false
this.rollData.isSuccess = true
this.rollData.isFailure = false
this.rollData.roll = new Roll("12+" + this.rollData.modifiers)
this.rollData.roll = new Roll(maxValue + "+" + this.rollData.modifiers)
this.rollData.reroll = false
this.sendChatMessage()
}

View File

@ -28,6 +28,66 @@ export class BoLUtility {
type: Boolean,
onChange: lang => window.location.reload()
})
game.settings.register("bol", "dice-formula", {
name: "Formule de dés",
hint: "Sélectionne la formule de dés (par défaut 2d6)",
scope: "world",
config: true,
default: "2d6",
type: String,
choices: { "6": "2d6", "8":"2d8", "10":"2d10", "12":"2d12", "20":"2d20"},
onChange: value => {
BoLUtility.setDiceFormula(value)
}
})
game.settings.register("bol", "dice-success-value", {
name: "Seuil de succès",
hint: "Sélectionne le seuil de succès (9 par défaut pour 2d6)",
scope: "world",
config: true,
default: 9,
range: {
min: 2,
max: 40,
step: 1
},
type: Number,
onChange: value => {
BoLUtility.setSuccessValue(value)
}
})
game.settings.register("bol", "dice-critical-success-value", {
name: "Valeur min de réussite critique",
hint: "Indique le seuil minimum de réussite critique (12 par défaut pour 2d6). Si les réussites critiques sont sur 19 et 20, alors indiquez 19.",
scope: "world",
config: true,
default: 12,
range: {
min: 2,
max: 40,
step: 1
},
type: Number,
onChange: value => {
BoLUtility.setCriticalSuccessValue(value)
}
})
game.settings.register("bol", "dice-critical-failure-value", {
name: "Valeur max d'échec critique",
hint: "Indique le seuil maximum d'échec critique (2 par défaut pour 2d6). Si les échecs critiques sont sur 2 et 3, alors indiquez 3.",
scope: "world",
config: true,
default: 2,
range: {
min: 2,
max: 40,
step: 1
},
type: Number,
onChange: value => {
BoLUtility.setCriticalFailureValue(value)
}
})
game.settings.register("world", "character-summary-data", {
name: "character-summary-data",
scope: "world",
@ -65,8 +125,34 @@ export class BoLUtility {
this.useBougette = game.settings.get("bol", "useBougette") // Use optionnal bougette rules
this.actorSheetLogo = game.settings.get("bol", "logoActorSheet") || "/systems/bol/ui/logo.webp"
this.logoTopLeft = game.settings.get("bol", "logoTopLeft") || "/systems/bol/ui/logo2.webp"
this.diceFormula = game.settings.get("bol", "dice-formula")
this.successValue = Number(game.settings.get("bol", "dice-success-value"))
this.criticalSuccessValue = Number(game.settings.get("bol", "dice-critical-success-value"))
this.criticalFailureValue = Number(game.settings.get("bol", "dice-critical-failure-value"))
}
/* -------------------------------------------- */
static setDiceFormula(value) {
this.diceFormula = value
}
static setSuccessValue(value) {
this.successValue = Number(value)
}
static setCriticalSuccessValue(value) {
this.criticalSuccessValue = Number(value)
}
static setCriticalFailureValue(value) {
this.criticalFailureValue = Number(value)
}
static getDiceData() {
return {
diceFormula: this.diceFormula,
successValue : this.successValue,
criticalSuccessValue: this.criticalSuccessValue,
criticalFailureValue: this.criticalFailureValue
}
}
/* -------------------------------------------- */
static getRollArmor() {
return this.rollArmor

View File

@ -14,7 +14,7 @@
],
"url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt",
"version": "10.5.2",
"version": "10.5.3",
"compatibility": {
"minimum": "10",
"verified": "10"
@ -202,7 +202,7 @@
],
"socket": true,
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.2.zip",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.3.zip",
"background": "systems/bol/ui/page_accueil.webp",
"gridDistance": 1.5,
"gridUnits": "m",