From dd3bedb5c0e89ae350e4d49494bd27eec7396824 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 4 Sep 2019 08:38:27 -0400 Subject: [PATCH] Implemented Run Away Together --- .../src/mage/cards/r/RunAwayTogether.java | 71 +++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + 2 files changed, 72 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RunAwayTogether.java diff --git a/Mage.Sets/src/mage/cards/r/RunAwayTogether.java b/Mage.Sets/src/mage/cards/r/RunAwayTogether.java new file mode 100644 index 00000000000..2b6f0628d4e --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RunAwayTogether.java @@ -0,0 +1,71 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RunAwayTogether extends CardImpl { + + public RunAwayTogether(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); + + // Choose two target creatures controlled by different players. Return those creatures to their owners' hands. + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true)); + this.getSpellAbility().addTarget(new RunAwayTogetherTarget()); + } + + private RunAwayTogether(final RunAwayTogether card) { + super(card); + } + + @Override + public RunAwayTogether copy() { + return new RunAwayTogether(this); + } +} + +class RunAwayTogetherTarget extends TargetCreaturePermanent { + + RunAwayTogetherTarget() { + super(2, 2, StaticFilters.FILTER_PERMANENT_CREATURE, false); + } + + private RunAwayTogetherTarget(final RunAwayTogetherTarget target) { + super(target); + } + + @Override + public RunAwayTogetherTarget copy() { + return new RunAwayTogetherTarget(this); + } + + @Override + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { + if (!super.canTarget(controllerId, id, source, game)) { + return false; + } + Permanent creature = game.getPermanent(id); + if (creature == null) { + return false; + } + return !this.getTargets() + .stream() + .map(game::getPermanent) + .anyMatch(permanent -> permanent != null + && !creature.getId().equals(permanent.getId()) + && !creature.isControlledBy(permanent.getControllerId()) + ); + } +} +// give carly rae jepsen a sword \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index c284aa90098..e455f0dc5e1 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -33,6 +33,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Gilded Goose", 160, Rarity.RARE, mage.cards.g.GildedGoose.class)); cards.add(new SetCardInfo("Golden Egg", 220, Rarity.COMMON, mage.cards.g.GoldenEgg.class)); cards.add(new SetCardInfo("Maraleaf Pixie", 196, Rarity.UNCOMMON, mage.cards.m.MaraleafPixie.class)); + cards.add(new SetCardInfo("Run Away Together", 62, Rarity.COMMON, mage.cards.r.RunAwayTogether.class)); cards.add(new SetCardInfo("Tome Raider", 68, Rarity.COMMON, mage.cards.t.TomeRaider.class)); cards.add(new SetCardInfo("Wishful Merfolk", 73, Rarity.COMMON, mage.cards.w.WishfulMerfolk.class)); cards.add(new SetCardInfo("Witching Well", 74, Rarity.COMMON, mage.cards.w.WitchingWell.class));