Remove redundant branch in TargetPermanent canTarget method (#9003)

This commit is contained in:
DeepCrimson 2022-05-25 22:03:47 -07:00 committed by GitHub
parent 0c8ef41012
commit 49c02387d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {