#86, #42, Gestion des échecs totaux et appel à la chance en combat #321

Merged
vincent.vandeme merged 1 commits from appel-chance-combat into v1.2 2021-01-07 09:21:12 +01:00
8 changed files with 205 additions and 131 deletions

View File

@ -1758,7 +1758,7 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollAppelChance( onSuccess = () => {}, onEchec= ()=>{}) async rollAppelChance(onSuccess = () => {}, onEchec = () => {})
{ {
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' }; let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
const dialog = await RdDRoll.create(this, rollData, const dialog = await RdDRoll.create(this, rollData,
@ -1768,9 +1768,7 @@ export class RdDActor extends Actor {
label: 'Appel à la chance', label: 'Appel à la chance',
callbacks: [ callbacks: [
this.createCallbackExperience(), this.createCallbackExperience(),
{ action: r => this._appelChanceResult(r) }, { action: r => this._appelChanceResult(r, onSuccess, onEchec) },
{ condition: r=> r.rolled.isSuccess, action: r => onSuccess() },
{ condition: r=> r.rolled.isEchec, action: r => onEchec() }
] ]
} }
); );
@ -1778,11 +1776,15 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _appelChanceResult(rollData) { async _appelChanceResult(rollData, onSuccess = () => {}, onEchec= ()=>{}) {
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
if (rollData.rolled.isSuccess) { if (rollData.rolled.isSuccess) {
await this.chanceActuelleIncDec(-1) await this.chanceActuelleIncDec(-1)
onSuccess();
}
else {
onEchec();
} }
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -5,8 +5,8 @@
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));
.forEach(it => it.delete()); toDelete.forEach(it => it.delete());
} }

View File

@ -101,6 +101,9 @@ export class RdDCombat {
'#encaisser-button', '#encaisser-button',
'#appel-chance-defense', '#appel-chance-defense',
'#appel-destinee-defense', '#appel-destinee-defense',
'#appel-chance-attaque',
'#appel-destinee-attaque',
'#echec-total-attaque',
]) { ]) {
html.on("click", button, event => { html.on("click", button, event => {
event.preventDefault(); event.preventDefault();
@ -133,73 +136,97 @@ export class RdDCombat {
} }
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value; const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value;
let defenderRoll = this._consumeDefense(attackerRoll.passeArme); let defenderRoll = this._getDefense(attackerRoll.passeArme);
const armeParadeId = event.currentTarget.attributes['data-armeid']?.value;
switch (button) { switch (button) {
case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value); case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
case '#parer-button': { case '#parer-button': return this.parade(attackerRoll, armeParadeId);
const armeId = event.currentTarget.attributes['data-armeid'];
return this.parade(attackerRoll, armeId?.value);
}
case '#esquiver-button': return this.esquive(attackerRoll); case '#esquiver-button': return this.esquive(attackerRoll);
case '#encaisser-button': return this.encaisser(attackerRoll, defenderTokenId); case '#encaisser-button': return this.encaisser(attackerRoll, defenderTokenId);
case '#echec-total-attaque': return this._onEchecTotal(attackerRoll);
case '#appel-chance-attaque': return this.attacker.rollAppelChance(
() => this.attaqueChanceuse(attackerRoll),
() => this._onEchecTotal(attackerRoll));
case '#appel-chance-defense': return this.defender.rollAppelChance( case '#appel-chance-defense': return this.defender.rollAppelChance(
() => this.rejouerDefense(defenderRoll, { chance: true }), () => this.defenseChanceuse(attackerRoll, defenderRoll),
() => this.afficherOptionsDefense(attackerRoll, { chance: true })); () => this.afficherOptionsDefense(attackerRoll, { defenseChance: true }));
case '#appel-destinee-attaque': return this.attacker.appelDestinee(
() => this.attaqueSignificative(attackerRoll),
() => { });
case '#appel-destinee-defense': return this.defender.appelDestinee( case '#appel-destinee-defense': return this.defender.appelDestinee(
() => this.defenseSignificative(defenderRoll), () => this.defenseDestinee(defenderRoll),
() => this.afficherOptionsDefense(attackerRoll, { destinee: true })); () => { });
} }
} }
/* -------------------------------------------- */
_consumeDefense(passeArme) { _consumeDefense(passeArme) {
let defenderRoll = game.system.rdd.rollDataHandler.defenses[passeArme]; let defenderRoll = this._getDefense(passeArme);
game.system.rdd.rollDataHandler.defenses[passeArme] = undefined; game.system.rdd.rollDataHandler.defenses[passeArme] = undefined;
return defenderRoll; return defenderRoll;
} }
/* -------------------------------------------- */
_getDefense(passeArme) {
return game.system.rdd.rollDataHandler.defenses[passeArme];
}
/* -------------------------------------------- */
_storeDefense(defenderRoll) { _storeDefense(defenderRoll) {
game.system.rdd.rollDataHandler.defenses[defenderRoll.passeArme] = defenderRoll; game.system.rdd.rollDataHandler.defenses[defenderRoll.passeArme] = defenderRoll;
} }
rejouerDefense(defenderRoll, tentatives) { /* -------------------------------------------- */
attaqueChanceuse(attackerRoll) {
ui.notifications.info("L'attaque est rejouée grâce à la chance")
attackerRoll.essais.attaqueChance = true;
this.attaque(attackerRoll, attackerRoll.arme);
}
/* -------------------------------------------- */
attaqueDestinee(attackerRoll) {
ui.notifications.info('Attaque significative grâce à la destinée')
RdDResolutionTable.forceSignificative(attackerRoll.rolled);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
this._onAttaqueNormale(attackerRoll);
}
/* -------------------------------------------- */
defenseChanceuse(attackerRoll, defenderRoll) {
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")
const attackerRoll = defenderRoll.attackerRoll; attackerRoll.essais.defenseChance = true;
attackerRoll.essais.defense = false;
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
this.addTentatives(attackerRoll, tentatives); this._sendMessageDefense(attackerRoll);
if (defenderRoll.arme) {
this.parade(attackerRoll, defenderRoll.arme._id);
}
else{
this.esquive(attackerRoll);
}
} }
afficherOptionsDefense(attackerRoll, tentatives) { /* -------------------------------------------- */
ui.notifications.info("La chance n'est pas avec vous") defenseDestinee(defenderRoll) {
this._sendMessageDefense(attackerRoll, tentatives); ui.notifications.info('Défense significative grâce à la destinée')
}
defenseSignificative(defenderRoll){
ui.notifications.info('defense significative grâce à la destinée')
const attackerRoll = defenderRoll.attackerRoll;
RdDResolutionTable.forceSignificative(defenderRoll.rolled); RdDResolutionTable.forceSignificative(defenderRoll.rolled);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
if (defenderRoll.arme) { if (defenderRoll.arme) {
this._onParadeNormale(defenderRoll); this._onParadeNormale(defenderRoll);
} }
else{ else {
this._onEsquiveNormale(defenderRoll); this._onEsquiveNormale(defenderRoll);
} }
} }
/* -------------------------------------------- */
afficherOptionsDefense(attackerRoll, essais) {
ui.notifications.info("La chance n'est pas avec vous");
this._sendMessageDefense(attackerRoll, essais);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
removeChatMessageActionsPasseArme(passeArme) { removeChatMessageActionsPasseArme(passeArme) {
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")){
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`); ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
} }
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static isEchec(rollData) { static isEchec(rollData) {
@ -269,7 +296,7 @@ export class RdDCombat {
competence: competence, competence: competence,
surprise: this.attacker.getSurprise(), surprise: this.attacker.getSurprise(),
surpriseDefenseur: this.defender.getSurprise(), surpriseDefenseur: this.defender.getSurprise(),
tentatives: { chance: false, defense: false } essais: { }
}; };
if (this.attacker.isCreature()) { if (this.attacker.isCreature()) {
@ -287,73 +314,69 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_onAttaqueParticuliere(rollData) { async _onAttaqueParticuliere(rollData) {
console.log("RdDCombat.onAttaqueParticuliere >>>", rollData);
// Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
let message = '<h4 class="rdd-roll-part"><strong>Réussite particulière en attaque</strong></h4>';
message += `<br><a class='chat-card-button' id='particuliere-attaque' data-mode='force' data-attackerId='${this.attackerId}'>Attaquer en Force</a>`;
if (rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0) {
if (rollData.arme.data.rapide) {
message += `<br><a class='chat-card-button' id='particuliere-attaque' data-mode='rapidite' data-attackerId='${this.attackerId}'>Attaquer en Rapidité</a>`;
}
message += `<br><a class='chat-card-button' id='particuliere-attaque' data-mode='finesse' data-attackerId='${this.attackerId}'>Attaquer en Finesse</a>`;
}
game.system.rdd.rollDataHandler.attaques[this.attackerId] = duplicate(rollData); game.system.rdd.rollDataHandler.attaques[this.attackerId] = duplicate(rollData);
// TODO: use a dialog?
ChatMessage.create({ content: message, whisper: ChatMessage.getWhisperRecipients(this.attacker.name) }); // Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
const isMeleeDiffNegative = rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0;
ChatMessage.create({
whisper: ChatMessage.getWhisperRecipients(this.attacker.name),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', {
attackerId: this.attackerId,
defenderTokenId: this.defenderTokenId,
isFinesse: isMeleeDiffNegative,
isRapide: isMeleeDiffNegative && rollData.arme.data.rapide
})
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueNormale(rollData) { async _onAttaqueNormale(attackerRoll) {
console.log("RdDCombat.onAttaqueNormale >>>", rollData); console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
rollData.dmg = RdDBonus.dmg(rollData, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar());
// Save rollData for defender // Save rollData for defender
game.system.rdd.rollDataHandler.attaques[this.attackerId] = duplicate(rollData); game.system.rdd.rollDataHandler.attaques[this.attackerId] = duplicate(attackerRoll);
rollData.show = { attackerRoll.show = {
cible: this.target ? this.defender.data.name : 'la cible', cible: this.target ? this.defender.data.name : 'la cible',
isRecul: (rollData.particuliere == 'force' || rollData.tactique == 'charge') isRecul: (attackerRoll.particuliere == 'force' || attackerRoll.tactique == 'charge')
} }
await RdDResolutionTable.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.html'); await RdDResolutionTable.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.html');
if (!await this.accorderEntite('avant-defense')) { if (!await this.accorderEntite('avant-defense')) {
return; return;
} }
if (this.target) { if (this.target) {
await this._sendMessageDefense(rollData); await this._sendMessageDefense(attackerRoll);
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _sendMessageDefense(attackerRoll, tentatives = {}) { async _sendMessageDefense(attackerRoll, essais = {}) {
console.log("RdDCombat._sendMessageDefense", attackerRoll, tentatives, " / ", 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});
this.addTentatives(attackerRoll, tentatives); const paramDemandeDefense = {
let message = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html`, {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
tentatives: attackerRoll.tentatives, essais: attackerRoll.essais,
surprise: this.defender.getSurprise(), surprise: this.defender.getSurprise(),
defender: this.defender, defender: this.defender,
attackerId: this.attackerId, attackerId: this.attackerId,
defenderTokenId: this.defenderTokenId, defenderTokenId: this.defenderTokenId,
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"), mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"),
armes: this._filterArmesParade(this.defender.data.items, attackerRoll.competence, attackerRoll.arme), armes: this._filterArmesParade(this.defender.data.items, attackerRoll.competence, attackerRoll.arme),
diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0,
dmg: attackerRoll.dmg dmg: attackerRoll.dmg
}); };
let message = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', paramDemandeDefense);
RdDCombat._sendRollMessage(this.attacker, this.defender, this.defenderTokenId, "msg_defense", message, attackerRoll); RdDCombat._sendRollMessage(this.attacker, this.defender, this.defenderTokenId, "msg_defense", message, attackerRoll);
} }
addTentatives(attackerRoll, tentatives) {
mergeObject(attackerRoll.tentatives, tentatives, { overwrite: true });
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_filterArmesParade(items, competence) { _filterArmesParade(items, competence) {
items = items.filter(item => (item.type == 'arme' && item.data.equipe) || (item.type == 'competencecreature' && item.data.isparade)); items = items.filter(item => (item.type == 'arme' && item.data.equipe) || (item.type == 'competencecreature' && item.data.isparade));
@ -371,17 +394,33 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueEchecTotal(rollData) { async _onAttaqueEchecTotal(attackerRoll) {
// TODO: remplacer par un chat message pour laisser le joueur choisir un appel à la chance _avant_
// https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/-/issues/85 game.system.rdd.rollDataHandler.attaques[this.attackerId] = duplicate(attackerRoll);
console.log("RdDCombat.onEchecTotal >>>", rollData);
let chatOptions = { // Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
content: "<strong>Echec total à l'attaque!</strong> " ChatMessage.create({
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' }) whisper: ChatMessage.getWhisperRecipients(this.attacker.name),
} content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html', {
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name) attackerId: this.attackerId,
attacker: this.attacker,
defenderTokenId: this.defenderTokenId,
essais: attackerRoll.essais
})
});
} }
/* -------------------------------------------- */
async _onEchecTotal(rollData) {
console.log("RdDCombat._onEchecTotal >>>", rollData);
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({
content: `<strong>Echec total à ${action}!</strong> ` + await RdDRollTables.getMaladresse({ arme: avecArme })
}, this.defender.name)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueEchec(rollData) { async _onAttaqueEchec(rollData) {
@ -393,6 +432,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async choixParticuliere(rollData, choix) { async choixParticuliere(rollData, choix) {
console.log("RdDCombat.choixParticuliere >>>", rollData, choix); console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
// TODO
rollData.particuliere = choix; rollData.particuliere = choix;
await this._onAttaqueNormale(rollData); await this._onAttaqueNormale(rollData);
} }
@ -418,7 +458,6 @@ export class RdDCombat {
{ condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) }, { condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) }, { condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) }, { condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) },
{ condition: RdDCombat.isEchecTotal, action: r => this._onParadeEchecTotal(r) },
] ]
}); });
dialog.render(true); dialog.render(true);
@ -473,33 +512,22 @@ export class RdDCombat {
async _onParadeNormale(rollData) { async _onParadeNormale(rollData) {
console.log("RdDCombat._onParadeNormale >>>", rollData); console.log("RdDCombat._onParadeNormale >>>", rollData);
this._consumeDefense(rollData.passeArme);
await this.computeRecul(rollData); await this.computeRecul(rollData);
await this.computeDeteriorationArme(rollData); await this.computeDeteriorationArme(rollData);
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html'); await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
} }
/* -------------------------------------------- */
async _onParadeEchecTotal(rollData) {
// TODO: remplacer par un chat message pour laisser le joueur choisir un appel à la chance _avant_
// https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/-/issues/85
console.log("RdDCombat._onParadeEchecTotal >>>", rollData);
let chatOptions = {
content: "<strong>Echec total à la parade!</strong> "
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' })
}
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onParadeEchec(rollData) { async _onParadeEchec(rollData) {
console.log("RdDCombat._onParadeEchec >>>", rollData); console.log("RdDCombat._onParadeEchec >>>", rollData);
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html'); await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
this._storeDefense(rollData);
this.removeChatMessageActionsPasseArme(rollData.passeArme); this.removeChatMessageActionsPasseArme(rollData.passeArme);
this._sendMessageDefense(rollData.attackerRoll, { defense: true }); this._sendMessageDefense(rollData.attackerRoll, { defense: true });
this._storeDefense(rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -522,7 +550,6 @@ export class RdDCombat {
{ condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) }, { condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) }, { condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onEsquiveEchec(r) }, { condition: RdDCombat.isEchec, action: r => this._onEsquiveEchec(r) },
{ condition: RdDCombat.isEchecTotal, action: r => this._onEsquiveEchecTotal(r) },
] ]
}); });
dialog.render(true); dialog.render(true);
@ -561,30 +588,19 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onEsquiveNormale(rollData) { async _onEsquiveNormale(rollData) {
console.log("RdDCombat._onEsquiveNormal >>>", rollData); console.log("RdDCombat._onEsquiveNormal >>>", rollData);
this._consumeDefense(rollData.passeArme);
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-esquive.html'); await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-esquive.html');
} }
/* -------------------------------------------- */
async _onEsquiveEchecTotal(rollData) {
// TODO: remplacer par un chat message pour laisser le joueur choisir un appel à la chance _avant_
// https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/-/issues/85
console.log("RdDCombat._onEsquiveEchecTotal >>>", rollData);
let chatOptions = {
content: "<strong>Echec total à l'esquive!</strong> "
+ await RdDRollTables.getMaladresse({ arme: false })
}
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onEsquiveEchec(rollData) { async _onEsquiveEchec(rollData) {
console.log("RdDCombat._onEsquiveEchec >>>", rollData); console.log("RdDCombat._onEsquiveEchec >>>", rollData);
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-esquive.html'); await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-esquive.html');
this._storeDefense(rollData);
this.removeChatMessageActionsPasseArme(rollData.passeArme); this.removeChatMessageActionsPasseArme(rollData.passeArme);
this._sendMessageDefense(rollData.attackerRoll, { defense: true }) this._sendMessageDefense(rollData.attackerRoll, { defense: true })
this._storeDefense(rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -679,11 +695,16 @@ export class RdDCombat {
defenderTokenId = defenderTokenId || this.defenderTokenId; defenderTokenId = defenderTokenId || this.defenderTokenId;
console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId); console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId);
let defenderRoll = this._consumeDefense(attackerRoll.passeArme);
if (defenderRoll && RdDCombat.isEchecTotal(defenderRoll)) {
// TODO: echec total!!!
this._onEchecTotal(defenderRoll);
}
if (game.user.isGM) { // Current user is the GM -> direct access if (game.user.isGM) { // Current user is the GM -> direct access
attackerRoll.attackerId = this.attackerId; attackerRoll.attackerId = this.attackerId;
attackerRoll.defenderTokenId = defenderTokenId; attackerRoll.defenderTokenId = defenderTokenId;
let defenderRoll = this._consumeDefense(attackerRoll.passeArme);
await this.computeRecul(defenderRoll); await this.computeRecul(defenderRoll);
this.defender.encaisserDommages(attackerRoll, this.attacker); this.defender.encaisserDommages(attackerRoll, this.attacker);
} else { // Emit message for GM } else { // Emit message for GM

View File

@ -161,6 +161,16 @@ Hooks.once("init", async function() {
type: Boolean type: Boolean
}); });
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat", {
name: "Supprimer les dialogues de combat",
hint: "Si désactivée, tous les dialogues de combat sont conservés dans la conversation",
scope: "world",
config: true,
default: true,
type: Boolean
});
//game.settings.get("<systemName>","<settingName>") to retrieve it and game.settings.set("<systemName>","<settingName>", <newValue>) //game.settings.get("<systemName>","<settingName>") to retrieve it and game.settings.set("<systemName>","<settingName>", <newValue>)
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -205,6 +205,8 @@ export class RdDUtility {
// messages tchat // messages tchat
'systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-particuliere.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-parade.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-parade.html',

View File

@ -0,0 +1,22 @@
<div data-passearme="{{passeArme}}">
<h4 class="rdd-roll-part"><strong>Echec total en attaque</strong></h4>
<br>
{{#if (eq attacker.data.type 'personnage')}}
{{#unless essais.attaqueChance}}
<a class='chat-card-button' id='appel-chance-attaque' data-attackerId='{{attackerId}}'
data-defenderTokenId='{{defenderTokenId}}'>Faire appel à la chance</a>
</a>
<br>
{{/unless}}
{{#if (gt attacker.data.data.compteurs.destinee.value 0)}}
<a class='chat-card-button' id='appel-destinee-attaque' data-attackerId='{{attackerId}}'
data-defenderTokenId='{{defenderTokenId}}'>Utiliser la destinée</a>
</a>
<br>
{{/if}}
{{/if}}
<a class='chat-card-button' id='echec-total-attaque' data-attackerId='{{attackerId}}'
data-defenderTokenId='{{defenderTokenId}}'>
Tirer l'échec total !
</a>
</div>

View File

@ -0,0 +1,19 @@
<div data-passearme="{{passeArme}}">
<h4 class="rdd-roll-part"><strong>Réussite particulière en attaque</strong></h4>
<br>
<a class="chat-card-button" id="particuliere-attaque" data-mode="force" data-attackerId="{{attackerId}}">
Attaquer en Force
</a>
{{#if isRapide}}
<br>
<a class="chat-card-button" id="particuliere-attaque" data-mode="rapidite" data-attackerId="{{attackerId}}">
Attaquer en Rapidité
</a>
{{/if}}
{{#if isFinesse}}
<br>
<a class="chat-card-button" id="particuliere-attaque" data-mode="finesse" data-attackerId="{{attackerId}}">
Attaquer en Finesse
</a>
{{/if}}
</div>

View File

@ -1,7 +1,7 @@
<div data-passearme="{{passeArme}}"> <div data-passearme="{{passeArme}}">
{{#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 tentatives.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
@ -11,9 +11,9 @@
<span class='chat-card-button-area'> <span class='chat-card-button-area'>
<br> <br>
{{#unless (eq surprise 'totale')}} {{#unless (eq surprise 'totale')}}
{{#if tentatives.defense}} {{#if essais.defense}}
<br> <br>
{{#unless tentatives.chance}} {{#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}}'
data-defenderTokenId='{{defenderTokenId}}'>Faire appel à la chance</a> data-defenderTokenId='{{defenderTokenId}}'>Faire appel à la chance</a>
@ -31,22 +31,20 @@
{{/if}} {{/if}}
{{else}} {{else}}
{{#each armes as |arme key|}} {{#each armes as |arme key|}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' <a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>
data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>Parer avec {{arme.name}} Parer avec {{arme.name}} à {{../diffLibre }}
</a> </a>
<br> <br>
{{/each}} {{/each}}
{{#if mainsNues}} {{#if mainsNues}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' <a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
data-defenderTokenId='{{defenderTokenId}}'> Parer à mains nues à {{diffLibre}}
Parer à mains nues
</a> </a>
<br> <br>
{{/if}} {{/if}}
{{#if (ne attaqueCategorie 'tir')}} {{#if (ne attaqueCategorie 'tir')}}
<a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' <a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
data-defenderTokenId='{{defenderTokenId}}'> Esquiver à {{diffLibre}}
Esquiver
</a> </a>
<br> <br>
{{/if}} {{/if}}