From 76f51848a3a5d9c3c12217eacf43f7635e945b3a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 20 Jan 2015 12:10:06 +0100 Subject: [PATCH] * Enigma Sphinx - Fixed that it only was put to third of library if it was controlled by its owner before it went to the graveyard. --- .../mage/sets/alarareborn/EnigmaSphinx.java | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java b/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java index 86bc5576fce..48d54006373 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java +++ b/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java @@ -34,13 +34,17 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.CascadeAbility; import mage.abilities.keyword.FlyingAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; import mage.players.Library; import mage.players.Player; @@ -61,8 +65,8 @@ public class EnigmaSphinx extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); - // When Enigma Sphinx is put into your graveyard from the battlefield, put it into your library third from the top. - this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new EnigmaSphinxEffect())); + // When Enigma Sphinx is put into your graveyard from the battlefield, put it into your library third from the top. + this.addAbility(new EnigmaSphinxTriggeredAbility(new EnigmaSphinxEffect())); // Cascade this.addAbility(new CascadeAbility()); @@ -78,6 +82,49 @@ public class EnigmaSphinx extends CardImpl { } } +class EnigmaSphinxTriggeredAbility extends TriggeredAbilityImpl { + + public EnigmaSphinxTriggeredAbility(Effect effect) { + this(effect, false); + } + + public EnigmaSphinxTriggeredAbility(Effect effect, boolean optional) { + super(Zone.ALL, effect, optional); + } + + EnigmaSphinxTriggeredAbility(EnigmaSphinxTriggeredAbility ability) { + super(ability); + } + + @Override + public EnigmaSphinxTriggeredAbility copy() { + return new EnigmaSphinxTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + Permanent permanent = zEvent.getTarget(); + if (permanent != null && + zEvent.getToZone() == Zone.GRAVEYARD && + zEvent.getFromZone() == Zone.BATTLEFIELD && + permanent.getId().equals(this.getSourceId()) && + // 5/1/2009 If you control an Enigma Sphinx that's owned by another player, it's put into that player's + // graveyard from the battlefield, so Enigma Sphinx's middle ability won't trigger. + permanent.getOwnerId().equals(permanent.getControllerId())) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "When {this} is put into your graveyard from the battlefield, " + super.getRule(); + } +} + class EnigmaSphinxEffect extends OneShotEffect { public EnigmaSphinxEffect() {