v12.0.9 - Le scriptorium d'Astrobazzarh #711

Merged
uberwald merged 13 commits from VincentVk/foundryvtt-reve-de-dragon:v11 into v11 2024-09-27 10:16:54 +02:00
4 changed files with 41 additions and 38 deletions
Showing only changes of commit 538cf5bdbf - Show all commits

View File

@ -33,12 +33,12 @@ export class RdDItemArme extends Item {
return RdDItemArme.mainsNues(); return RdDItemArme.mainsNues();
} }
static getCompetenceArme(arme, competenceName) { static getCompetenceArme(arme, maniement) {
switch (arme.type) { switch (arme.type) {
case ITEM_TYPES.competencecreature: case ITEM_TYPES.competencecreature:
return arme.name return arme.name
case ITEM_TYPES.arme: case ITEM_TYPES.arme:
switch (competenceName) { switch (maniement) {
case 'competence': return arme.system.competence; case 'competence': return arme.system.competence;
case 'unemain': return RdDItemArme.competence1Mains(arme); case 'unemain': return RdDItemArme.competence1Mains(arme);
case 'deuxmains': return RdDItemArme.competence2Mains(arme); case 'deuxmains': return RdDItemArme.competence2Mains(arme);
@ -148,30 +148,32 @@ export class RdDItemArme extends Item {
return true; return true;
} }
/* -------------------------------------------- */ static dommagesReels(arme, maniement) {
static armeUneOuDeuxMains(armeData, aUneMain) { switch (maniement) {
if (armeData && !armeData.system.cac) { case 'tir':
armeData.system.unemain = armeData.system.unemain || !armeData.system.deuxmains; case 'lancer':
const uneOuDeuxMains = armeData.system.unemain && armeData.system.deuxmains; case 'competence':
const containsSlash = !Number.isInteger(armeData.system.dommages) && armeData.system.dommages.includes("/"); return Number(arme.system.dommages)
if (containsSlash) { // Sanity check
armeData = foundry.utils.duplicate(armeData);
const tableauDegats = armeData.system.dommages.split("/");
if (aUneMain)
armeData.system.dommagesReels = Number(tableauDegats[0]);
else // 2 mains
armeData.system.dommagesReels = Number(tableauDegats[1]);
}
else {
armeData.system.dommagesReels = Number(armeData.system.dommages);
}
if (uneOuDeuxMains != containsSlash) {
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + armeData.name + " ne sont pas corrects (ie sous la forme X/Y)");
}
} }
return armeData; if (arme.system.unemain && arme.system.deuxmains) {
const containsSlash = !Number.isInteger(arme.system.dommages) && arme.system.dommages.includes("/")
if (!containsSlash) {
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
return Number(arme.system.dommages)
}
const tableauDegats = arme.system.dommages.split("/");
return Number(tableauDegats[maniement == 'unemain' ? 0 : 1])
}
return Number(arme.system.dommages);
}
/* -------------------------------------------- */
static armeUneOuDeuxMains(arme, aUneMain) {
if (arme && !arme.system.cac) {
arme = foundry.utils.duplicate(arme);
arme.system.dommagesReels = RdDItemArme.dommagesReels(arme, aUneMain ? 'unemain' : 'deuxmains')
}
return arme;
} }
static competence1Mains(arme) { static competence1Mains(arme) {
@ -197,7 +199,7 @@ export class RdDItemArme extends Item {
static corpsACorps(actor) { static corpsACorps(actor) {
let competence = actor?.getCompetenceCorpsACorps() ?? { system: { niveau: -6 } }; let competence = actor?.getCompetenceCorpsACorps() ?? { system: { niveau: -6 } };
let melee = actor? actor.system.carac['melee'].value : 0 let melee = actor ? actor.system.carac['melee'].value : 0
return { return {
_id: competence?.id, _id: competence?.id,
name: 'Corps à corps', name: 'Corps à corps',

View File

@ -31,8 +31,8 @@ export class RdDBonus {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static dmg(rollData, dmgActor, isEntiteIncarnee = false) { static dmg(rollData, actor, isEntiteIncarnee = false) {
const dmgArme = RdDBonus._dmgArme(rollData) const dmgArme = RdDBonus.dmgArme(rollData.arme)
let dmg = { let dmg = {
total: 0, total: 0,
dmgArme: dmgArme, dmgArme: dmgArme,
@ -41,7 +41,7 @@ export class RdDBonus {
dmgParticuliere: RdDBonus._dmgParticuliere(rollData), dmgParticuliere: RdDBonus._dmgParticuliere(rollData),
dmgSurprise: RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used), dmgSurprise: RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used),
mortalite: RdDBonus._calculMortalite(rollData, isEntiteIncarnee), mortalite: RdDBonus._calculMortalite(rollData, isEntiteIncarnee),
dmgActor: RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac?.label, dmgArme) dmgActor: RdDBonus.bonusDmg(actor, rollData.selectedCarac?.label.toLowerCase(), dmgArme)
} }
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere; dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere;
return dmg; return dmg;
@ -71,11 +71,11 @@ export class RdDBonus {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _dmgArme(rollData) { static dmgArme(arme) {
if (rollData.arme) { if (arme) {
let dmgBase = rollData.arme.system.dommagesReels ?? Number(rollData.arme.system.dommages ?? 0); let dmgBase = arme.system.dommagesReels ?? Number(arme.system.dommages ?? 0);
//Le bonus dégats magiques ne peut pas faire dépasser le bonus de l'arme (cf p.278) //Le bonus dégats magiques ne peut pas faire dépasser le bonus de l'arme (cf p.278)
return dmgBase + Math.min(dmgBase, rollData.arme.system.magique ? rollData.arme.system.ecaille_efficacite : 0); return dmgBase + Math.min(dmgBase, arme.system.magique ? arme.system.ecaille_efficacite : 0);
} }
return 0; return 0;
} }
@ -86,13 +86,14 @@ export class RdDBonus {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _dmgPerso(dmgActor, categorie, dmgArme) { static bonusDmg(actor, categorie, dmgArme) {
const dmgActor = actor.getBonusDegat()
if (categorie == undefined) { if (categorie == undefined) {
return 0 return 0
} }
switch (categorie) { switch (categorie) {
case "Tir": return 0; case "tir": return 0;
case "Lancer": return Math.max(0, Math.min(dmgArme, dmgActor)); case "lancer": return Math.max(0, Math.min(dmgArme, dmgActor));
} }
return dmgActor; return dmgActor;
} }

View File

@ -864,7 +864,7 @@ export class RdDCombat {
async _onAttaqueNormale(attackerRoll) { async _onAttaqueNormale(attackerRoll) {
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntite()); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite());
let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} } let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} }
attackerRoll.show = { attackerRoll.show = {
cible: this.target ? this.defender.name : 'la cible', cible: this.target ? this.defender.name : 'la cible',

View File

@ -307,7 +307,7 @@ export class RdDRoll extends Dialog {
async updateRollResult(html) { async updateRollResult(html) {
const rollData = this.rollData; const rollData = this.rollData;
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat()) rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor)
rollData.caracValue = parseInt(rollData.selectedCarac.value) rollData.caracValue = parseInt(rollData.selectedCarac.value)
rollData.dmg.mortalite = rollData.dmg.mortalite ?? 'mortel'; rollData.dmg.mortalite = rollData.dmg.mortalite ?? 'mortel';
rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac); rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac);