Fix erreur en cas d'attaque sans cible

This commit is contained in:
Vincent Vandemeulebrouck 2021-03-18 23:55:59 +01:00
parent 17d863482d
commit e71c03abb0
2 changed files with 17 additions and 11 deletions

View File

@ -2546,7 +2546,7 @@ export class RdDActor extends Actor {
let competence = this.getCompetence(compName); let competence = this.getCompetence(compName);
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) { if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
RdDCombat.createUsingTarget(this).attaque(competence, arme); RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
} else { } else {
this.rollCompetence(competence.name); this.rollCompetence(competence.name);
} }

View File

@ -413,10 +413,12 @@ export class RdDCombat {
? "Vous devez choisir <strong>une seule</strong> cible à attaquer!" ? "Vous devez choisir <strong>une seule</strong> cible à attaquer!"
: "Vous devez choisir une cible à attaquer!"); : "Vous devez choisir une cible à attaquer!");
} }
else {
const defender = target?.actor; const defender = target?.actor;
const defenderTokenId = target?.data._id; const defenderTokenId = target?.data._id;
return this.create(attacker, defender, defenderTokenId, target) return this.create(attacker, defender, defenderTokenId, target)
} }
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static getTarget() { static getTarget() {
@ -500,6 +502,7 @@ export class RdDCombat {
} }
if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character._id == defenderToken.actor.data._id))) { if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character._id == defenderToken.actor.data._id))) {
const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId);
if (rddCombat) {
const defenderRoll = msg.defenderRoll; const defenderRoll = msg.defenderRoll;
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll); RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
RdDCombat._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll);
@ -508,6 +511,7 @@ export class RdDCombat {
} }
} }
} }
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static _callJetDeVie(event) { static _callJetDeVie(event) {
@ -533,9 +537,11 @@ export class RdDCombat {
const rddCombat = RdDCombat.createForAttackerAndDefender( const rddCombat = RdDCombat.createForAttackerAndDefender(
event.currentTarget.attributes['data-attackerId']?.value, event.currentTarget.attributes['data-attackerId']?.value,
event.currentTarget.attributes['data-defenderTokenId']?.value); event.currentTarget.attributes['data-defenderTokenId']?.value);
if (rddCombat) {
rddCombat.onEvent(button, event); rddCombat.onEvent(button, event);
event.preventDefault(); event.preventDefault();
}
}); });
} }
html.on("click", '#chat-jet-vie', event => { html.on("click", '#chat-jet-vie', event => {