From 2ff41028a9fcff4344d58498f466ba6cd286fbb1 Mon Sep 17 00:00:00 2001 From: ciaccona007 Date: Sat, 18 Apr 2020 12:55:19 -0700 Subject: [PATCH 1/3] Implement Nesting Grounds --- .../src/mage/cards/n/NestingGrounds.java | 106 ++++++++++++++++++ .../src/mage/sets/Commander2020Edition.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/n/NestingGrounds.java 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)); From 9776faa1df81e7943690ac7532f3021b8b17a25b Mon Sep 17 00:00:00 2001 From: ciaccona007 Date: Sat, 18 Apr 2020 13:35:25 -0700 Subject: [PATCH 2/3] Nesting Grounds can't target the same permanent twice --- Mage.Sets/src/mage/cards/n/NestingGrounds.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/cards/n/NestingGrounds.java b/Mage.Sets/src/mage/cards/n/NestingGrounds.java index c605ace0ec..ab9f174ab6 100644 --- a/Mage.Sets/src/mage/cards/n/NestingGrounds.java +++ b/Mage.Sets/src/mage/cards/n/NestingGrounds.java @@ -17,10 +17,12 @@ import mage.counters.Counter; import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; +import mage.target.common.TargetControlledPermanent; import java.util.HashSet; import java.util.Set; @@ -28,7 +30,7 @@ import java.util.UUID; /** * - * @author anonymous + * @author ciaccona007 */ public final class NestingGrounds extends CardImpl { @@ -42,8 +44,16 @@ public final class NestingGrounds extends CardImpl { // {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"))); + TargetControlledPermanent target1 = new TargetControlledPermanent(new FilterControlledPermanent("permanent to remove counter from")); + target1.setTargetTag(1); + ability.addTarget(target1); + + FilterPermanent filter = new FilterPermanent("permanent to put counter on"); + filter.add(new AnotherTargetPredicate(2)); + TargetPermanent target2 = new TargetPermanent(filter); + target2.setTargetTag(2); + ability.addTarget(target2); + this.addAbility(ability); } From 27a351e92b37b75a691cc08f32db785bbf1398bd Mon Sep 17 00:00:00 2001 From: ciaccona007 Date: Sat, 18 Apr 2020 14:11:02 -0700 Subject: [PATCH 3/3] Nesting Grounds can't target the same permanent twice --- Mage.Sets/src/mage/cards/n/NestingGrounds.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/cards/n/NestingGrounds.java b/Mage.Sets/src/mage/cards/n/NestingGrounds.java index d5389ac3f7..6302b09b37 100644 --- a/Mage.Sets/src/mage/cards/n/NestingGrounds.java +++ b/Mage.Sets/src/mage/cards/n/NestingGrounds.java @@ -17,10 +17,12 @@ import mage.counters.Counter; import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; +import mage.target.common.TargetControlledPermanent; import java.util.HashSet; import java.util.Set; @@ -40,8 +42,16 @@ public final class NestingGrounds extends CardImpl { // {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 ActivateAsSorceryActivatedAbility(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"))); + TargetControlledPermanent target1 = new TargetControlledPermanent(new FilterControlledPermanent("permanent to remove counter from")); + target1.setTargetTag(1); + ability.addTarget(target1); + + FilterPermanent filter = new FilterPermanent("permanent to put counter on"); + filter.add(new AnotherTargetPredicate(2)); + TargetPermanent target2 = new TargetPermanent(filter); + target2.setTargetTag(2); + ability.addTarget(target2); + this.addAbility(ability); }