Fixed double triggering. Fixed Issue 86.

This commit is contained in:
magenoxx 2011-06-26 19:18:43 +04:00
parent e8dc1b659c
commit 5e79f51f1d
2 changed files with 19 additions and 12 deletions

View file

@ -163,6 +163,7 @@ class NecroticPlagueEffect2 extends OneShotEffect<NecroticPlagueEffect2> {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
if (target.canChoose(source.getControllerId(), game)) {
if (controller.choose(Outcome.Detriment, target, game)) {
Card card = game.getCard(cardId);
if (card != null) {
@ -173,6 +174,7 @@ class NecroticPlagueEffect2 extends OneShotEffect<NecroticPlagueEffect2> {
}
}
}
}
}
return false;
}

View file

@ -45,6 +45,8 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import javax.swing.*;
/**
*
* @author BetaSteward_at_googlemail.com
@ -118,16 +120,19 @@ public class PermanentCard extends PermanentImpl<PermanentCard> {
// we only want to trigger abilities that are not on the underlying card ie. have been added by another effect
// or we want to trigger abilities that only trigger on leaving the battlefield
// card abilities will get triggered later when the card hits the new zone
List<UUID> triggered = new ArrayList<UUID>();
Card card = game.getCard(objectId).copy();
for (TriggeredAbility ability: abilities.getTriggeredAbilities(event.getFromZone())) {
if (!card.getAbilities().containsKey(ability.getId())) {
if (ability.checkTrigger(event, game)) {
triggered.add(ability.getId());
ability.trigger(game, controllerId);
}
} else if (ability instanceof ZoneChangeTriggeredAbility && event.getFromZone() == Zone.BATTLEFIELD) {
ZoneChangeTriggeredAbility zcAbility = (ZoneChangeTriggeredAbility)ability;
if (zcAbility.getToZone() == null) {
if (ability.checkTrigger(event, game)) {
triggered.add(ability.getId());
ability.trigger(game, controllerId);
}
}
@ -135,7 +140,7 @@ public class PermanentCard extends PermanentImpl<PermanentCard> {
}
for (TriggeredAbility ability: abilities.getTriggeredAbilities(event.getToZone())) {
if (!card.getAbilities().containsKey(ability.getId())) {
if (ability.checkTrigger(event, game)) {
if (!triggered.contains(ability.getId()) && ability.checkTrigger(event, game)) {
ability.trigger(game, controllerId);
}
}