2021-01-05 18:43:13 +01:00
|
|
|
import { RdDCarac } from "./rdd-carac.js";
|
2020-12-16 23:02:15 +01:00
|
|
|
|
|
|
|
const conditionsTactiques = [
|
|
|
|
{ type: '', descr: '', dmg: 0, attaque: 0, parade: 0, esquive: true },
|
|
|
|
{ type: 'charge', descr: 'Charge', dmg: 2, attaque: 4, parade: -4, esquive: false },
|
|
|
|
{ type: 'feinte', descr: 'Feinte', dmg: 1, attaque: 1, parade: 0, esquive: true },
|
|
|
|
{ type: 'pret', descr: 'prêt', dmg: 0, attaque: 0, parade: 0, esquive: true },
|
|
|
|
{ type: 'demi', descr: 'Demi-surprise', dmg: 1, attaque: 0, parade: 0, esquive: true },
|
|
|
|
{ type: 'totale', descr: 'Surprise totale', dmg: 10, attaque: 6, parade: 0, esquive: true },
|
|
|
|
];
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
export class RdDBonus {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-01-01 03:25:48 +01:00
|
|
|
static find(condition) {
|
2020-12-16 23:02:15 +01:00
|
|
|
return conditionsTactiques.find(e => e.type == condition) || conditionsTactiques.find(e => e.type == 'pret');
|
|
|
|
}
|
|
|
|
|
2021-01-06 16:24:05 +01:00
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
static isAjustementAstrologique(rollData) {
|
|
|
|
return RdDCarac.isChance(rollData.selectedCarac) ||
|
|
|
|
rollData.selectedSort?.data.isrituel;
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static isDefenseAttaqueFinesse(rollData) {
|
|
|
|
return rollData.attackerRoll?.particuliere == 'finesse';
|
|
|
|
}
|
2021-01-06 16:24:05 +01:00
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static dmg(rollData, dmgActor, isCauchemar = false) {
|
2021-01-06 16:24:05 +01:00
|
|
|
let dmg = { total: 0 };
|
2020-12-16 23:02:15 +01:00
|
|
|
if (rollData.arme && rollData.arme.name.toLowerCase() == "esquive") {
|
|
|
|
// Specific case management
|
2021-01-29 20:10:43 +01:00
|
|
|
ui.notifications.warn("Calcul de bonus dégats sur esquive !");
|
2020-12-16 23:02:15 +01:00
|
|
|
} else {
|
|
|
|
dmg.dmgArme = RdDBonus._dmgArme(rollData);
|
2021-01-01 03:25:48 +01:00
|
|
|
dmg.penetration = RdDBonus._peneration(rollData);
|
2021-01-13 03:42:13 +01:00
|
|
|
dmg.dmgTactique = RdDBonus.dmgBonus(rollData.tactique);
|
2020-12-16 23:02:15 +01:00
|
|
|
dmg.dmgParticuliere = RdDBonus._dmgParticuliere(rollData);
|
2021-01-13 03:42:13 +01:00
|
|
|
dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used);
|
2020-12-16 23:02:15 +01:00
|
|
|
dmg.dmgActor = rollData.selectedCarac ? RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac.label, dmg.dmgArme) : 0;
|
|
|
|
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere;
|
|
|
|
dmg.mortalite = RdDBonus._calculMortalite(rollData, isCauchemar)
|
|
|
|
}
|
|
|
|
return dmg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static description(condition) {
|
2021-01-01 03:25:48 +01:00
|
|
|
return RdDBonus.find(condition).descr;
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static dmgBonus(condition) {
|
2021-01-01 03:25:48 +01:00
|
|
|
return RdDBonus.find(condition).dmg;
|
2021-01-06 16:24:05 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static bonusAttaque(condition) {
|
2021-01-01 03:25:48 +01:00
|
|
|
return RdDBonus.find(condition).attaque;
|
2021-01-06 16:24:05 +01:00
|
|
|
}
|
2021-01-05 18:43:13 +01:00
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static _calculMortalite(rollData, isCauchemar) {
|
2021-01-06 16:24:05 +01:00
|
|
|
if (isCauchemar) {
|
2020-12-16 23:02:15 +01:00
|
|
|
return "cauchemar";
|
|
|
|
}
|
2021-01-07 00:40:56 +01:00
|
|
|
return isCauchemar ? "cauchemar"
|
2021-01-06 16:24:05 +01:00
|
|
|
: rollData.dmg?.mortalite
|
|
|
|
?? rollData.arme?.data.mortalite
|
|
|
|
?? "mortel";
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
2021-01-06 16:24:05 +01:00
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static _dmgArme(rollData) {
|
2021-01-29 20:10:43 +01:00
|
|
|
let dmg1 = 0;
|
|
|
|
if ( rollData.arme) {
|
|
|
|
dmg1 = rollData.arme.data.dommagesReels ?? Number(rollData.arme.data.dommages ?? 0);
|
|
|
|
dmg1 += (rollData.arme.data.magique) ? rollData.arme.data.ecaille_efficacite : 0;
|
|
|
|
}
|
|
|
|
return dmg1;
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
2021-01-01 03:25:48 +01:00
|
|
|
|
2021-01-29 20:10:43 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-01 03:25:48 +01:00
|
|
|
static _peneration(rollData) {
|
2021-01-04 14:10:21 +01:00
|
|
|
return parseInt(rollData.arme?.data.penetration ?? 0);
|
2021-01-01 03:25:48 +01:00
|
|
|
}
|
2021-01-06 16:24:05 +01:00
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static _dmgPerso(dmgActor, categorie, dmgArme) {
|
|
|
|
switch (categorie) {
|
|
|
|
case "Tir": return 0;
|
|
|
|
case "Lancer": return Math.max(0, Math.min(dmgArme, dmgActor));
|
|
|
|
}
|
|
|
|
return dmgActor;
|
|
|
|
}
|
2021-01-06 16:24:05 +01:00
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static _dmgParticuliere(rollData) {
|
2021-01-03 16:58:11 +01:00
|
|
|
return rollData.particuliere == 'force' ? 5 : 0;
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|