From 251e0443df564cd300514f0ce0deb0f6647eabd6 Mon Sep 17 00:00:00 2001 From: spjspj Date: Mon, 30 Jul 2018 23:27:03 +1000 Subject: [PATCH] Treasure Nabber (C18) "All takesies, no givesies" --- .../src/mage/cards/t/TreasureNabber.java | 146 ++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2018.java | 1 + 2 files changed, 147 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TreasureNabber.java diff --git a/Mage.Sets/src/mage/cards/t/TreasureNabber.java b/Mage.Sets/src/mage/cards/t/TreasureNabber.java new file mode 100644 index 0000000000..9a62b20545 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TreasureNabber.java @@ -0,0 +1,146 @@ +package mage.cards.t; + +import java.util.List; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.PhaseStep; +import mage.constants.SubLayer; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; +import mage.target.targetpointer.FixedTargets; + +/** + * + * @author spjspj + */ +public final class TreasureNabber extends CardImpl { + + public TreasureNabber(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); + + this.subtype.add(SubType.GOBLIN); + this.subtype.add(SubType.ROGUE); + this.power = new MageInt(3); + this.toughness = new MageInt(2); + + // Whenever an opponent taps an artifact for mana, gain control of that artifact until the end of your next turn. + this.addAbility(new TreasureNabberAbility()); + } + + public TreasureNabber(final TreasureNabber card) { + super(card); + } + + @Override + public TreasureNabber copy() { + return new TreasureNabber(this); + } +} + +class TreasureNabberAbility extends TriggeredAbilityImpl { + + public TreasureNabberAbility() { + super(Zone.BATTLEFIELD, new TreasureNabberEffect()); + } + + public TreasureNabberAbility(TreasureNabberAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == EventType.TAPPED_FOR_MANA; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (game.getOpponents(controllerId).contains(event.getPlayerId())) { + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent != null && permanent.isArtifact()) { + getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + return true; + } + } + return false; + } + + @Override + public TreasureNabberAbility copy() { + return new TreasureNabberAbility(this); + } + + @Override + public String getRule() { + return "Whenever an opponent taps an artifact for mana, gain control of that artifact until the end of your next turn"; + } +} + +class TreasureNabberEffect extends ContinuousEffectImpl { + + protected FixedTargets fixedTargets; + protected int startingTurn; + + TreasureNabberEffect() { + super(Duration.Custom, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); + this.staticText = "gain control of that artifact until the end of your next turn"; + startingTurn = 0; + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); + startingTurn = game.getTurnNum(); + if (game.getPhase().getStep().getType() == PhaseStep.END_TURN) { + startingTurn = game.getTurnNum() + 1; + } + } + + TreasureNabberEffect(final TreasureNabberEffect effect) { + super(effect); + this.fixedTargets = effect.fixedTargets; + } + + @Override + public TreasureNabberEffect copy() { + return new TreasureNabberEffect(this); + } + + @Override + public boolean isInactive(Ability source, Game game) { + if (startingTurn != 0 && game.getTurnNum() >= startingTurn && game.getPhase().getStep().getType() == PhaseStep.END_TURN) { + if (game.isActivePlayer(source.getControllerId())) { + return true; + } + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + + if (permanent != null) { + permanent.changeControllerId(source.getControllerId(), game); + return true; + } + return false; + } + + public void setTargets(List targetedPermanents, Game game) { + this.fixedTargets = new FixedTargets(targetedPermanents, game); + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index 2f7998b98c..98b2701e39 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -293,6 +293,7 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Tranquil Expanse", 289, Rarity.UNCOMMON, mage.cards.t.TranquilExpanse.class)); cards.add(new SetCardInfo("Tranquil Thicket", 290, Rarity.COMMON, mage.cards.t.TranquilThicket.class)); cards.add(new SetCardInfo("Treasure Hunt", 109, Rarity.COMMON, mage.cards.t.TreasureHunt.class)); + cards.add(new SetCardInfo("Treasure Nabber", 27, Rarity.RARE, mage.cards.t.TreasureNabber.class)); cards.add(new SetCardInfo("Turntimber Sower", 35, Rarity.RARE, mage.cards.t.TurntimberSower.class)); cards.add(new SetCardInfo("Tuvasa the Sunlit", 47, Rarity.MYTHIC, mage.cards.t.TuvasaTheSunlit.class)); cards.add(new SetCardInfo("Unflinching Courage", 192, Rarity.UNCOMMON, mage.cards.u.UnflinchingCourage.class));