mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Fixed double triggering. Fixed Issue 86.
This commit is contained in:
parent
e8dc1b659c
commit
5e79f51f1d
2 changed files with 19 additions and 12 deletions
|
@ -163,16 +163,18 @@ class NecroticPlagueEffect2 extends OneShotEffect<NecroticPlagueEffect2> {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
|
||||
if (controller.choose(Outcome.Detriment, target, game)) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getId(), source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
return permanent.addAttachment(cardId, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target.canChoose(source.getControllerId(), game)) {
|
||||
if (controller.choose(Outcome.Detriment, target, game)) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getId(), source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
return permanent.addAttachment(cardId, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
Card card = game.getCard(objectId).copy();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue