Fixed a bug of ZoneChangeAllTriggeredAbility trying to get permanent from battelfield if permanent left battlefield.

This commit is contained in:
LevelX2 2013-06-04 00:55:50 +02:00
parent 20a0e16604
commit 2259a534b2
2 changed files with 12 additions and 4 deletions

View file

@ -75,7 +75,12 @@ public class ZoneChangeAllTriggeredAbility<T extends ZoneChangeAllTriggeredAbili
if (event.getType() == EventType.ZONE_CHANGE) { if (event.getType() == EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event; ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) { if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) {
Permanent perm = game.getPermanent(event.getTargetId()); Permanent perm;
if (zEvent.getTarget() != null) {
perm = zEvent.getTarget();
} else {
perm = game.getPermanent(event.getTargetId()); // LevelX2: maybe this part is not neccessary
}
if (perm != null && filter.match(perm, sourceId, controllerId, game)) { if (perm != null && filter.match(perm, sourceId, controllerId, game)) {
return true; return true;
} }

View file

@ -67,18 +67,21 @@ public class ProtectionAbility extends StaticAbility<ProtectionAbility> {
public boolean canTarget(MageObject source, Game game) { public boolean canTarget(MageObject source, Game game) {
if (filter instanceof FilterPermanent) { if (filter instanceof FilterPermanent) {
if (source instanceof Permanent) if (source instanceof Permanent) {
return !filter.match(source, game); return !filter.match(source, game);
}
return true; return true;
} }
if (filter instanceof FilterSpell) { if (filter instanceof FilterSpell) {
if (source instanceof Spell) if (source instanceof Spell) {
return !filter.match(source, game); return !filter.match(source, game);
}
return true; return true;
} }
if (filter instanceof FilterCard) { if (filter instanceof FilterCard) {
if (source instanceof Card) if (source instanceof Card) {
return !filter.match(source, game); return !filter.match(source, game);
}
return true; return true;
} }
if (filter instanceof FilterObject) { if (filter instanceof FilterObject) {