From aa2215fefb5b86cb8ce91335fbef698c791af35a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 23 Apr 2022 16:37:09 -0400 Subject: [PATCH] [SNC] Implemented Mysterious Limousine --- .../src/mage/cards/m/MysteriousLimousine.java | 108 ++++++++++++++++++ .../src/mage/sets/StreetsOfNewCapenna.java | 1 + Mage/src/main/java/mage/game/Exile.java | 3 +- 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/m/MysteriousLimousine.java diff --git a/Mage.Sets/src/mage/cards/m/MysteriousLimousine.java b/Mage.Sets/src/mage/cards/m/MysteriousLimousine.java new file mode 100644 index 0000000000..e266bf2d23 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MysteriousLimousine.java @@ -0,0 +1,108 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility; +import mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.keyword.CrewAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.game.ExileZone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MysteriousLimousine extends CardImpl { + + private static final FilterPermanent filter = new FilterCreaturePermanent("other creature"); + + static { + filter.add(AnotherPredicate.instance); + } + + public MysteriousLimousine(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}{W}{W}"); + + this.subtype.add(SubType.VEHICLE); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Whenever Mysterious Limousine enters the battlefield or attacks, exile up to one other target creature until Mysterious Limousine leaves the battlefield. If a creature is put into exile this way, return each other card exiled with Mysterious Limousine to the battlefield under its owner's control. + Ability ability = new EntersBattlefieldOrAttacksSourceTriggeredAbility(new MysteriousLimousineEffect()); + ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new OnLeaveReturnExiledToBattlefieldAbility())); + ability.addTarget(new TargetPermanent(0, 1, filter)); + this.addAbility(ability); + + // Crew 2 + this.addAbility(new CrewAbility(2)); + } + + private MysteriousLimousine(final MysteriousLimousine card) { + super(card); + } + + @Override + public MysteriousLimousine copy() { + return new MysteriousLimousine(this); + } +} + +class MysteriousLimousineEffect extends OneShotEffect { + + MysteriousLimousineEffect() { + super(Outcome.Benefit); + staticText = "exile up to one other target creature until {this} leaves the battlefield. " + + "If a creature is put into exile this way, return each other card exiled " + + "with {this} to the battlefield under its owner's control"; + } + + private MysteriousLimousineEffect(final MysteriousLimousineEffect effect) { + super(effect); + } + + @Override + public MysteriousLimousineEffect copy() { + return new MysteriousLimousineEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (player == null || permanent == null) { + return false; + } + UUID exileId = CardUtil.getExileZoneId(game, source); + Cards cards = new CardsImpl(); + ExileZone exileZone = game.getExile().getExileZone(exileId); + if (exileZone != null) { + cards.addAll(exileZone); + } + player.moveCardsToExile(permanent, source, game, true, exileId, CardUtil.getSourceName(game, source)); + if (!cards.isEmpty()) { + player.moveCards( + cards.getCards(game), Zone.BATTLEFIELD, source, game, + false, false, true, null + ); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index 6929bfe020..291d2f0427 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -173,6 +173,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Mountain", 268, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mr. Orfeo, the Boulder", 204, Rarity.UNCOMMON, mage.cards.m.MrOrfeoTheBoulder.class)); cards.add(new SetCardInfo("Murder", 88, Rarity.COMMON, mage.cards.m.Murder.class)); + cards.add(new SetCardInfo("Mysterious Limousine", 22, Rarity.RARE, mage.cards.m.MysteriousLimousine.class)); cards.add(new SetCardInfo("Night Clubber", 89, Rarity.UNCOMMON, mage.cards.n.NightClubber.class)); cards.add(new SetCardInfo("Nimble Larcenist", 205, Rarity.UNCOMMON, mage.cards.n.NimbleLarcenist.class)); cards.add(new SetCardInfo("Ob Nixilis, the Adversary", 206, Rarity.MYTHIC, mage.cards.o.ObNixilisTheAdversary.class)); diff --git a/Mage/src/main/java/mage/game/Exile.java b/Mage/src/main/java/mage/game/Exile.java index 2c9a73fd7d..bc0427ffe5 100644 --- a/Mage/src/main/java/mage/game/Exile.java +++ b/Mage/src/main/java/mage/game/Exile.java @@ -49,8 +49,7 @@ public class Exile implements Serializable, Copyable { } private ExileZone createZone(UUID id, String name, boolean hidden) { - exileZones.putIfAbsent(id, new ExileZone(id, name, hidden)); - return exileZones.get(id); + return exileZones.computeIfAbsent(id, x -> new ExileZone(id, name, hidden)); } public ExileZone getExileZone(UUID id) {