`);
}
}
@@ -296,7 +301,7 @@ export class RdDCombat {
competence: competence,
surprise: this.attacker.getSurprise(),
surpriseDefenseur: this.defender.getSurprise(),
- essais: { }
+ essais: {}
};
if (this.attacker.isCreature()) {
@@ -359,7 +364,7 @@ export class RdDCombat {
console.log("RdDCombat._sendMessageDefense", attackerRoll, essais, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
- mergeObject(attackerRoll.essais, essais, {overwrite: true});
+ mergeObject(attackerRoll.essais, essais, { overwrite: true });
const paramDemandeDefense = {
passeArme: attackerRoll.passeArme,
essais: attackerRoll.essais,
@@ -417,9 +422,9 @@ export class RdDCombat {
const arme = rollData.arme;
const avecArme = arme?.data.categorie_parade != 'sans-armes';
const action = (rollData.attackerRoll ? (arme ? "la parade" : "l'esquive") : "l'attaque");
- ChatUtility.chatWithRollMode({
+ ChatUtility.createChatWithRollMode(this.defender.name, {
content: `
Echec total à ${action}! ` + await RdDRollTables.getMaladresse({ arme: avecArme })
- }, this.defender.name)
+ });
}
/* -------------------------------------------- */
@@ -489,45 +494,45 @@ export class RdDCombat {
}
/* -------------------------------------------- */
- _getDiviseurSignificative(rollData) {
- let facteurSign = (this.defender.isDemiSurprise() || rollData.needParadeSignificative) ? 2 : 1;
- if (RdDBonus.isDefenseAttaqueFinesse(rollData)) {
+ _getDiviseurSignificative(defenderRoll) {
+ let facteurSign = (this.defender.isDemiSurprise() || defenderRoll.needParadeSignificative) ? 2 : 1;
+ if (RdDBonus.isDefenseAttaqueFinesse(defenderRoll)) {
facteurSign *= 2;
}
return facteurSign;
}
/* -------------------------------------------- */
- _onParadeParticuliere(rollData) {
- console.log("RdDCombat._onParadeParticuliere >>>", rollData);
- if (!rollData.attackerRoll.isPart) {
+ _onParadeParticuliere(defenderRoll) {
+ console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
+ if (!defenderRoll.attackerRoll.isPart) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132
- ChatUtility.chatWithRollMode({
+ ChatUtility.createChatWithRollMode(this.defender.name, {
content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)`
- }, this.defender.name)
+ });
}
}
/* -------------------------------------------- */
- async _onParadeNormale(rollData) {
- console.log("RdDCombat._onParadeNormale >>>", rollData);
+ async _onParadeNormale(defenderRoll) {
+ console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
- this._consumeDefense(rollData.passeArme);
- await this.computeRecul(rollData);
- await this.computeDeteriorationArme(rollData);
+ this._consumeDefense(defenderRoll.passeArme);
+ await this.computeRecul(defenderRoll);
+ await this.computeDeteriorationArme(defenderRoll);
- await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
+ await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
}
/* -------------------------------------------- */
- async _onParadeEchec(rollData) {
- console.log("RdDCombat._onParadeEchec >>>", rollData);
+ async _onParadeEchec(defenderRoll) {
+ console.log("RdDCombat._onParadeEchec >>>", defenderRoll);
- await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
+ await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
- this.removeChatMessageActionsPasseArme(rollData.passeArme);
- this._sendMessageDefense(rollData.attackerRoll, { defense: true });
- this._storeDefense(rollData);
+ this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
+ this._sendMessageDefense(defenderRoll.attackerRoll, { defense: true });
+ this._storeDefense(defenderRoll);
}
/* -------------------------------------------- */
@@ -579,10 +584,9 @@ export class RdDCombat {
/* -------------------------------------------- */
_onEsquiveParticuliere(rollData) {
console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
- let chatOptions = {
+ ChatUtility.createChatWithRollMode(this.defender.name, {
content: "
Vous pouvez esquiver une deuxième esquive!"
- }
- ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
+ });
}
/* -------------------------------------------- */
@@ -651,11 +655,11 @@ export class RdDCombat {
}
}
/* -------------------------------------------- */
- async computeRecul(rollData) { // Calcul du recul (p. 132)
- const attaque = rollData.attackerRoll;
- if (this._isAttaqueCauseRecul(attaque)) {
+ async computeRecul(defenderRoll) { // Calcul du recul (p. 132)
+ const attackerRoll = defenderRoll.attackerRoll;
+ if (this._isAttaqueCauseRecul(attackerRoll)) {
- let impactRecul = this._computeImpactRecul(attaque);
+ let impactRecul = this._computeImpactRecul(attackerRoll);
const agilite = this.defender.isEntiteCauchemar()
? this.defender.data.data.carac.reve.value
: this.defender.data.data.carac.agilite.value;
@@ -663,13 +667,13 @@ export class RdDCombat {
let rollRecul = await RdDResolutionTable.rollData({ caracValue: 10, finalLevel: impactRecul, showDice: false });
if (rollRecul.isSuccess) {
- rollData.show.recul = 'encaisse';
+ defenderRoll.show.recul = 'encaisse';
} else if (rollRecul.isETotal) {
- rollData.show.recul = 'chute';
+ defenderRoll.show.recul = 'chute';
}
else {
let chute = await RdDResolutionTable.rollData({ caracValue: agilite, finalLevel: impactRecul, showDice: false });
- rollData.show.recul = (chute.isSuccess)
+ defenderRoll.show.recul = (chute.isSuccess)
? 'recul'
: 'chute';
}
@@ -696,7 +700,13 @@ export class RdDCombat {
console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId);
let defenderRoll = this._consumeDefense(attackerRoll.passeArme);
- if (defenderRoll && RdDCombat.isEchecTotal(defenderRoll)) {
+ if (!defenderRoll) {
+ defenderRoll = {
+ attackerRoll: attackerRoll,
+ show: {}
+ };
+ }
+ else if (RdDCombat.isEchecTotal(defenderRoll)) {
// TODO: echec total!!!
this._onEchecTotal(defenderRoll);
}
@@ -746,7 +756,6 @@ export class RdDCombat {
/* -------------------------------------------- */
static async displayActorCombatStatus(actor) {
- let rollMode = game.settings.get("core", "rollMode");
let rollData = {
alias: actor.name,
etatGeneral: actor.getEtatGeneral(),
@@ -762,8 +771,9 @@ export class RdDCombat {
} else if (actor.countBlessuresByName("graves") > 0) {
rollData.isGrave = true;
}
- let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData);
- ChatUtility.createChatMessage({ content: content }, rollMode, actor.name);
+ ChatUtility.createChatWithRollMode(actor.name, {
+ content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData)
+ });
}
/* -------------------------------------------- */
diff --git a/module/rdd-commands.js b/module/rdd-commands.js
index 6cc330de..53385113 100644
--- a/module/rdd-commands.js
+++ b/module/rdd-commands.js
@@ -69,7 +69,7 @@ export class RdDCommands {
return;
}
const term = path[0];
- fullPath = fullPath+term+' '
+ fullPath = fullPath + term + ' '
if (path.length == 1) {
command.descr = `
${fullPath}: ${command.descr}`;
targetTable[term] = command;
@@ -192,15 +192,14 @@ export class RdDCommands {
};
await RdDResolutionTable.rollData(rollData);
msg.content = await RdDResolutionTable.buildRollDataHtml(rollData);
- ChatUtility.chatWithRollMode(msg, game.user.name);
+ ChatUtility.createChatWithRollMode(game.user.name, msg);
}
async rollDeDraconique(msg) {
- let rollMode = game.settings.get("core", "rollMode");
let ddr = new DeDraconique().evaluate();
await RdDDice.show(ddr, rollMode);
msg.content = `Lancer d'un Dé draconique: ${ddr.total}`;
- ChatUtility.createChatMessage(msg, rollMode, game.user.name);
+ ChatUtility.createChatWithRollMode(game.user.name, msg);
}
}
diff --git a/module/rdd-dice.js b/module/rdd-dice.js
index e98e7241..81d41057 100644
--- a/module/rdd-dice.js
+++ b/module/rdd-dice.js
@@ -15,7 +15,7 @@ export class RdDDice {
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
let whisper = null;
let blind = false;
- rollMode = rollMode || game.settings.get("core", "rollMode");
+ rollMode = rollMode ?? game.settings.get("core", "rollMode");
switch (rollMode) {
case "blindroll": //GM only
blind = true;
diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js
index 83dff5b7..fd516b21 100644
--- a/module/rdd-resolution-table.js
+++ b/module/rdd-resolution-table.js
@@ -91,9 +91,9 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
- ChatUtility.chatWithRollMode(
- { content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template) },
- actor?.userName ?? game.user.name)
+ ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {
+ content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template)
+ });
}
/* -------------------------------------------- */
@@ -139,7 +139,7 @@ export class RdDResolutionTable {
}
}
static forceSignificative(chances) {
- chances.roll = Math.floor(chances.score /2);
+ chances.roll = Math.floor(chances.score / 2);
mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true });
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index e10e776e..7b263dff 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -98,25 +98,25 @@ const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "C
/* -------------------------------------------- */
const definitionsEncaissement = {
"mortel": [
- { minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 1, graves: 0, critiques: 0 },
- { minimum: 16, maximum: 19, endurance: "2d6", vie: "2", legeres: 0, graves: 1, critiques: 0 },
- { minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", legeres: 0, graves: 0, critiques: 1 },
+ { minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
+ { minimum: 16, maximum: 19, endurance: "2d6", vie: "2", eraflures: 0, legeres: 0, graves: 1, critiques: 0 },
+ { minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", eraflures: 0, legeres: 0, graves: 0, critiques: 1 },
],
"non-mortel": [
- { minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 16, maximum: 19, endurance: "2d6", vie: "0", legeres: 1, graves: 0, critiques: 0 },
- { minimum: 20, maximum: undefined, endurance: "100", vie: "1", legeres: 1, graves: 0, critiques: 0 },
+ { minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 16, maximum: 19, endurance: "2d6", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
+ { minimum: 20, maximum: undefined, endurance: "100", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
],
"cauchemar": [
- { minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 16, maximum: 19, endurance: "2d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
- { minimum: 20, maximum: undefined, endurance: "3d6 + @over20", vie: "0", legeres: 0, graves: 0, critiques: 0 },
+ { minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 16, maximum: 19, endurance: "2d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
+ { minimum: 20, maximum: undefined, endurance: "3d6 + @over20", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
]
};
@@ -193,6 +193,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-appelchance.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-attaque.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-encaissement.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-parade.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-esquive.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-competence.html',
@@ -260,14 +261,14 @@ export class RdDUtility {
}
/* -------------------------------------------- */
- static async processItemDropEvent( actorSheet, event) {
+ static async processItemDropEvent(actorSheet, event) {
let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
console.log(dragData, actorSheet.actor._id);
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
let objetId = dragData.id || dragData.data._id;
if ( dropID ) { // Dropped over an item !!!
- if ( actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) {
- if ( actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID) ) {
+ if (actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) {
+ if (actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID)) {
await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]);
await actorSheet.actor.ajouterAConteneur(objetId, dropID);
}
@@ -281,9 +282,9 @@ export class RdDUtility {
actorSheet.actor.computeEncombrementTotalEtMalusArmure();
return true;
}
-
+
/* -------------------------------------------- */
- static buildArbreDeConteneur( actorSheet, data ) {
+ static buildArbreDeConteneur(actorSheet, data) {
actorSheet.objetVersConteneur = {}; // Table de hash locale pour recupération rapide du conteneur parent (si existant)
// Attribution des objets aux conteneurs
for (let conteneur of data.data.conteneurs) {
@@ -551,10 +552,10 @@ export class RdDUtility {
/* -------------------------------------------- */
static _evaluatePerte(formula, over20) {
- console.log("_evaluatePerte", formula, over20)
- let perte = new Roll(formula, { over20: over20 })
- perte.evaluate()
- return perte.total
+ console.log("_evaluatePerte", formula, over20);
+ let perte = new Roll(formula, { over20: over20 });
+ perte.evaluate();
+ return perte.total;
}
/* -------------------------------------------- */
diff --git a/templates/chat-demande-defense.html b/templates/chat-demande-defense.html
index 2fdfdd8d..b3117441 100644
--- a/templates/chat-demande-defense.html
+++ b/templates/chat-demande-defense.html
@@ -2,7 +2,7 @@
{{#if (eq surprise 'totale')}}
{{defender.name}} est totalement surpris
{{else if essais.defense}}
-
{{defender.name}} doit
+
{{defender.name}} doit :
{{else}}
{{defender.name}} doit se défendre
{{#if (eq surprise 'demi')}} avec une significative {{/if}} :
@@ -12,7 +12,6 @@
{{#unless (eq surprise 'totale')}}
{{#if essais.defense}}
-
{{#unless essais.defenseChance}}
{{#if (eq defender.data.type 'personnage')}}
{{/if}}
- {{/unless}}
- {{#if (eq defender.data.type 'personnage')}}
+ {{#if (eq defender.data.type 'personnage')}}
{{#if (gt defender.data.data.compteurs.destinee.value 0)}}
Utiliser la destinée
{{/if}}
- {{/if}}
+ {{/if}}
+ {{/unless}}
{{else}}
{{#each armes as |arme key|}}
diff --git a/templates/chat-resultat-encaissement.html b/templates/chat-resultat-encaissement.html
new file mode 100644
index 00000000..8413dd3e
--- /dev/null
+++ b/templates/chat-resultat-encaissement.html
@@ -0,0 +1,42 @@
+{{#if isGM}}
+
+ {{#if (gt endurance 0)}}
+ De plus, {{alias}} a perdu {{endurance}} points d'endurance
+ {{#if (ne vie 0)}}et {{vie}} points de vie{{/if}}
+ {{/if}}
+
+{{else}}
+{{alias}} encaisse à
+
+ {{numberFormat dmg.total decimals=0 sign=true}}
+ {{#if (eq dmg.mortalite 'non-mortel')~}}(coups non mortels)
+ {{~else if (eq dmg.mortalite 'cauchemar')}}(entité de cauchemar)
+ {{~/if}}
+
+
+
+ Je d'encaissement de {{roll.total}}
+ {{#unless (eq armure 0)}}, l'armure a protègé de {{armure}} {{#unless (eq penetration 0)}}(pénétration de {{penetration}})
+ {{/unless}}
+ {{/unless}}, total:
{{total}}
+
+ {{alias}} subit
+ {{#if (gt eraflures 0)}}une contusion
+ {{else if (gt legeres 0)}}une blessure légère
+ {{else if (gt graves 0)}}une blessure grave
+ {{else if (gt critique 0)}}une blessure critique
+ {{else}}Rien du tout
+ {{/if}}
+
+ ({{dmg.loc.label}})
+ {{#if (gt endurance 0)}}
+ {{#if hasPlayerOwner}}, a perdu {{endurance}} points d'endurance
+ {{#if (ne vie 0)}},
{{vie}} points de vie{{/if}}
+ {{/if}}
+ {{#if (gt endurance 1)}}
+ et {{#if sonne}}est
sonné jusqu'à la fin du prochain round{{else}}n'est pas sonné{{/if}}
+ ({{jetEndurance}} / {{resteEndurance}})!
+ {{/if}}
+ {{/if}}
+
+{{/if}}
\ No newline at end of file