2021-01-05 18:43:13 +01:00
|
|
|
import { RdDCarac } from "./rdd-carac.js";
|
2023-06-14 01:48:32 +02:00
|
|
|
import { RdDPossession } from "./rdd-possession.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) ||
|
2022-06-12 12:14:55 +02:00
|
|
|
rollData.selectedSort?.system.isrituel;
|
2021-01-05 18:43:13 +01:00
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static isDefenseAttaqueFinesse(rollData) {
|
2023-04-21 18:18:20 +02:00
|
|
|
if (rollData.isEmpoignade && rollData.rolled?.isPart) {
|
|
|
|
return true
|
|
|
|
}
|
2023-06-14 01:48:32 +02:00
|
|
|
if (RdDPossession.isDefensePossession(rollData)) {
|
|
|
|
return RdDPossession.isPossessionFinesse(rollData)
|
|
|
|
}
|
2021-01-05 18:43:13 +01:00
|
|
|
return rollData.attackerRoll?.particuliere == 'finesse';
|
|
|
|
}
|
2021-01-06 16:24:05 +01:00
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2023-03-14 02:38:21 +01:00
|
|
|
static dmg(rollData, dmgActor, isEntiteIncarnee = false) {
|
2023-11-21 16:03:26 +01:00
|
|
|
const dmgArme = RdDBonus._dmgArme(rollData)
|
|
|
|
let dmg = {
|
|
|
|
total: 0,
|
|
|
|
dmgArme: dmgArme,
|
|
|
|
penetration: RdDBonus._peneration(rollData),
|
|
|
|
dmgTactique: RdDBonus.dmgBonus(rollData.tactique),
|
|
|
|
dmgParticuliere: RdDBonus._dmgParticuliere(rollData),
|
|
|
|
dmgSurprise: RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used),
|
|
|
|
mortalite: RdDBonus._calculMortalite(rollData, isEntiteIncarnee),
|
|
|
|
dmgActor: RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac?.label, dmgArme)
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
2023-11-21 16:03:26 +01:00
|
|
|
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere;
|
2020-12-16 23:02:15 +01:00
|
|
|
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
|
|
|
/* -------------------------------------------- */
|
2023-03-14 02:38:21 +01:00
|
|
|
static _calculMortalite(rollData, isEntiteIncarnee) {
|
|
|
|
return isEntiteIncarnee ? "entiteincarnee"
|
2021-01-06 16:24:05 +01:00
|
|
|
: rollData.dmg?.mortalite
|
2022-06-12 12:14:55 +02:00
|
|
|
?? rollData.arme?.system.mortalite
|
2021-01-06 16:24:05 +01:00
|
|
|
?? "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) {
|
2023-06-14 01:48:32 +02:00
|
|
|
if (rollData.arme) {
|
2022-06-12 12:14:55 +02:00
|
|
|
let dmgBase = rollData.arme.system.dommagesReels ?? Number(rollData.arme.system.dommages ?? 0);
|
2021-02-04 01:03:47 +01:00
|
|
|
//Le bonus dégats magiques ne peut pas faire dépasser le bonus de l'arme (cf p.278)
|
2022-06-12 12:14:55 +02:00
|
|
|
return dmgBase + Math.min(dmgBase, rollData.arme.system.magique ? rollData.arme.system.ecaille_efficacite : 0);
|
2021-01-29 20:10:43 +01:00
|
|
|
}
|
2021-02-04 01:03:47 +01:00
|
|
|
return 0;
|
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) {
|
2022-06-12 12:14:55 +02:00
|
|
|
return parseInt(rollData.arme?.system.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) {
|
2023-11-21 16:03:26 +01:00
|
|
|
if (categorie == undefined) {
|
|
|
|
return 0
|
|
|
|
}
|
2020-12-16 23:02:15 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|