[TDM] Implement Warden of the Grove

This commit is contained in:
theelk801 2025-04-08 08:44:31 -04:00
parent 0df5f17603
commit 235e5200d0
3 changed files with 103 additions and 4 deletions

View file

@ -0,0 +1,91 @@
package mage.cards.w;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.keyword.EndureSourceEffect;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.counters.Counters;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class WardenOfTheGrove extends CardImpl {
private static final FilterPermanent filter
= new FilterControlledCreaturePermanent("another nontoken creature you control");
static {
filter.add(AnotherPredicate.instance);
filter.add(TokenPredicate.FALSE);
}
public WardenOfTheGrove(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
this.subtype.add(SubType.HYDRA);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// At the beginning of your end step, put a +1/+1 counter on this creature.
this.addAbility(new BeginningOfEndStepTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance())));
// Whenever another nontoken creature you control enters, it endures X, where X is the number of counters on this creature.
this.addAbility(new EntersBattlefieldAllTriggeredAbility(
Zone.BATTLEFIELD, new WardenOfTheGroveEffect(),
filter, false, SetTargetPointer.PERMANENT
));
}
private WardenOfTheGrove(final WardenOfTheGrove card) {
super(card);
}
@Override
public WardenOfTheGrove copy() {
return new WardenOfTheGrove(this);
}
}
class WardenOfTheGroveEffect extends OneShotEffect {
WardenOfTheGroveEffect() {
super(Outcome.Benefit);
staticText = "it endures X, where X is the number of counters on {this}";
}
private WardenOfTheGroveEffect(final WardenOfTheGroveEffect effect) {
super(effect);
}
@Override
public WardenOfTheGroveEffect copy() {
return new WardenOfTheGroveEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return EndureSourceEffect.doEndure(
this.getTargetPointer().getFirstTargetPermanentOrLKI(game, source),
Optional.ofNullable(source.getSourcePermanentOrLKI(game))
.map(p -> p.getCounters(game))
.map(Counters::getTotalCount)
.orElse(0),
game, source
);
}
}

View file

@ -247,6 +247,7 @@ public final class TarkirDragonstorm extends ExpansionSet {
cards.add(new SetCardInfo("Voice of Victory", 33, Rarity.RARE, mage.cards.v.VoiceOfVictory.class));
cards.add(new SetCardInfo("War Effort", 131, Rarity.UNCOMMON, mage.cards.w.WarEffort.class));
cards.add(new SetCardInfo("Wail of War", 98, Rarity.UNCOMMON, mage.cards.w.WailOfWar.class));
cards.add(new SetCardInfo("Warden of the Grove", 166, Rarity.RARE, mage.cards.w.WardenOfTheGrove.class));
cards.add(new SetCardInfo("Watcher of the Wayside", 249, Rarity.COMMON, mage.cards.w.WatcherOfTheWayside.class));
cards.add(new SetCardInfo("Wayspeaker Bodyguard", 34, Rarity.UNCOMMON, mage.cards.w.WayspeakerBodyguard.class));
cards.add(new SetCardInfo("Wild Ride", 132, Rarity.COMMON, mage.cards.w.WildRide.class));

View file

@ -39,12 +39,19 @@ public class EndureSourceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return doEndure(source.getSourcePermanentOrLKI(game), 1, game, source);
}
public static boolean doEndure(Permanent permanent, int amount, Game game, Ability source) {
if (permanent == null || amount < 1) {
return false;
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null && player.chooseUse(
Player controller = game.getPlayer(permanent.getControllerId());
if (controller == null) {
return false;
}
if (permanent.getZoneChangeCounter(game) == game.getState().getZoneChangeCounter(permanent.getId())
&& controller.chooseUse(
Outcome.BoostCreature, "Put " + CardUtil.numberToText(amount, "a") + " +1/+1 counter" +
(amount > 1 ? "s" : "") + " on " + permanent.getName() + " or create " +
CardUtil.addArticle("" + amount) + ' ' + amount + '/' + amount + " Spirit token?",