Combat Calligrapher - fixed game error (NPE error)

This commit is contained in:
Oleg Agafonov 2023-05-09 15:52:07 +04:00
parent 05443fb3f4
commit 1dc5ee13a3

View file

@ -82,12 +82,17 @@ class CombatCalligrapherTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
Player attacker = game.getPlayer(event.getPlayerId());
Player defender = game.getPlayer(event.getTargetId());
if (attacker == null || defender == null) {
return false;
}
// Do not trigger if opponent is out of range (not visible as opponent to controller, and not the controller)
// or if the person being attacked is not an opponent of the controller.
if ((!game.getOpponents(getControllerId()).contains(attacker.getId()) && attacker.getId() != getControllerId())
|| !game.getOpponents(getControllerId()).contains(defender.getId())) {
return false;
}
getEffects().setValue("playerToAttack", defender.getId());
getEffects().setTargetPointer(new FixedTarget(attacker.getId()));
return true;