diff --git a/Mage.Sets/src/mage/cards/m/MemorialVault.java b/Mage.Sets/src/mage/cards/m/MemorialVault.java new file mode 100644 index 00000000000..4f7bcd98b4c --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MemorialVault.java @@ -0,0 +1,78 @@ +package mage.cards.m; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTopXMayPlayUntilEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.Collection; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MemorialVault extends CardImpl { + + public MemorialVault(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}{R}"); + + // {T}, Sacrifice another artifact: Exile the top X cards of your library, where X is one plus the mana value of the sacrificed artifact. You may play those cards this turn. + Ability ability = new SimpleActivatedAbility(new MemorialVaultEffect(), new TapSourceCost()); + ability.addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_ANOTHER_ARTIFACT)); + this.addAbility(ability); + } + + private MemorialVault(final MemorialVault card) { + super(card); + } + + @Override + public MemorialVault copy() { + return new MemorialVault(this); + } +} + +class MemorialVaultEffect extends OneShotEffect { + + MemorialVaultEffect() { + super(Outcome.Benefit); + staticText = "exile the top X cards of your library, where X is one plus " + + "the mana value of the sacrificed artifact. You may play those cards this turn"; + } + + private MemorialVaultEffect(final MemorialVaultEffect effect) { + super(effect); + } + + @Override + public MemorialVaultEffect copy() { + return new MemorialVaultEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int xValue = 1 + CardUtil + .castStream(source.getCosts(), SacrificeTargetCost.class) + .map(SacrificeTargetCost::getPermanents) + .flatMap(Collection::stream) + .mapToInt(MageObject::getManaValue) + .sum(); + return new ExileTopXMayPlayUntilEffect(xValue, Duration.EndOfTurn).apply(game, source); + } +} diff --git a/Mage.Sets/src/mage/sets/EdgeOfEternities.java b/Mage.Sets/src/mage/sets/EdgeOfEternities.java index 45e96c564d9..5076cb68b5a 100644 --- a/Mage.Sets/src/mage/sets/EdgeOfEternities.java +++ b/Mage.Sets/src/mage/sets/EdgeOfEternities.java @@ -211,6 +211,8 @@ public final class EdgeOfEternities extends ExpansionSet { cards.add(new SetCardInfo("Meltstrider's Gear", 198, Rarity.COMMON, mage.cards.m.MeltstridersGear.class)); cards.add(new SetCardInfo("Meltstrider's Resolve", 199, Rarity.UNCOMMON, mage.cards.m.MeltstridersResolve.class)); cards.add(new SetCardInfo("Memorial Team Leader", 144, Rarity.UNCOMMON, mage.cards.m.MemorialTeamLeader.class)); + cards.add(new SetCardInfo("Memorial Vault", 145, Rarity.RARE, mage.cards.m.MemorialVault.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Memorial Vault", 336, Rarity.RARE, mage.cards.m.MemorialVault.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mental Modulation", 67, Rarity.COMMON, mage.cards.m.MentalModulation.class)); cards.add(new SetCardInfo("Mightform Harmonizer", 200, Rarity.RARE, mage.cards.m.MightformHarmonizer.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mightform Harmonizer", 297, Rarity.RARE, mage.cards.m.MightformHarmonizer.class, NON_FULL_USE_VARIOUS));