|
| 1 | +package mage.cards.s; |
| 2 | + |
| 3 | +import java.util.UUID; |
| 4 | +import mage.MageInt; |
| 5 | +import mage.constants.SubType; |
| 6 | +import mage.constants.SuperType; |
| 7 | +import mage.filter.StaticFilters; |
| 8 | +import mage.game.Game; |
| 9 | +import mage.game.permanent.Permanent; |
| 10 | +import mage.target.common.TargetControlledPermanent; |
| 11 | +import mage.target.common.TargetOpponent; |
| 12 | +import mage.target.targetpointer.FixedTarget; |
| 13 | +import mage.abilities.Ability; |
| 14 | +import mage.abilities.common.SimpleActivatedAbility; |
| 15 | +import mage.abilities.costs.common.TapSourceCost; |
| 16 | +import mage.abilities.costs.mana.GenericManaCost; |
| 17 | +import mage.abilities.effects.OneShotEffect; |
| 18 | +import mage.abilities.effects.common.DrawCardSourceControllerEffect; |
| 19 | +import mage.abilities.effects.common.continuous.GainControlTargetEffect; |
| 20 | +import mage.abilities.keyword.LifelinkAbility; |
| 21 | +import mage.cards.CardImpl; |
| 22 | +import mage.cards.CardSetInfo; |
| 23 | +import mage.constants.CardType; |
| 24 | +import mage.constants.Duration; |
| 25 | +import mage.constants.Outcome; |
| 26 | + |
| 27 | +/** |
| 28 | + * @author balazskristof |
| 29 | + */ |
| 30 | +public final class StiltzkinMoogleMerchant extends CardImpl { |
| 31 | + |
| 32 | + public StiltzkinMoogleMerchant(UUID ownerId, CardSetInfo setInfo) { |
| 33 | + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}"); |
| 34 | + |
| 35 | + this.supertype.add(SuperType.LEGENDARY); |
| 36 | + this.subtype.add(SubType.MOOGLE); |
| 37 | + this.power = new MageInt(1); |
| 38 | + this.toughness = new MageInt(2); |
| 39 | + |
| 40 | + // Lifelink |
| 41 | + this.addAbility(LifelinkAbility.getInstance()); |
| 42 | + |
| 43 | + // {2}, {T}: Target opponent gains control of another target permanent you control. If they do, you draw a card. |
| 44 | + Ability ability = new SimpleActivatedAbility(new StiltzkinMoogleMerchantEffect(), new GenericManaCost(2)); |
| 45 | + ability.addCost(new TapSourceCost()); |
| 46 | + ability.addTarget(new TargetOpponent()); |
| 47 | + ability.addTarget(new TargetControlledPermanent(StaticFilters.FILTER_CONTROLLED_ANOTHER_PERMANENT)); |
| 48 | + this.addAbility(ability); |
| 49 | + } |
| 50 | + |
| 51 | + private StiltzkinMoogleMerchant(final StiltzkinMoogleMerchant card) { |
| 52 | + super(card); |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public StiltzkinMoogleMerchant copy() { |
| 57 | + return new StiltzkinMoogleMerchant(this); |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +class StiltzkinMoogleMerchantEffect extends OneShotEffect { |
| 62 | + |
| 63 | + StiltzkinMoogleMerchantEffect() { |
| 64 | + super(Outcome.Benefit); |
| 65 | + staticText = "Target opponent gains control of another target permanent you control. If they do, you draw a card."; |
| 66 | + } |
| 67 | + |
| 68 | + private StiltzkinMoogleMerchantEffect(StiltzkinMoogleMerchantEffect effect) { |
| 69 | + super(effect); |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + public StiltzkinMoogleMerchantEffect copy() { |
| 74 | + return new StiltzkinMoogleMerchantEffect(this); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public boolean apply(Game game, Ability source) { |
| 79 | + Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); |
| 80 | + if (permanent == null) { |
| 81 | + return false; |
| 82 | + } |
| 83 | + UUID opponent = getTargetPointer().getFirst(game, source); |
| 84 | + game.addEffect(new GainControlTargetEffect( |
| 85 | + Duration.Custom, true, opponent |
| 86 | + ).setTargetPointer(new FixedTarget(permanent.getId(), game)), source); |
| 87 | + game.processAction(); |
| 88 | + if (permanent.isControlledBy(opponent)) { |
| 89 | + new DrawCardSourceControllerEffect(1).apply(game, source); |
| 90 | + return true; |
| 91 | + } |
| 92 | + return false; |
| 93 | + } |
| 94 | +} |
| 95 | + |
0 commit comments