spjspj - Add Evangelize (TSP) - Also possibly a fix for Preacher which could target Narset, Enlightened Master when it shouldn't be able to

This commit is contained in:
spjspj 2016-10-20 16:58:18 +11:00
parent ae2765885f
commit b6661ae79d
3 changed files with 86 additions and 3 deletions

View file

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.target.common;
import java.util.UUID;
@ -11,6 +10,7 @@ import mage.abilities.Ability;
import mage.constants.Outcome;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
@ -26,7 +26,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
super(1, 1, filter, false);
this.targetName = filter.getMessage();
}
public TargetOpponentsChoicePermanent(int minNumTargets, int maxNumTargets, FilterPermanent filter, boolean notTarget) {
super(minNumTargets, maxNumTargets, filter, notTarget);
this.targetName = filter.getMessage();
@ -47,8 +47,22 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
Permanent permanent = game.getPermanent(id);
if (opponentId != null) {
return super.canTarget(opponentId, id, source, game);
if (permanent != null) {
if (source != null) {
boolean canSourceControllerTarget = true;
if (!isNotTarget()) {
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game)
|| !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) {
canSourceControllerTarget = false;
}
}
canSourceControllerTarget &= super.canTarget(opponentId, id, source, game);
canSourceControllerTarget &= filter.match(permanent, source.getSourceId(), opponentId, game);
return canSourceControllerTarget;
}
}
}
return false;
}