From 49c02387d437a25762da49e9d9aaabfc6ca11417 Mon Sep 17 00:00:00 2001 From: DeepCrimson <98864333+DeepCrimson@users.noreply.github.com> Date: Wed, 25 May 2022 22:03:47 -0700 Subject: [PATCH] Remove redundant branch in TargetPermanent canTarget method (#9003) --- .../java/mage/target/TargetPermanent.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Mage/src/main/java/mage/target/TargetPermanent.java b/Mage/src/main/java/mage/target/TargetPermanent.java index 5747ea098e4..c8bcc2be75b 100644 --- a/Mage/src/main/java/mage/target/TargetPermanent.java +++ b/Mage/src/main/java/mage/target/TargetPermanent.java @@ -57,24 +57,24 @@ public class TargetPermanent extends TargetObject { @Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); - if (permanent != null) { - if (source != null) { - //1. TODO: check for replacement effects - //2. We need to check both source.getId() and source.getSourceId() - // first for protection from spells or abilities (e.g. protection from colored spells, r1753) - // second for protection from sources (e.g. protection from artifacts + equip ability) - if (!isNotTarget()) { - if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) - || !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) { - return false; - } + if (permanent == null) { + return false; + } + + if (source != null) { + //1. TODO: check for replacement effects + //2. We need to check both source.getId() and source.getSourceId() + // first for protection from spells or abilities (e.g. protection from colored spells, r1753) + // second for protection from sources (e.g. protection from artifacts + equip ability) + if (!isNotTarget()) { + if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) + || !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) { + return false; } - return filter.match(permanent, controllerId, source, game); - } else { - return filter.match(permanent, controllerId, source, game); } } - return false; + + return filter.match(permanent, controllerId, source, game); } public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game, boolean flag) {