Gestion particulières et Echecs totaux
This commit is contained in:
parent
afa4b25acb
commit
cff1818a37
@ -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: '' };
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
@ -1768,21 +1768,23 @@ export class RdDActor extends Actor {
|
||||
label: 'Appel à la chance',
|
||||
callbacks: [
|
||||
this.createCallbackExperience(),
|
||||
{ action: r => this._appelChanceResult(r) },
|
||||
{ condition: r=> r.rolled.isSuccess, action: r => onSuccess() },
|
||||
{ condition: r=> r.rolled.isEchec, action: r => onEchec() }
|
||||
{ action: r => this._appelChanceResult(r, onSuccess, onEchec) },
|
||||
]
|
||||
}
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _appelChanceResult(rollData) {
|
||||
if (rollData.rolled.isSuccess) {
|
||||
await this.chanceActuelleIncDec(-1)
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _appelChanceResult(rollData, onSuccess = () => {}, onEchec= ()=>{}) {
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||
if (rollData.rolled.isSuccess) {
|
||||
await this.chanceActuelleIncDec(-1)
|
||||
onSuccess();
|
||||
}
|
||||
else {
|
||||
onEchec();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -5,8 +5,8 @@
|
||||
export class ChatUtility {
|
||||
static removeMyChatMessageContaining(part) {
|
||||
const toDelete = game.messages.filter(it => it.user._id == game.user._id)
|
||||
.filter(it => it.data.content.includes(part))
|
||||
.forEach(it => it.delete());
|
||||
.filter(it => it.data.content.includes(part));
|
||||
toDelete.forEach(it => it.delete());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,72 +136,96 @@ 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 }));
|
||||
|
||||
case '#appel-destinee-defense': return this.defender.appelDestinee(
|
||||
() => this.defenseSignificative(defenderRoll),
|
||||
() => this.afficherOptionsDefense(attackerRoll, { destinee: 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.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);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this._onEsquiveNormale(defenderRoll);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
afficherOptionsDefense(attackerRoll, essais) {
|
||||
ui.notifications.info("La chance n'est pas avec vous");
|
||||
this._sendMessageDefense(attackerRoll, essais);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
removeChatMessageActionsPasseArme(passeArme) {
|
||||
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
|
||||
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")){
|
||||
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -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
|
||||
|
@ -161,6 +161,16 @@ Hooks.once("init", async function() {
|
||||
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>)
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -205,6 +205,8 @@ export class RdDUtility {
|
||||
// messages tchat
|
||||
'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-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-attaque.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-parade.html',
|
||||
|
22
templates/chat-demande-attaque-etotal.html
Normal file
22
templates/chat-demande-attaque-etotal.html
Normal 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>
|
19
templates/chat-demande-attaque-particuliere.html
Normal file
19
templates/chat-demande-attaque-particuliere.html
Normal 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>
|
@ -1,7 +1,7 @@
|
||||
<div data-passearme="{{passeArme}}">
|
||||
{{#if (eq surprise 'totale')}}
|
||||
<span><strong>{{defender.name}}</strong> est totalement surpris</span>
|
||||
{{else if tentatives.defense}}
|
||||
{{else if essais.defense}}
|
||||
<span><strong>{{defender.name}}</strong> doit</span>
|
||||
{{else}}
|
||||
<span><strong>{{defender.name}}</strong> doit se défendre
|
||||
@ -11,9 +11,9 @@
|
||||
<span class='chat-card-button-area'>
|
||||
<br>
|
||||
{{#unless (eq surprise 'totale')}}
|
||||
{{#if tentatives.defense}}
|
||||
{{#if essais.defense}}
|
||||
<br>
|
||||
{{#unless tentatives.chance}}
|
||||
{{#unless essais.defenseChance}}
|
||||
{{#if (eq defender.data.type 'personnage')}}
|
||||
<a class='chat-card-button' id='appel-chance-defense' data-attackerId='{{attackerId}}'
|
||||
data-defenderTokenId='{{defenderTokenId}}'>Faire appel à la chance</a>
|
||||
@ -31,22 +31,20 @@
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#each armes as |arme key|}}
|
||||
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}'
|
||||
data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>Parer avec {{arme.name}}
|
||||
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>
|
||||
Parer avec {{arme.name}} à {{../diffLibre }}
|
||||
</a>
|
||||
<br>
|
||||
{{/each}}
|
||||
{{#if mainsNues}}
|
||||
<a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}'
|
||||
data-defenderTokenId='{{defenderTokenId}}'>
|
||||
Parer à mains nues
|
||||
<a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
|
||||
Parer à mains nues à {{diffLibre}}
|
||||
</a>
|
||||
<br>
|
||||
{{/if}}
|
||||
{{#if (ne attaqueCategorie 'tir')}}
|
||||
<a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}'
|
||||
data-defenderTokenId='{{defenderTokenId}}'>
|
||||
Esquiver
|
||||
<a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
|
||||
Esquiver à {{diffLibre}}
|
||||
</a>
|
||||
<br>
|
||||
{{/if}}
|
||||
|
Loading…
Reference in New Issue
Block a user