From 33349b3d281538f4208bb795e5003f89493e132f Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 18 Jan 2023 21:00:32 -0500 Subject: [PATCH] [ONE] Implement Mirran Safehouse --- .../src/mage/cards/m/MirranSafehouse.java | 85 +++++++++++++++++++ .../src/mage/sets/PhyrexiaAllWillBeOne.java | 1 + 2 files changed, 86 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MirranSafehouse.java diff --git a/Mage.Sets/src/mage/cards/m/MirranSafehouse.java b/Mage.Sets/src/mage/cards/m/MirranSafehouse.java new file mode 100644 index 0000000000..5623a89ea1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MirranSafehouse.java @@ -0,0 +1,85 @@ +package mage.cards.m; + +import java.util.Collection; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +import mage.abilities.Ability; +import mage.abilities.ActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * @author TheElk801 + */ +public final class MirranSafehouse extends CardImpl { + + public MirranSafehouse(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + // As long as Mirran Safehouse is on the battlefield, it has all activated abilites of all land cards in all graveyards. + this.addAbility(new SimpleStaticAbility(new MirranSafehouseEffect())); + } + + private MirranSafehouse(final MirranSafehouse card) { + super(card); + } + + @Override + public MirranSafehouse copy() { + return new MirranSafehouse(this); + } +} + +class MirranSafehouseEffect extends ContinuousEffectImpl { + + MirranSafehouseEffect() { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + staticText = "As long as {this} is on the battlefield, " + + "it has all activated abilities of all land cards in all graveyards"; + this.dependendToTypes.add(DependencyType.AddingAbility); // Yixlid Jailer + } + + private MirranSafehouseEffect(final MirranSafehouseEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent == null) { + return false; + } + Set abilities = game + .getState() + .getPlayersInRange(source.getControllerId(), game) + .stream() + .map(game::getPlayer) + .filter(Objects::nonNull) + .map(Player::getGraveyard) + .map(graveyard -> graveyard.getCards(StaticFilters.FILTER_CARD_LAND, game)) + .flatMap(Collection::stream) + .map(card -> card.getAbilities(game)) + .flatMap(Collection::stream) + .filter(ActivatedAbility.class::isInstance) + .collect(Collectors.toSet()); + for (Ability ability : abilities) { + permanent.addAbility(ability, source.getSourceId(), game); + } + return true; + } + + @Override + public MirranSafehouseEffect copy() { + return new MirranSafehouseEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java index d7fdb1c1a1..9b99f90139 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java @@ -45,6 +45,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet { cards.add(new SetCardInfo("Migloz, Maze Crusher", 210, Rarity.RARE, mage.cards.m.MiglozMazeCrusher.class)); cards.add(new SetCardInfo("Mindsplice Apparatus", 63, Rarity.RARE, mage.cards.m.MindspliceApparatus.class)); cards.add(new SetCardInfo("Minor Misstep", 64, Rarity.UNCOMMON, mage.cards.m.MinorMisstep.class)); + cards.add(new SetCardInfo("Mirran Safehouse", 232, Rarity.RARE, mage.cards.m.MirranSafehouse.class)); cards.add(new SetCardInfo("Mirrex", 254, Rarity.RARE, mage.cards.m.Mirrex.class)); cards.add(new SetCardInfo("Mondrak, Glory Dominus", 23, Rarity.MYTHIC, mage.cards.m.MondrakGloryDominus.class)); cards.add(new SetCardInfo("Monument to Perfection", 233, Rarity.RARE, mage.cards.m.MonumentToPerfection.class));