[MOM] Implement Elvish Vatkeeper

This commit is contained in:
theelk801 2023-04-04 08:16:37 -04:00
parent 1cf060d291
commit 96cf6b2927
5 changed files with 161 additions and 60 deletions

View file

@ -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);
}
}

View file

@ -4,23 +4,19 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; 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.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.TokenPredicate; import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID; 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)); ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE));
// * Transform target Incubator token you control. // * 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); this.addAbility(ability);
} }
@ -63,28 +59,3 @@ public final class SeedpodCaretaker extends CardImpl {
return new SeedpodCaretaker(this); 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);
}
}

View file

@ -1,20 +1,16 @@
package mage.cards.w; package mage.cards.w;
import mage.abilities.Ability; import mage.abilities.effects.common.TransformTargetEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import java.util.UUID; import java.util.UUID;
@ -30,7 +26,7 @@ public final class WaxingMoon extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
// Transform up to one target Werewolf you control. // 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)); this.getSpellAbility().addTarget(new TargetPermanent(0, 1, filter));
// Creatures you control gain trample until end of turn. // Creatures you control gain trample until end of turn.
@ -49,26 +45,3 @@ public final class WaxingMoon extends CardImpl {
return new WaxingMoon(this); 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);
}
}

View file

@ -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("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("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("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("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("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)); cards.add(new SetCardInfo("Faerie Mastermind", 58, Rarity.RARE, mage.cards.f.FaerieMastermind.class));

View file

@ -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();
}
}