forked from public/foundryvtt-reve-de-dragon
Adaptation des encaissement alternatifs
Les encaissement alternatifs fonctionnent avec la validation d'encaissement par le MJ. - l'ajout de la difficulté d'attaque au dégâts est indiqué dans les bonus de dégâts - pour les minimums sur les dés d'encaissement, si le MJ remplace le jet, les minimums sont alors ignorés.
This commit is contained in:
@ -549,49 +549,54 @@ export class RdDUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async jetEncaissement(rollData, armure, options = { showDice: HIDE_DICE }) {
|
||||
let formula = "2d10";
|
||||
const diff = Math.abs(rollData.diffLibre);
|
||||
let formula = RdDUtility.formuleEncaissement(diff, options)
|
||||
const roll = await RdDDice.roll(formula, options);
|
||||
|
||||
// Chaque dé fait au minmum la difficulté libre
|
||||
if (ReglesOptionnelles.isUsing('degat-minimum-malus-libre')) {
|
||||
if (rollData.diffLibre < 0) {
|
||||
let valeurMin = Math.abs(rollData.diffLibre);
|
||||
formula += "min" + valeurMin;
|
||||
}
|
||||
}
|
||||
// Chaque dé fait au minmum la difficulté libre
|
||||
if (ReglesOptionnelles.isUsing('degat-ajout-malus-libre')) {
|
||||
if (rollData.diffLibre < 0) {
|
||||
let valeurMin = Math.abs(rollData.diffLibre);
|
||||
formula += "+" + valeurMin;
|
||||
}
|
||||
}
|
||||
|
||||
let roll = await RdDDice.roll(formula, options);
|
||||
|
||||
// 1 dé fait au minmum la difficulté libre
|
||||
if (ReglesOptionnelles.isUsing('degat-minimum-malus-libre-simple')) {
|
||||
if (rollData.diffLibre < 0) {
|
||||
let valeurMin = Math.abs(rollData.diffLibre);
|
||||
if (roll.terms[0].results[0].result < valeurMin) {
|
||||
roll.terms[0].results[0].result = valeurMin;
|
||||
} else if (roll.terms[0].results[1].result < valeurMin) {
|
||||
roll.terms[0].results[1].result = valeurMin;
|
||||
}
|
||||
roll._total = roll.terms[0].results[0].result + roll.terms[0].results[1].result;
|
||||
}
|
||||
}
|
||||
RdDUtility.remplaceDeMinParDifficulte(roll, diff, options);
|
||||
|
||||
return await RdDUtility.prepareEncaissement(rollData, roll, armure);
|
||||
}
|
||||
|
||||
static remplaceDeMinParDifficulte(roll, diff, options) {
|
||||
if (!ReglesOptionnelles.isUsing('degat-minimum-malus-libre-simple')) {
|
||||
return
|
||||
}
|
||||
// 1 dé fait au minmum la difficulté libre
|
||||
const total = options.forceDiceResult?.total;
|
||||
if (total) {
|
||||
const reste = Math.max(total - diff, 1)
|
||||
roll.terms[0].number = reste + diff
|
||||
}
|
||||
else {
|
||||
if (roll.terms[0].results[0].result < diff) {
|
||||
roll.terms[0].results[0].result = diff;
|
||||
} else if (roll.terms[0].results[1].result < diff) {
|
||||
roll.terms[0].results[1].result = diff;
|
||||
}
|
||||
roll._total = roll.terms[0].results[0].result + roll.terms[0].results[1].result;
|
||||
}
|
||||
}
|
||||
|
||||
static formuleEncaissement(diff, options) {
|
||||
// Chaque dé fait au minimum la difficulté libre
|
||||
if (ReglesOptionnelles.isUsing('degat-minimum-malus-libre')) {
|
||||
return `2d10min${diff}`
|
||||
}
|
||||
return '2d10'
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async prepareEncaissement(rollData, roll, armure) {
|
||||
const jetTotal = roll.total + rollData.dmg.total - armure;
|
||||
let encaissement = RdDUtility._selectEncaissement(jetTotal, rollData.dmg.mortalite);
|
||||
let over20 = Math.max(jetTotal - 20, 0);
|
||||
// La difficulté d'ataque s'ajoute aux dégâts
|
||||
const bonusDegatsDiffLibre = ReglesOptionnelles.isUsing('degat-ajout-malus-libre') ? Math.abs(rollData.diffLibre ?? 0) : 0
|
||||
const jetTotal = roll.total + rollData.dmg.total - armure + bonusDegatsDiffLibre
|
||||
const encaissement = RdDUtility._selectEncaissement(jetTotal, rollData.dmg.mortalite);
|
||||
const over20 = Math.max(jetTotal - 20, 0);
|
||||
encaissement.dmg = rollData.dmg;
|
||||
encaissement.dmg.loc = rollData.dmg.loc ?? await RdDUtility.getLocalisation(this.type);
|
||||
encaissement.dmg.loc.label = encaissement.dmg.loc.label ?? 'Corps;';
|
||||
encaissement.dmg.bonusDegatsDiffLibre = bonusDegatsDiffLibre
|
||||
encaissement.roll = roll;
|
||||
encaissement.armure = armure;
|
||||
encaissement.penetration = rollData.arme?.system.penetration ?? 0;
|
||||
|
Reference in New Issue
Block a user