fix #11423 (Tiller Engine)

This commit is contained in:
xenohedron 2023-11-19 00:02:59 -05:00
parent 2457255130
commit 2e79595ecf

View file

@ -4,14 +4,18 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.effects.common.UntapTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.permanent.TappedPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.UUID;
@ -35,10 +39,8 @@ public final class TillerEngine extends CardImpl {
// Whenever a land enters the battlefield tapped and under your control, choose one
// Untap that land.
Ability ability = new EntersBattlefieldControlledTriggeredAbility(
Zone.BATTLEFIELD, new UntapTargetEffect().setText("Untap that land"),
filter, false, SetTargetPointer.PERMANENT
).setTriggerPhrase("Whenever a land enters the battlefield tapped and under your control, ");
Ability ability = new EntersBattlefieldControlledTriggeredAbility(new TillerEngineUntapEffect(), filter)
.setTriggerPhrase("Whenever a land enters the battlefield tapped and under your control, ");
// Tap target nonland permanent an opponent controls.
Mode mode = new Mode(new TapTargetEffect());
@ -56,3 +58,32 @@ public final class TillerEngine extends CardImpl {
return new TillerEngine(this);
}
}
class TillerEngineUntapEffect extends OneShotEffect {
// This class is needed rather than UntapTargetEffect to use the stored value rather than a SetTargetPointer,
// because the second mode must not have its target pointer overwritten by the trigger
TillerEngineUntapEffect() {
super(Outcome.Untap);
staticText = "Untap that land";
}
private TillerEngineUntapEffect(final TillerEngineUntapEffect effect) {
super(effect);
}
@Override
public TillerEngineUntapEffect copy() {
return new TillerEngineUntapEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
if (permanent != null) {
permanent.untap(game);
}
return true;
}
}