Merge branch 'amelioration-encaissement' into 'v1.2'

#100 Amélioration messages encaissement

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!109
This commit is contained in:
Leratier Bretonnien 2021-01-09 20:27:33 +00:00
commit 0290b182ca
9 changed files with 928 additions and 885 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,21 +3,20 @@
* Class providing helper methods to get the list of users, and * Class providing helper methods to get the list of users, and
*/ */
export class ChatUtility { export class ChatUtility {
/* -------------------------------------------- */
static removeMyChatMessageContaining(part) { static removeMyChatMessageContaining(part) {
const toDelete = game.messages.filter(it => it.user._id == game.user._id) const toDelete = game.messages.filter(it => it.user._id == game.user._id)
.filter(it => it.data.content.includes(part)); .filter(it => it.data.content.includes(part));
toDelete.forEach(it => it.delete()); toDelete.forEach(it => it.delete());
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static chatWithRollMode(chatOptions, name) { static createChatWithRollMode(name, chatOptions) {
let rollMode = game.settings.get("core", "rollMode"); ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
ChatUtility.createChatMessage(chatOptions, rollMode, name);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static createChatMessage(chatOptions, rollMode, name) { static createChatMessage(name, rollMode, chatOptions) {
switch (rollMode) { switch (rollMode) {
case "blindroll": // GM only case "blindroll": // GM only
if (!game.user.isGM) { if (!game.user.isGM) {

View File

@ -136,7 +136,6 @@ export class RdDCombat {
} }
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value; const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value;
let defenderRoll = this._getDefense(attackerRoll.passeArme);
const armeParadeId = event.currentTarget.attributes['data-armeid']?.value; const armeParadeId = event.currentTarget.attributes['data-armeid']?.value;
switch (button) { switch (button) {
@ -150,13 +149,13 @@ export class RdDCombat {
() => this.attaqueChanceuse(attackerRoll), () => this.attaqueChanceuse(attackerRoll),
() => this._onEchecTotal(attackerRoll)); () => this._onEchecTotal(attackerRoll));
case '#appel-chance-defense': return this.defender.rollAppelChance( case '#appel-chance-defense': return this.defender.rollAppelChance(
() => this.defenseChanceuse(attackerRoll, defenderRoll), () => this.defenseChanceuse(attackerRoll),
() => this.afficherOptionsDefense(attackerRoll, { defenseChance: true })); () => this.afficherOptionsDefense(attackerRoll, { defenseChance: true }));
case '#appel-destinee-attaque': return this.attacker.appelDestinee( case '#appel-destinee-attaque': return this.attacker.appelDestinee(
() => this.attaqueSignificative(attackerRoll), () => this.attaqueSignificative(attackerRoll),
() => { }); () => { });
case '#appel-destinee-defense': return this.defender.appelDestinee( case '#appel-destinee-defense': return this.defender.appelDestinee(
() => this.defenseDestinee(defenderRoll), () => this.defenseDestinee(attackerRoll),
() => { }); () => { });
} }
} }
@ -194,7 +193,7 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
defenseChanceuse(attackerRoll, defenderRoll) { defenseChanceuse(attackerRoll) {
ui.notifications.info("La défense est rejouée grâce à la chance") ui.notifications.info("La défense est rejouée grâce à la chance")
attackerRoll.essais.defenseChance = true; attackerRoll.essais.defenseChance = true;
attackerRoll.essais.defense = false; attackerRoll.essais.defense = false;
@ -203,15 +202,21 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
defenseDestinee(defenderRoll) { defenseDestinee(attackerRoll) {
ui.notifications.info('Défense significative grâce à la destinée') let defenderRoll = this._getDefense(attackerRoll.passeArme);
RdDResolutionTable.forceSignificative(defenderRoll.rolled); if (defenderRoll) {
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); ui.notifications.info('Défense significative grâce à la destinée')
if (defenderRoll.arme) { RdDResolutionTable.forceSignificative(defenderRoll.rolled);
this._onParadeNormale(defenderRoll); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
if (defenderRoll.arme) {
this._onParadeNormale(defenderRoll);
}
else {
this._onEsquiveNormale(defenderRoll);
}
} }
else { else {
this._onEsquiveNormale(defenderRoll); ui.notifications.warn("Appel à la destinée impossible, la passe d'armes est déjà terminée!")
} }
} }
@ -223,7 +228,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
removeChatMessageActionsPasseArme(passeArme) { removeChatMessageActionsPasseArme(passeArme) {
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")){ if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`); ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
} }
} }
@ -296,7 +301,7 @@ export class RdDCombat {
competence: competence, competence: competence,
surprise: this.attacker.getSurprise(), surprise: this.attacker.getSurprise(),
surpriseDefenseur: this.defender.getSurprise(), surpriseDefenseur: this.defender.getSurprise(),
essais: { } essais: {}
}; };
if (this.attacker.isCreature()) { 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); console.log("RdDCombat._sendMessageDefense", attackerRoll, essais, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
mergeObject(attackerRoll.essais, essais, {overwrite: true}); mergeObject(attackerRoll.essais, essais, { overwrite: true });
const paramDemandeDefense = { const paramDemandeDefense = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
essais: attackerRoll.essais, essais: attackerRoll.essais,
@ -417,9 +422,9 @@ export class RdDCombat {
const arme = rollData.arme; const arme = rollData.arme;
const avecArme = arme?.data.categorie_parade != 'sans-armes'; const avecArme = arme?.data.categorie_parade != 'sans-armes';
const action = (rollData.attackerRoll ? (arme ? "la parade" : "l'esquive") : "l'attaque"); const action = (rollData.attackerRoll ? (arme ? "la parade" : "l'esquive") : "l'attaque");
ChatUtility.chatWithRollMode({ ChatUtility.createChatWithRollMode(this.defender.name, {
content: `<strong>Echec total à ${action}!</strong> ` + await RdDRollTables.getMaladresse({ arme: avecArme }) content: `<strong>Echec total à ${action}!</strong> ` + await RdDRollTables.getMaladresse({ arme: avecArme })
}, this.defender.name) });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -489,45 +494,45 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_getDiviseurSignificative(rollData) { _getDiviseurSignificative(defenderRoll) {
let facteurSign = (this.defender.isDemiSurprise() || rollData.needParadeSignificative) ? 2 : 1; let facteurSign = (this.defender.isDemiSurprise() || defenderRoll.needParadeSignificative) ? 2 : 1;
if (RdDBonus.isDefenseAttaqueFinesse(rollData)) { if (RdDBonus.isDefenseAttaqueFinesse(defenderRoll)) {
facteurSign *= 2; facteurSign *= 2;
} }
return facteurSign; return facteurSign;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_onParadeParticuliere(rollData) { _onParadeParticuliere(defenderRoll) {
console.log("RdDCombat._onParadeParticuliere >>>", rollData); console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
if (!rollData.attackerRoll.isPart) { if (!defenderRoll.attackerRoll.isPart) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132 // 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)` content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)`
}, this.defender.name) });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onParadeNormale(rollData) { async _onParadeNormale(defenderRoll) {
console.log("RdDCombat._onParadeNormale >>>", rollData); console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
this._consumeDefense(rollData.passeArme); this._consumeDefense(defenderRoll.passeArme);
await this.computeRecul(rollData); await this.computeRecul(defenderRoll);
await this.computeDeteriorationArme(rollData); 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) { async _onParadeEchec(defenderRoll) {
console.log("RdDCombat._onParadeEchec >>>", rollData); 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.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(rollData.attackerRoll, { defense: true }); this._sendMessageDefense(defenderRoll.attackerRoll, { defense: true });
this._storeDefense(rollData); this._storeDefense(defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -579,10 +584,9 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
_onEsquiveParticuliere(rollData) { _onEsquiveParticuliere(rollData) {
console.log("RdDCombat._onEsquiveParticuliere >>>", rollData); console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
let chatOptions = { ChatUtility.createChatWithRollMode(this.defender.name, {
content: "<strong>Vous pouvez esquiver une deuxième esquive!</strong>" content: "<strong>Vous pouvez esquiver une deuxième esquive!</strong>"
} });
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -651,11 +655,11 @@ export class RdDCombat {
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async computeRecul(rollData) { // Calcul du recul (p. 132) async computeRecul(defenderRoll) { // Calcul du recul (p. 132)
const attaque = rollData.attackerRoll; const attackerRoll = defenderRoll.attackerRoll;
if (this._isAttaqueCauseRecul(attaque)) { if (this._isAttaqueCauseRecul(attackerRoll)) {
let impactRecul = this._computeImpactRecul(attaque); let impactRecul = this._computeImpactRecul(attackerRoll);
const agilite = this.defender.isEntiteCauchemar() const agilite = this.defender.isEntiteCauchemar()
? this.defender.data.data.carac.reve.value ? this.defender.data.data.carac.reve.value
: this.defender.data.data.carac.agilite.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 }); let rollRecul = await RdDResolutionTable.rollData({ caracValue: 10, finalLevel: impactRecul, showDice: false });
if (rollRecul.isSuccess) { if (rollRecul.isSuccess) {
rollData.show.recul = 'encaisse'; defenderRoll.show.recul = 'encaisse';
} else if (rollRecul.isETotal) { } else if (rollRecul.isETotal) {
rollData.show.recul = 'chute'; defenderRoll.show.recul = 'chute';
} }
else { else {
let chute = await RdDResolutionTable.rollData({ caracValue: agilite, finalLevel: impactRecul, showDice: false }); let chute = await RdDResolutionTable.rollData({ caracValue: agilite, finalLevel: impactRecul, showDice: false });
rollData.show.recul = (chute.isSuccess) defenderRoll.show.recul = (chute.isSuccess)
? 'recul' ? 'recul'
: 'chute'; : 'chute';
} }
@ -696,7 +700,13 @@ export class RdDCombat {
console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId); console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId);
let defenderRoll = this._consumeDefense(attackerRoll.passeArme); 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!!! // TODO: echec total!!!
this._onEchecTotal(defenderRoll); this._onEchecTotal(defenderRoll);
} }
@ -746,7 +756,6 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async displayActorCombatStatus(actor) { static async displayActorCombatStatus(actor) {
let rollMode = game.settings.get("core", "rollMode");
let rollData = { let rollData = {
alias: actor.name, alias: actor.name,
etatGeneral: actor.getEtatGeneral(), etatGeneral: actor.getEtatGeneral(),
@ -762,8 +771,9 @@ export class RdDCombat {
} else if (actor.countBlessuresByName("graves") > 0) { } else if (actor.countBlessuresByName("graves") > 0) {
rollData.isGrave = true; rollData.isGrave = true;
} }
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData); ChatUtility.createChatWithRollMode(actor.name, {
ChatUtility.createChatMessage({ content: content }, rollMode, actor.name); content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData)
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -69,7 +69,7 @@ export class RdDCommands {
return; return;
} }
const term = path[0]; const term = path[0];
fullPath = fullPath+term+' ' fullPath = fullPath + term + ' '
if (path.length == 1) { if (path.length == 1) {
command.descr = `<strong>${fullPath}</strong>: ${command.descr}`; command.descr = `<strong>${fullPath}</strong>: ${command.descr}`;
targetTable[term] = command; targetTable[term] = command;
@ -192,15 +192,14 @@ export class RdDCommands {
}; };
await RdDResolutionTable.rollData(rollData); await RdDResolutionTable.rollData(rollData);
msg.content = await RdDResolutionTable.buildRollDataHtml(rollData); msg.content = await RdDResolutionTable.buildRollDataHtml(rollData);
ChatUtility.chatWithRollMode(msg, game.user.name); ChatUtility.createChatWithRollMode(game.user.name, msg);
} }
async rollDeDraconique(msg) { async rollDeDraconique(msg) {
let rollMode = game.settings.get("core", "rollMode");
let ddr = new DeDraconique().evaluate(); let ddr = new DeDraconique().evaluate();
await RdDDice.show(ddr, rollMode); await RdDDice.show(ddr, rollMode);
msg.content = `Lancer d'un Dé draconique: ${ddr.total}`; msg.content = `Lancer d'un Dé draconique: ${ddr.total}`;
ChatUtility.createChatMessage(msg, rollMode, game.user.name); ChatUtility.createChatWithRollMode(game.user.name, msg);
} }
} }

View File

@ -15,7 +15,7 @@ export class RdDDice {
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) { if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
let whisper = null; let whisper = null;
let blind = false; let blind = false;
rollMode = rollMode || game.settings.get("core", "rollMode"); rollMode = rollMode ?? game.settings.get("core", "rollMode");
switch (rollMode) { switch (rollMode) {
case "blindroll": //GM only case "blindroll": //GM only
blind = true; blind = true;

View File

@ -91,9 +91,9 @@ export class RdDResolutionTable {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') { static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
ChatUtility.chatWithRollMode( ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {
{ content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template) }, content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template)
actor?.userName ?? game.user.name) });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -139,7 +139,7 @@ export class RdDResolutionTable {
} }
} }
static forceSignificative(chances) { 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 }); mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true });
} }

View File

@ -98,25 +98,25 @@ const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "C
/* -------------------------------------------- */ /* -------------------------------------------- */
const definitionsEncaissement = { const definitionsEncaissement = {
"mortel": [ "mortel": [
{ minimum: undefined, maximum: 0, endurance: "0", 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", 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", legeres: 1, 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", legeres: 0, graves: 1, 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", legeres: 0, graves: 0, critiques: 1 }, { minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", eraflures: 0, legeres: 0, graves: 0, critiques: 1 },
], ],
"non-mortel": [ "non-mortel": [
{ minimum: undefined, maximum: 0, endurance: "0", 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", 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", 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", legeres: 1, 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: "1", legeres: 1, graves: 0, critiques: 0 }, { minimum: 20, maximum: undefined, endurance: "100", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
], ],
"cauchemar": [ "cauchemar": [
{ minimum: undefined, maximum: 0, endurance: "0", 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", 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", 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", 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", 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-demande-attaque-etotal.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-appelchance.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-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-parade.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-esquive.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-esquive.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-competence.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")); let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
console.log(dragData, actorSheet.actor._id); console.log(dragData, actorSheet.actor._id);
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
let objetId = dragData.id || dragData.data._id; let objetId = dragData.id || dragData.data._id;
if ( dropID ) { // Dropped over an item !!! if ( dropID ) { // Dropped over an item !!!
if ( actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) { if (actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) {
if ( actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID) ) { if (actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID)) {
await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]); await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]);
await actorSheet.actor.ajouterAConteneur(objetId, dropID); await actorSheet.actor.ajouterAConteneur(objetId, dropID);
} }
@ -281,9 +282,9 @@ export class RdDUtility {
actorSheet.actor.computeEncombrementTotalEtMalusArmure(); actorSheet.actor.computeEncombrementTotalEtMalusArmure();
return true; 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) actorSheet.objetVersConteneur = {}; // Table de hash locale pour recupération rapide du conteneur parent (si existant)
// Attribution des objets aux conteneurs // Attribution des objets aux conteneurs
for (let conteneur of data.data.conteneurs) { for (let conteneur of data.data.conteneurs) {
@ -551,10 +552,10 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _evaluatePerte(formula, over20) { static _evaluatePerte(formula, over20) {
console.log("_evaluatePerte", formula, over20) console.log("_evaluatePerte", formula, over20);
let perte = new Roll(formula, { over20: over20 }) let perte = new Roll(formula, { over20: over20 });
perte.evaluate() perte.evaluate();
return perte.total return perte.total;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -2,7 +2,7 @@
{{#if (eq surprise 'totale')}} {{#if (eq surprise 'totale')}}
<span><strong>{{defender.name}}</strong> est totalement surpris</span> <span><strong>{{defender.name}}</strong> est totalement surpris</span>
{{else if essais.defense}} {{else if essais.defense}}
<span><strong>{{defender.name}}</strong> doit</span> <span><strong>{{defender.name}}</strong> doit :</span>
{{else}} {{else}}
<span><strong>{{defender.name}}</strong> doit se défendre <span><strong>{{defender.name}}</strong> doit se défendre
{{#if (eq surprise 'demi')}} avec une significative {{/if}} : {{#if (eq surprise 'demi')}} avec une significative {{/if}} :
@ -12,7 +12,6 @@
<br> <br>
{{#unless (eq surprise 'totale')}} {{#unless (eq surprise 'totale')}}
{{#if essais.defense}} {{#if essais.defense}}
<br>
{{#unless essais.defenseChance}} {{#unless essais.defenseChance}}
{{#if (eq defender.data.type 'personnage')}} {{#if (eq defender.data.type 'personnage')}}
<a class='chat-card-button' id='appel-chance-defense' data-attackerId='{{attackerId}}' <a class='chat-card-button' id='appel-chance-defense' data-attackerId='{{attackerId}}'
@ -20,15 +19,15 @@
</a> </a>
<br> <br>
{{/if}} {{/if}}
{{/unless}} {{#if (eq defender.data.type 'personnage')}}
{{#if (eq defender.data.type 'personnage')}}
{{#if (gt defender.data.data.compteurs.destinee.value 0)}} {{#if (gt defender.data.data.compteurs.destinee.value 0)}}
<a class='chat-card-button' id='appel-destinee-defense' data-attackerId='{{attackerId}}' <a class='chat-card-button' id='appel-destinee-defense' data-attackerId='{{attackerId}}'
data-defenderTokenId='{{defenderTokenId}}'>Utiliser la destinée</a> data-defenderTokenId='{{defenderTokenId}}'>Utiliser la destinée</a>
</a> </a>
<br> <br>
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/unless}}
{{else}} {{else}}
{{#each armes as |arme key|}} {{#each armes as |arme key|}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'> <a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>

View File

@ -0,0 +1,42 @@
{{#if isGM}}
<span>
{{#if (gt endurance 0)}}
De plus, {{alias}} a perdu {{endurance}} points d'endurance
{{#if (ne vie 0)}}et <span class="rdd-roll-echec">{{vie}} points de vie</span>{{/if}}
{{/if}}
</span>
{{else}}
<h4>{{alias}} encaisse à
<span>
{{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}}
</span>
</h4>
<div>
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: <span class="rdd-roll-echec">{{total}}</span>
<br>
{{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)}}, <span class="rdd-roll-echec">{{vie}} points de vie</span>{{/if}}
{{/if}}
{{#if (gt endurance 1)}}
et {{#if sonne}}est <strong>sonné</strong><img class="chat-icon" src="icons/svg/stoned.svg" alt="charge" height="16" width="16" /> jusqu'à la fin du prochain round{{else}}n'est pas sonné{{/if}}
({{jetEndurance}} / {{resteEndurance}})!
{{/if}}
{{/if}}
</div>
{{/if}}