|
|
|
@ -101,6 +101,9 @@ export class RdDCombat {
|
|
|
|
|
'#encaisser-button',
|
|
|
|
|
'#appel-chance-defense',
|
|
|
|
|
'#appel-destinee-defense',
|
|
|
|
|
'#appel-chance-attaque',
|
|
|
|
|
'#appel-destinee-attaque',
|
|
|
|
|
'#echec-total-attaque',
|
|
|
|
|
]) {
|
|
|
|
|
html.on("click", button, event => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
@ -133,61 +136,77 @@ export class RdDCombat {
|
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
|
|
|
|
|
case '#parer-button': {
|
|
|
|
|
const armeId = event.currentTarget.attributes['data-armeid'];
|
|
|
|
|
return this.parade(attackerRoll, armeId?.value);
|
|
|
|
|
}
|
|
|
|
|
case '#parer-button': return this.parade(attackerRoll, armeParadeId);
|
|
|
|
|
case '#esquiver-button': return this.esquive(attackerRoll);
|
|
|
|
|
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(
|
|
|
|
|
() => this.rejouerDefense(defenderRoll, { chance: true }),
|
|
|
|
|
() => this.afficherOptionsDefense(attackerRoll, { chance: true }));
|
|
|
|
|
|
|
|
|
|
() => this.defenseChanceuse(attackerRoll, defenderRoll),
|
|
|
|
|
() => this.afficherOptionsDefense(attackerRoll, { defenseChance: true }));
|
|
|
|
|
case '#appel-destinee-attaque': return this.attacker.appelDestinee(
|
|
|
|
|
() => this.attaqueSignificative(attackerRoll),
|
|
|
|
|
() => { });
|
|
|
|
|
case '#appel-destinee-defense': return this.defender.appelDestinee(
|
|
|
|
|
() => this.defenseSignificative(defenderRoll),
|
|
|
|
|
() => this.afficherOptionsDefense(attackerRoll, { destinee: true }));
|
|
|
|
|
() => this.defenseDestinee(defenderRoll),
|
|
|
|
|
() => { });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_consumeDefense(passeArme) {
|
|
|
|
|
let defenderRoll = game.system.rdd.rollDataHandler.defenses[passeArme];
|
|
|
|
|
let defenderRoll = this._getDefense(passeArme);
|
|
|
|
|
game.system.rdd.rollDataHandler.defenses[passeArme] = undefined;
|
|
|
|
|
return defenderRoll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_getDefense(passeArme) {
|
|
|
|
|
return game.system.rdd.rollDataHandler.defenses[passeArme];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_storeDefense(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")
|
|
|
|
|
const attackerRoll = defenderRoll.attackerRoll;
|
|
|
|
|
attackerRoll.essais.defenseChance = true;
|
|
|
|
|
attackerRoll.essais.defense = false;
|
|
|
|
|
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
|
|
|
|
|
this.addTentatives(attackerRoll, tentatives);
|
|
|
|
|
|
|
|
|
|
if (defenderRoll.arme) {
|
|
|
|
|
this.parade(attackerRoll, defenderRoll.arme._id);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.esquive(attackerRoll);
|
|
|
|
|
}
|
|
|
|
|
this._sendMessageDefense(attackerRoll);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
afficherOptionsDefense(attackerRoll, tentatives) {
|
|
|
|
|
ui.notifications.info("La chance n'est pas avec vous")
|
|
|
|
|
this._sendMessageDefense(attackerRoll, tentatives);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defenseSignificative(defenderRoll){
|
|
|
|
|
ui.notifications.info('defense significative grâce à la destinée')
|
|
|
|
|
const attackerRoll = defenderRoll.attackerRoll;
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
defenseDestinee(defenderRoll) {
|
|
|
|
|
ui.notifications.info('Défense significative grâce à la destinée')
|
|
|
|
|
RdDResolutionTable.forceSignificative(defenderRoll.rolled);
|
|
|
|
|
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
|
|
|
|
|
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
|
|
|
|
|
if (defenderRoll.arme) {
|
|
|
|
|
this._onParadeNormale(defenderRoll);
|
|
|
|
|
}
|
|
|
|
@ -196,10 +215,18 @@ export class RdDCombat {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
afficherOptionsDefense(attackerRoll, essais) {
|
|
|
|
|
ui.notifications.info("La chance n'est pas avec vous");
|
|
|
|
|
this._sendMessageDefense(attackerRoll, essais);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
removeChatMessageActionsPasseArme(passeArme) {
|
|
|
|
|
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")){
|
|
|
|
|
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static isEchec(rollData) {
|
|
|
|
@ -269,7 +296,7 @@ export class RdDCombat {
|
|
|
|
|
competence: competence,
|
|
|
|
|
surprise: this.attacker.getSurprise(),
|
|
|
|
|
surpriseDefenseur: this.defender.getSurprise(),
|
|
|
|
|
tentatives: { chance: false, defense: false }
|
|
|
|
|
essais: { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (this.attacker.isCreature()) {
|
|
|
|
@ -287,73 +314,69 @@ export class RdDCombat {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_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>`;
|
|
|
|
|
}
|
|
|
|
|
async _onAttaqueParticuliere(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) {
|
|
|
|
|
console.log("RdDCombat.onAttaqueNormale >>>", rollData);
|
|
|
|
|
async _onAttaqueNormale(attackerRoll) {
|
|
|
|
|
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
|
|
|
|
|
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',
|
|
|
|
|
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')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.target) {
|
|
|
|
|
await this._sendMessageDefense(rollData);
|
|
|
|
|
await this._sendMessageDefense(attackerRoll);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async _sendMessageDefense(attackerRoll, tentatives = {}) {
|
|
|
|
|
console.log("RdDCombat._sendMessageDefense", attackerRoll, tentatives, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie);
|
|
|
|
|
async _sendMessageDefense(attackerRoll, essais = {}) {
|
|
|
|
|
console.log("RdDCombat._sendMessageDefense", attackerRoll, essais, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie);
|
|
|
|
|
|
|
|
|
|
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
|
|
|
|
|
|
|
|
|
|
this.addTentatives(attackerRoll, tentatives);
|
|
|
|
|
|
|
|
|
|
let message = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html`, {
|
|
|
|
|
mergeObject(attackerRoll.essais, essais, {overwrite: true});
|
|
|
|
|
const paramDemandeDefense = {
|
|
|
|
|
passeArme: attackerRoll.passeArme,
|
|
|
|
|
tentatives: attackerRoll.tentatives,
|
|
|
|
|
essais: attackerRoll.essais,
|
|
|
|
|
surprise: this.defender.getSurprise(),
|
|
|
|
|
defender: this.defender,
|
|
|
|
|
attackerId: this.attackerId,
|
|
|
|
|
defenderTokenId: this.defenderTokenId,
|
|
|
|
|
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"),
|
|
|
|
|
armes: this._filterArmesParade(this.defender.data.items, attackerRoll.competence, attackerRoll.arme),
|
|
|
|
|
diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0,
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addTentatives(attackerRoll, tentatives) {
|
|
|
|
|
mergeObject(attackerRoll.tentatives, tentatives, { overwrite: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_filterArmesParade(items, competence) {
|
|
|
|
|
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) {
|
|
|
|
|
// 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.onEchecTotal >>>", rollData);
|
|
|
|
|
let chatOptions = {
|
|
|
|
|
content: "<strong>Echec total à l'attaque!</strong> "
|
|
|
|
|
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' })
|
|
|
|
|
}
|
|
|
|
|
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
|
|
|
|
|
async _onAttaqueEchecTotal(attackerRoll) {
|
|
|
|
|
|
|
|
|
|
game.system.rdd.rollDataHandler.attaques[this.attackerId] = duplicate(attackerRoll);
|
|
|
|
|
|
|
|
|
|
// Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
|
|
|
|
|
ChatMessage.create({
|
|
|
|
|
whisper: ChatMessage.getWhisperRecipients(this.attacker.name),
|
|
|
|
|
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html', {
|
|
|
|
|
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) {
|
|
|
|
@ -393,6 +432,7 @@ export class RdDCombat {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async choixParticuliere(rollData, choix) {
|
|
|
|
|
console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
|
|
|
|
|
// TODO
|
|
|
|
|
rollData.particuliere = choix;
|
|
|
|
|
await this._onAttaqueNormale(rollData);
|
|
|
|
|
}
|
|
|
|
@ -418,7 +458,6 @@ export class RdDCombat {
|
|
|
|
|
{ condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) },
|
|
|
|
|
{ condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) },
|
|
|
|
|
{ condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) },
|
|
|
|
|
{ condition: RdDCombat.isEchecTotal, action: r => this._onParadeEchecTotal(r) },
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
dialog.render(true);
|
|
|
|
@ -473,33 +512,22 @@ export class RdDCombat {
|
|
|
|
|
async _onParadeNormale(rollData) {
|
|
|
|
|
console.log("RdDCombat._onParadeNormale >>>", rollData);
|
|
|
|
|
|
|
|
|
|
this._consumeDefense(rollData.passeArme);
|
|
|
|
|
await this.computeRecul(rollData);
|
|
|
|
|
await this.computeDeteriorationArme(rollData);
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
console.log("RdDCombat._onParadeEchec >>>", rollData);
|
|
|
|
|
|
|
|
|
|
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
|
|
|
|
|
|
|
|
|
|
this._storeDefense(rollData);
|
|
|
|
|
this.removeChatMessageActionsPasseArme(rollData.passeArme);
|
|
|
|
|
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.isParticuliere, action: r => this._onEsquiveParticuliere(r) },
|
|
|
|
|
{ condition: RdDCombat.isEchec, action: r => this._onEsquiveEchec(r) },
|
|
|
|
|
{ condition: RdDCombat.isEchecTotal, action: r => this._onEsquiveEchecTotal(r) },
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
dialog.render(true);
|
|
|
|
@ -561,30 +588,19 @@ export class RdDCombat {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async _onEsquiveNormale(rollData) {
|
|
|
|
|
console.log("RdDCombat._onEsquiveNormal >>>", rollData);
|
|
|
|
|
|
|
|
|
|
this._consumeDefense(rollData.passeArme);
|
|
|
|
|
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) {
|
|
|
|
|
console.log("RdDCombat._onEsquiveEchec >>>", rollData);
|
|
|
|
|
|
|
|
|
|
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-esquive.html');
|
|
|
|
|
|
|
|
|
|
this._storeDefense(rollData);
|
|
|
|
|
this.removeChatMessageActionsPasseArme(rollData.passeArme);
|
|
|
|
|
this._sendMessageDefense(rollData.attackerRoll, { defense: true })
|
|
|
|
|
this._storeDefense(rollData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
@ -679,11 +695,16 @@ export class RdDCombat {
|
|
|
|
|
defenderTokenId = defenderTokenId || this.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
|
|
|
|
|
attackerRoll.attackerId = this.attackerId;
|
|
|
|
|
attackerRoll.defenderTokenId = defenderTokenId;
|
|
|
|
|
|
|
|
|
|
let defenderRoll = this._consumeDefense(attackerRoll.passeArme);
|
|
|
|
|
await this.computeRecul(defenderRoll);
|
|
|
|
|
this.defender.encaisserDommages(attackerRoll, this.attacker);
|
|
|
|
|
} else { // Emit message for GM
|
|
|
|
|