diff --git a/Mage.Sets/src/mage/cards/t/TradeRouteEnvoy.java b/Mage.Sets/src/mage/cards/t/TradeRouteEnvoy.java new file mode 100644 index 00000000000..28512ab25a8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TradeRouteEnvoy.java @@ -0,0 +1,84 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.CounterAnyPredicate; +import mage.game.Game; +import mage.players.Player; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TradeRouteEnvoy extends CardImpl { + + public TradeRouteEnvoy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); + + this.subtype.add(SubType.DOG); + this.subtype.add(SubType.SOLDIER); + this.power = new MageInt(4); + this.toughness = new MageInt(3); + + // When this creature enters, draw a card if you control a creature with a counter on it. If you don't draw a card this way, put a +1/+1 counter on this creature. + this.addAbility(new EntersBattlefieldTriggeredAbility(new TradeRouteEnvoyEffect())); + } + + private TradeRouteEnvoy(final TradeRouteEnvoy card) { + super(card); + } + + @Override + public TradeRouteEnvoy copy() { + return new TradeRouteEnvoy(this); + } +} + +class TradeRouteEnvoyEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterControlledCreaturePermanent(); + + static { + filter.add(CounterAnyPredicate.instance); + } + + TradeRouteEnvoyEffect() { + super(Outcome.Benefit); + staticText = "draw a card if you control a creature with a counter on it. " + + "If you don't draw a card this way, put a +1/+1 counter on this creature"; + } + + private TradeRouteEnvoyEffect(final TradeRouteEnvoyEffect effect) { + super(effect); + } + + @Override + public TradeRouteEnvoyEffect copy() { + return new TradeRouteEnvoyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + if (game.getBattlefield().contains(filter, source, game, 1)) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null && player.drawCards(1, source, game) > 0) { + return true; + } + } + Optional.ofNullable(source.getSourcePermanentIfItStillExists(game)) + .ifPresent(permanent -> permanent.addCounters(CounterType.P1P1.createInstance(), source, game)); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java index 7c4c17cbdc3..e94ce50a506 100644 --- a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java +++ b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java @@ -196,6 +196,7 @@ public final class TarkirDragonstorm extends ExpansionSet { cards.add(new SetCardInfo("Temur Tawnyback", 229, Rarity.COMMON, mage.cards.t.TemurTawnyback.class)); cards.add(new SetCardInfo("The Sibsig Ceremony", 91, Rarity.RARE, mage.cards.t.TheSibsigCeremony.class)); cards.add(new SetCardInfo("Thornwood Falls", 269, Rarity.COMMON, mage.cards.t.ThornwoodFalls.class)); + cards.add(new SetCardInfo("Trade Route Envoy", 163, Rarity.COMMON, mage.cards.t.TradeRouteEnvoy.class)); cards.add(new SetCardInfo("Tranquil Cove", 270, Rarity.COMMON, mage.cards.t.TranquilCove.class)); cards.add(new SetCardInfo("Twin Bolt", 128, Rarity.COMMON, mage.cards.t.TwinBolt.class)); cards.add(new SetCardInfo("Ugin, Eye of the Storms", 1, Rarity.MYTHIC, mage.cards.u.UginEyeOfTheStorms.class));