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,9 +413,11 @@ 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!");
} }
const defender = target?.actor; else {
const defenderTokenId = target?.data._id; const defender = target?.actor;
return this.create(attacker, defender, defenderTokenId, target) 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))) { 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);
const defenderRoll = msg.defenderRoll; if (rddCombat) {
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll); const defenderRoll = msg.defenderRoll;
RdDCombat._storeDefense(defenderRoll); RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme); RdDCombat._storeDefense(defenderRoll);
rddCombat._chatMessageDefense(msg.paramChatDefense); rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
rddCombat._chatMessageDefense(msg.paramChatDefense);
}
} }
} }
} }
@ -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 => {