[FIX] Fixes Fiend Hunters may enters the battlefield ability (issue 282) and also the found bug with multiple Fiend Hunters using the same exile zone, therefore one Fiend Hunter Exiling another causes the exiled Fiend Hunter's leaves the battlefield trigger to remove itself from the exile zone from the other. This same issue affected Journey to Nowhere, Oblivion Ring and Leonin Relic Warcer

This commit is contained in:
maurer.it 2011-10-18 20:28:50 -04:00
parent 73abbd2e87
commit e0f3e367fa
6 changed files with 211 additions and 16 deletions

View file

@ -34,14 +34,14 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.Target;
import mage.target.TargetPermanent;
import java.util.UUID;
import mage.abilities.effects.common.ExileTargetForSourceEffect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
/**
* @author nantuko
@ -64,14 +64,14 @@ public class FiendHunter extends CardImpl<FiendHunter> {
this.toughness = new MageInt(3);
// When Fiend Hunter enters the battlefield, you may exile another target creature.
Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetEffect(this.getId(), "Fiend Hunter Exile"), false);
Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetForSourceEffect("Fiend Hunter Exile"), true);
Target target = new TargetPermanent(filter);
target.setRequired(true);
ability1.addTarget(target);
this.addAbility(ability1);
// When Fiend Hunter leaves the battlefield, return the exiled card to the battlefield under its owner's control.
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileEffect(this.getId(), Constants.Zone.BATTLEFIELD), false);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Constants.Zone.BATTLEFIELD), false);
this.addAbility(ability2);
}

View file

@ -37,8 +37,8 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.effects.common.ExileTargetForSourceEffect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterPermanent;
@ -67,13 +67,13 @@ public class LeoninRelicWarder extends CardImpl<LeoninRelicWarder> {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileTargetEffect(this.getId(), "Leonin Relic-Warder exile"), true);
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileTargetForSourceEffect("Leonin Relic-Warder exile"), true);
Target target = new TargetPermanent(filter);
target.setRequired(true);
ability.addTarget(target);
this.addAbility(ability);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileEffect(this.getId(), Constants.Zone.BATTLEFIELD), false);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Constants.Zone.BATTLEFIELD), false);
this.addAbility(ability2);
}

View file

@ -28,7 +28,6 @@
package mage.sets.shardsofalara;
import mage.abilities.effects.common.ReturnFromExileEffect;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
@ -36,7 +35,8 @@ import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.ExileTargetForSourceEffect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterNonlandPermanent;
import mage.target.Target;
@ -54,12 +54,12 @@ public class OblivionRing extends CardImpl<OblivionRing> {
this.color.setWhite(true);
FilterNonlandPermanent filter = new FilterNonlandPermanent("another nonland permanent");
filter.setAnother(true);
Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetEffect(this.getId(), "Oblivion Ring exile"), false);
Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetForSourceEffect( "Oblivion Ring exile"), false);
Target target = new TargetPermanent(filter);
target.setRequired(true);
ability1.addTarget(target);
this.addAbility(ability1);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileEffect(this.getId(), Zone.BATTLEFIELD), false);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false);
this.addAbility(ability2);
}

View file

@ -35,8 +35,8 @@ import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.effects.common.ExileTargetForSourceEffect;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.Target;
@ -54,12 +54,12 @@ public class JourneyToNowhere extends CardImpl<JourneyToNowhere> {
this.color.setWhite(true);
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.setAnother(true);
Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetEffect(this.getId(), "Journey to Nowhere exile"), false);
Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetForSourceEffect("Journey to Nowhere exile"), false);
Target target = new TargetPermanent(filter);
target.setRequired(true);
ability1.addTarget(target);
this.addAbility(ability1);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileEffect(this.getId(), Zone.BATTLEFIELD), false);
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false);
this.addAbility(ability2);
}

View file

@ -0,0 +1,90 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import java.util.UUID;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class ExileTargetForSourceEffect extends OneShotEffect<ExileTargetForSourceEffect> {
private String exileZone = null;
public ExileTargetForSourceEffect(String exileZone) {
this();
this.exileZone = exileZone;
}
public ExileTargetForSourceEffect() {
super(Outcome.Exile);
}
public ExileTargetForSourceEffect(final ExileTargetForSourceEffect effect) {
super(effect);
this.exileZone = effect.exileZone;
}
@Override
public ExileTargetForSourceEffect copy() {
return new ExileTargetForSourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(source));
UUID exileId = source.getSourceId();
if (permanent != null) {
return permanent.moveToExile(exileId, exileZone, source.getId(), game);
} else {
Card card = game.getCard(targetPointer.getFirst(source));
if (card != null) {
return card.moveToExile(exileId, exileZone, source.getId(), game);
}
}
return false;
}
@Override
public String getText(Mode mode) {
if (mode.getTargets().isEmpty()) {
return "Exile it";
} else {
return "Exile target " + mode.getTargets().get(0).getTargetName();
}
}
}

View file

@ -0,0 +1,105 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import java.util.UUID;
import mage.Constants.Outcome;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.game.ExileZone;
import mage.game.Game;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class ReturnFromExileForSourceEffect extends OneShotEffect<ReturnFromExileForSourceEffect> {
private Zone zone;
private boolean tapped;
public ReturnFromExileForSourceEffect(Zone zone) {
this(zone, false);
}
public ReturnFromExileForSourceEffect(Zone zone, boolean tapped) {
super(Outcome.PutCardInPlay);
this.zone = zone;
this.tapped = tapped;
setText();
}
public ReturnFromExileForSourceEffect(final ReturnFromExileForSourceEffect effect) {
super(effect);
this.zone = effect.zone;
this.tapped = effect.tapped;
}
@Override
public ReturnFromExileForSourceEffect copy() {
return new ReturnFromExileForSourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
UUID exileId = source.getSourceId();
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null) {
for (UUID cardId: exile) {
Card card = game.getCard(cardId);
card.moveToZone(zone, source.getId(), game, tapped);
}
exile.clear();
return true;
}
return false;
}
private void setText() {
StringBuilder sb = new StringBuilder();
sb.append("return the exiled cards ");
switch(zone) {
case BATTLEFIELD:
sb.append("to the battlefield under its owner's control");
if (tapped)
sb.append(" tapped");
break;
case HAND:
sb.append("to their owner's hand");
break;
case GRAVEYARD:
sb.append("to their owner's graveyard");
break;
}
staticText = sb.toString();
}
}