diff --git a/Mage.Sets/src/mage/cards/n/NestingGrounds.java b/Mage.Sets/src/mage/cards/n/NestingGrounds.java new file mode 100644 index 0000000000..c605ace0ec --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NestingGrounds.java @@ -0,0 +1,106 @@ +package mage.cards.n; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.mana.ColorlessManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.counters.Counter; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * + * @author anonymous + */ +public final class NestingGrounds extends CardImpl { + + public NestingGrounds(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); + + + // {T}: Add {C}. + this.addAbility(new ColorlessManaAbility()); + + // {1}, {T}: Move a counter from target permanent you control onto another target permanent. Activate this ability only any time you could cast a sorcery. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new NestingGroundsEffect(), new GenericManaCost(1)); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetPermanent(new FilterControlledPermanent("permanent to remove counter from"))); + ability.addTarget(new TargetPermanent(new FilterPermanent("permanent to put counter on"))); + this.addAbility(ability); + } + + private NestingGrounds(final NestingGrounds card) { + super(card); + } + + @Override + public NestingGrounds copy() { + return new NestingGrounds(this); + } +} + +class NestingGroundsEffect extends OneShotEffect { + + public NestingGroundsEffect() { + super(Outcome.AIDontUseIt); + this.staticText = "Move a counter from target permanent you control onto another target permanent"; + } + + public NestingGroundsEffect(final mage.cards.n.NestingGroundsEffect effect) { + super(effect); + } + + @Override + public mage.cards.n.NestingGroundsEffect copy() { + return new mage.cards.n.NestingGroundsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent fromPermanent = game.getPermanent(source.getFirstTarget()); + Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); + if (fromPermanent == null + || toPermanent == null + || controller == null) { + return false; + } + Choice choice = new ChoiceImpl(); + Set possibleChoices = new HashSet<>(); + for (String counterName : fromPermanent.getCounters(game).keySet()) { + possibleChoices.add(counterName); + } + choice.setChoices(possibleChoices); + if (controller.choose(outcome, choice, game)) { + String chosen = choice.getChoice(); + if (fromPermanent.getCounters(game).containsKey(chosen)) { + CounterType counterType = CounterType.findByName(chosen); + if (counterType != null) { + Counter counter = counterType.createInstance(); + fromPermanent.removeCounters(counter, game); + toPermanent.addCounters(counter, source, game); + return true; + } + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2020Edition.java b/Mage.Sets/src/mage/sets/Commander2020Edition.java index e6b0138c5c..515d124177 100644 --- a/Mage.Sets/src/mage/sets/Commander2020Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2020Edition.java @@ -204,6 +204,7 @@ public final class Commander2020Edition extends ExpansionSet { cards.add(new SetCardInfo("Mystic Monastery", 293, Rarity.UNCOMMON, mage.cards.m.MysticMonastery.class)); cards.add(new SetCardInfo("Nahiri, the Harbinger", 223, Rarity.MYTHIC, mage.cards.n.NahiriTheHarbinger.class)); cards.add(new SetCardInfo("Natural Connection", 184, Rarity.COMMON, mage.cards.n.NaturalConnection.class)); + cards.add(new SetCardInfo("Nesting Grounds", 71, Rarity.RARE, mage.cards.n.NestingGrounds.class)); cards.add(new SetCardInfo("Netherborn Altar", 45, Rarity.RARE, mage.cards.n.NetherbornAltar.class)); cards.add(new SetCardInfo("New Perspectives", 119, Rarity.RARE, mage.cards.n.NewPerspectives.class)); cards.add(new SetCardInfo("Niblis of Frost", 120, Rarity.RARE, mage.cards.n.NiblisOfFrost.class));