|
|
@ -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,61 +136,77 @@ 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -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) {
|
|
|
|
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
|
|
|
|