From 96cf6b2927484ca59c1e8a2b0a7f4b912dc78ed2 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Tue, 4 Apr 2023 08:16:37 -0400 Subject: [PATCH] [MOM] Implement Elvish Vatkeeper --- .../src/mage/cards/e/ElvishVatkeeper.java | 90 +++++++++++++++++++ .../src/mage/cards/s/SeedpodCaretaker.java | 33 +------ Mage.Sets/src/mage/cards/w/WaxingMoon.java | 31 +------ .../src/mage/sets/MarchOfTheMachine.java | 1 + .../effects/common/TransformTargetEffect.java | 66 ++++++++++++++ 5 files changed, 161 insertions(+), 60 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/e/ElvishVatkeeper.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/TransformTargetEffect.java diff --git a/Mage.Sets/src/mage/cards/e/ElvishVatkeeper.java b/Mage.Sets/src/mage/cards/e/ElvishVatkeeper.java new file mode 100644 index 0000000000..d81b28a8c0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ElvishVatkeeper.java @@ -0,0 +1,90 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TransformTargetEffect; +import mage.abilities.effects.keyword.IncubateEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ElvishVatkeeper extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledPermanent( + SubType.INCUBATOR, "Incubator token you control" + ); + + static { + filter.add(TokenPredicate.TRUE); + } + + public ElvishVatkeeper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{G}"); + + this.subtype.add(SubType.PHYREXIAN); + this.subtype.add(SubType.ELF); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // When Elvish Vatkeeper enters the battlefield, incubate 2. + this.addAbility(new EntersBattlefieldTriggeredAbility(new IncubateEffect(2))); + + // {5}: Transform target Incubator token you control. Double the number of +1/+1 counters on it. + Ability ability = new SimpleActivatedAbility(new TransformTargetEffect(), new GenericManaCost(5)); + ability.addEffect(new ElvishVatkeeperEffect()); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + } + + private ElvishVatkeeper(final ElvishVatkeeper card) { + super(card); + } + + @Override + public ElvishVatkeeper copy() { + return new ElvishVatkeeper(this); + } +} + +class ElvishVatkeeperEffect extends OneShotEffect { + + ElvishVatkeeperEffect() { + super(Outcome.Benefit); + staticText = "double the number of +1/+1 counters on it"; + } + + private ElvishVatkeeperEffect(final ElvishVatkeeperEffect effect) { + super(effect); + } + + @Override + public ElvishVatkeeperEffect copy() { + return new ElvishVatkeeperEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + return permanent != null && permanent.addCounters(CounterType.P1P1.createInstance( + permanent.getCounters(game).getCount(CounterType.P1P1) + ), source.getControllerId(), source, game); + } +} diff --git a/Mage.Sets/src/mage/cards/s/SeedpodCaretaker.java b/Mage.Sets/src/mage/cards/s/SeedpodCaretaker.java index 71260a12e5..43b0b195f5 100644 --- a/Mage.Sets/src/mage/cards/s/SeedpodCaretaker.java +++ b/Mage.Sets/src/mage/cards/s/SeedpodCaretaker.java @@ -4,23 +4,19 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TransformTargetEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.StaticFilters; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.permanent.TokenPredicate; -import mage.game.Game; import mage.target.TargetPermanent; -import java.util.Objects; -import java.util.Optional; import java.util.UUID; /** @@ -50,7 +46,7 @@ public final class SeedpodCaretaker extends CardImpl { ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE)); // * Transform target Incubator token you control. - ability.addMode(new Mode(new SeedpodCaretakerEffect()).addTarget(new TargetPermanent(filter))); + ability.addMode(new Mode(new TransformTargetEffect()).addTarget(new TargetPermanent(filter))); this.addAbility(ability); } @@ -63,28 +59,3 @@ public final class SeedpodCaretaker extends CardImpl { return new SeedpodCaretaker(this); } } - -class SeedpodCaretakerEffect extends OneShotEffect { - - SeedpodCaretakerEffect() { - super(Outcome.Benefit); - staticText = "transform target Incubator token you control"; - } - - private SeedpodCaretakerEffect(final SeedpodCaretakerEffect effect) { - super(effect); - } - - @Override - public SeedpodCaretakerEffect copy() { - return new SeedpodCaretakerEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - return Optional - .ofNullable(game.getPermanent(getTargetPointer().getFirst(game, source))) - .filter(Objects::nonNull).map(permanent -> permanent.transform(source, game)) - .orElse(null); - } -} diff --git a/Mage.Sets/src/mage/cards/w/WaxingMoon.java b/Mage.Sets/src/mage/cards/w/WaxingMoon.java index d3b293fb03..47afae4699 100644 --- a/Mage.Sets/src/mage/cards/w/WaxingMoon.java +++ b/Mage.Sets/src/mage/cards/w/WaxingMoon.java @@ -1,20 +1,16 @@ package mage.cards.w; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TransformTargetEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.SubType; import mage.filter.FilterPermanent; import mage.filter.StaticFilters; import mage.filter.common.FilterControlledPermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import java.util.UUID; @@ -30,7 +26,7 @@ public final class WaxingMoon extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); // Transform up to one target Werewolf you control. - this.getSpellAbility().addEffect(new WaxingMoonEffect()); + this.getSpellAbility().addEffect(new TransformTargetEffect()); this.getSpellAbility().addTarget(new TargetPermanent(0, 1, filter)); // Creatures you control gain trample until end of turn. @@ -49,26 +45,3 @@ public final class WaxingMoon extends CardImpl { return new WaxingMoon(this); } } - -class WaxingMoonEffect extends OneShotEffect { - - WaxingMoonEffect() { - super(Outcome.Benefit); - staticText = "transform up to one target Werewolf you control"; - } - - private WaxingMoonEffect(final WaxingMoonEffect effect) { - super(effect); - } - - @Override - public WaxingMoonEffect copy() { - return new WaxingMoonEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getFirstTarget()); - return permanent != null && permanent.transform(source, game); - } -} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index ecc19e5e76..add644334a 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -48,6 +48,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Dismal Backwater", 269, Rarity.COMMON, mage.cards.d.DismalBackwater.class)); cards.add(new SetCardInfo("Dusk Legion Duelist", 11, Rarity.RARE, mage.cards.d.DuskLegionDuelist.class)); cards.add(new SetCardInfo("Elspeth's Smite", 13, Rarity.UNCOMMON, mage.cards.e.ElspethsSmite.class)); + cards.add(new SetCardInfo("Elvish Vatkeeper", 223, Rarity.UNCOMMON, mage.cards.e.ElvishVatkeeper.class)); cards.add(new SetCardInfo("Errant and Giada", 224, Rarity.RARE, mage.cards.e.ErrantAndGiada.class)); cards.add(new SetCardInfo("Essence of Orthodoxy", 323, Rarity.RARE, mage.cards.e.EssenceOfOrthodoxy.class)); cards.add(new SetCardInfo("Faerie Mastermind", 58, Rarity.RARE, mage.cards.f.FaerieMastermind.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/TransformTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TransformTargetEffect.java new file mode 100644 index 0000000000..31f2acfa63 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/TransformTargetEffect.java @@ -0,0 +1,66 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.Target; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class TransformTargetEffect extends OneShotEffect { + + public TransformTargetEffect() { + super(Outcome.Transform); + } + + public TransformTargetEffect(final TransformTargetEffect effect) { + super(effect); + } + + @Override + public TransformTargetEffect copy() { + return new TransformTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID targetId : getTargetPointer().getTargets(game, source)) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (permanent != null) { + permanent.transform(source, game); + } + } + return true; + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + StringBuilder sb = new StringBuilder("transform "); + Target target = mode.getTargets().get(0); + if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE + && target.getMinNumberOfTargets() == 0) { + sb.append("any number of "); + } else { + if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) { + sb.append("up to "); + } + sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(' '); + } + String targetName = mode.getTargets().get(0).getTargetName(); + if (!targetName.contains("target ")) { + sb.append("target "); + } + sb.append(targetName); + return sb.toString(); + } +}