diff --git a/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java b/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java new file mode 100644 index 00000000000..eb897aafaab --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java @@ -0,0 +1,132 @@ +package mage.cards.n; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect; +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.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class NahirisLithoforming extends CardImpl { + + public NahirisLithoforming(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}"); + + // Sacrifice X lands. For each land sacrificed this way, draw a card. You may play X additional lands this turn. Lands you control enter the battlefield tapped this turn. + this.getSpellAbility().addEffect(new NahirisLithoformingSacrificeEffect()); + this.getSpellAbility().addEffect(new NahirisLithoformingTappedEffect()); + } + + private NahirisLithoforming(final NahirisLithoforming card) { + super(card); + } + + @Override + public NahirisLithoforming copy() { + return new NahirisLithoforming(this); + } +} + +class NahirisLithoformingSacrificeEffect extends OneShotEffect { + + NahirisLithoformingSacrificeEffect() { + super(Outcome.Benefit); + staticText = "Sacrifice X lands. For each land sacrificed this way, draw a card. " + + "You may play X additional lands this turn."; + } + + private NahirisLithoformingSacrificeEffect(final NahirisLithoformingSacrificeEffect effect) { + super(effect); + } + + @Override + public NahirisLithoformingSacrificeEffect copy() { + return new NahirisLithoformingSacrificeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || source.getManaCostsToPay().getX() == 0) { + return false; + } + int landCount = game.getBattlefield().count( + StaticFilters.FILTER_CONTROLLED_LAND_SHORT_TEXT, + source.getSourceId(), source.getControllerId(), game + ); + landCount = Math.min(source.getManaCostsToPay().getX(), landCount); + TargetPermanent target = new TargetPermanent( + landCount, landCount, StaticFilters.FILTER_CONTROLLED_LAND_SHORT_TEXT, true + ); + player.choose(outcome, target, source.getSourceId(), game); + int counter = 0; + for (UUID permanentId : target.getTargets()) { + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null && permanent.sacrifice(source.getSourceId(), game)) { + counter++; + } + } + player.drawCards(counter, source.getSourceId(), game); + game.addEffect(new PlayAdditionalLandsControllerEffect( + source.getManaCostsToPay().getX(), Duration.EndOfTurn + ), source); + return true; + } +} + +class NahirisLithoformingTappedEffect extends ReplacementEffectImpl { + + NahirisLithoformingTappedEffect() { + super(Duration.EndOfTurn, Outcome.Tap); + staticText = "Lands you control enter the battlefield tapped this turn."; + } + + NahirisLithoformingTappedEffect(final NahirisLithoformingTappedEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent target = ((EntersTheBattlefieldEvent) event).getTarget(); + if (target != null) { + target.setTapped(true); + } + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (source.getControllerId().equals(event.getPlayerId())) { + Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); + if (permanent != null && permanent.isLand()) { + return true; + } + } + return false; + } + + @Override + public NahirisLithoformingTappedEffect copy() { + return new NahirisLithoformingTappedEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ZendikarRising.java b/Mage.Sets/src/mage/sets/ZendikarRising.java index aa18e963c70..4d6f6e0d240 100644 --- a/Mage.Sets/src/mage/sets/ZendikarRising.java +++ b/Mage.Sets/src/mage/sets/ZendikarRising.java @@ -186,6 +186,7 @@ public final class ZendikarRising extends ExpansionSet { cards.add(new SetCardInfo("Murasa Rootgrazer", 229, Rarity.UNCOMMON, mage.cards.m.MurasaRootgrazer.class)); cards.add(new SetCardInfo("Murasa Sproutling", 196, Rarity.UNCOMMON, mage.cards.m.MurasaSproutling.class)); cards.add(new SetCardInfo("Murkwater Pathway", 260, Rarity.RARE, mage.cards.m.MurkwaterPathway.class)); + cards.add(new SetCardInfo("Nahiri's Lithoforming", 151, Rarity.RARE, mage.cards.n.NahirisLithoforming.class)); cards.add(new SetCardInfo("Nahiri, Heir of the Ancients", 230, Rarity.MYTHIC, mage.cards.n.NahiriHeirOfTheAncients.class)); cards.add(new SetCardInfo("Needleverge Pathway", 263, Rarity.RARE, mage.cards.n.NeedlevergePathway.class)); cards.add(new SetCardInfo("Nighthawk Scavenger", 115, Rarity.RARE, mage.cards.n.NighthawkScavenger.class));