fixed The Tabernacle at Pendrell Vale forcing sacrifice of creatures which have left and re-entered the battlefield (fixes #4861)

This commit is contained in:
Evan Kranzler 2018-04-24 19:26:58 -04:00
parent 758634f5bb
commit 1e86f1607e

View file

@ -39,7 +39,7 @@ import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -51,12 +51,18 @@ import mage.players.Player;
public class TheTabernacleAtPendrellVale extends CardImpl {
public TheTabernacleAtPendrellVale(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
addSuperType(SuperType.LEGENDARY);
// All creatures have "At the beginning of your upkeep, destroy this creature unless you pay {1}."
Ability ability = new BeginningOfUpkeepTriggeredAbility(new DestroySourceUnlessPaysEffect(new ManaCostsImpl("{1}")), TargetController.YOU, false);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(ability, Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_CREATURES)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAllEffect(
ability,
Duration.WhileOnBattlefield,
new FilterCreaturePermanent("All creatures")
)
));
}
public TheTabernacleAtPendrellVale(final TheTabernacleAtPendrellVale card) {
@ -69,14 +75,14 @@ public class TheTabernacleAtPendrellVale extends CardImpl {
}
}
class DestroySourceUnlessPaysEffect extends OneShotEffect {
protected Cost cost;
public DestroySourceUnlessPaysEffect(Cost cost) {
super(Outcome.DestroyPermanent);
this.cost = cost;
}
}
public DestroySourceUnlessPaysEffect(final DestroySourceUnlessPaysEffect effect) {
super(effect);
@ -87,8 +93,8 @@ class DestroySourceUnlessPaysEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) {
if (player != null && permanent != null && source.getSourceObjectZoneChangeCounter() == permanent.getZoneChangeCounter(game)) {
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
@ -105,8 +111,8 @@ class DestroySourceUnlessPaysEffect extends OneShotEffect {
return new DestroySourceUnlessPaysEffect(this);
}
@Override
@Override
public String getText(Mode mode) {
return "destroy this creature unless you pay {1}";
}
}
}