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);
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
RdDCombat.createUsingTarget(this).attaque(competence, arme);
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
} else {
this.rollCompetence(competence.name);
}

View File

@ -413,9 +413,11 @@ export class RdDCombat {
? "Vous devez choisir <strong>une seule</strong> cible à attaquer!"
: "Vous devez choisir une cible à attaquer!");
}
const defender = target?.actor;
const defenderTokenId = target?.data._id;
return this.create(attacker, defender, defenderTokenId, target)
else {
const defender = target?.actor;
const defenderTokenId = target?.data._id;
return this.create(attacker, defender, defenderTokenId, target)
}
}
/* -------------------------------------------- */
@ -500,11 +502,13 @@ export class RdDCombat {
}
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 defenderRoll = msg.defenderRoll;
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
RdDCombat._storeDefense(defenderRoll);
rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
rddCombat._chatMessageDefense(msg.paramChatDefense);
if (rddCombat) {
const defenderRoll = msg.defenderRoll;
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
RdDCombat._storeDefense(defenderRoll);
rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
rddCombat._chatMessageDefense(msg.paramChatDefense);
}
}
}
}
@ -533,9 +537,11 @@ export class RdDCombat {
const rddCombat = RdDCombat.createForAttackerAndDefender(
event.currentTarget.attributes['data-attackerId']?.value,
event.currentTarget.attributes['data-defenderTokenId']?.value);
if (rddCombat) {
rddCombat.onEvent(button, event);
event.preventDefault();
rddCombat.onEvent(button, event);
event.preventDefault();
}
});
}
html.on("click", '#chat-jet-vie', event => {