From 28dfaaffa17e5dbd56d08ee0d9d5eda2fe780094 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 4 May 2021 18:32:17 -0400 Subject: [PATCH] [C21] fixed issues with Nils, Discipline Enforcer (fixes #7800) --- .../mage/cards/n/NilsDisciplineEnforcer.java | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java b/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java index 4496272c95..4d3d39bdea 100644 --- a/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java +++ b/Mage.Sets/src/mage/cards/n/NilsDisciplineEnforcer.java @@ -6,25 +6,24 @@ import mage.abilities.common.BeginningOfEndStepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.combat.CantAttackYouUnlessPayManaAllEffect; -import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.SuperType; -import mage.constants.TargetController; +import mage.constants.*; import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.target.Target; import mage.target.TargetPermanent; import mage.target.targetadjustment.TargetAdjuster; -import mage.target.targetpointer.EachTargetPointer; +import java.util.Objects; import java.util.UUID; /** @@ -43,10 +42,7 @@ public final class NilsDisciplineEnforcer extends CardImpl { // At the beginning of your end step, for each player, put a +1/+1 counter on up to one target creature that player controls. Ability ability = new BeginningOfEndStepTriggeredAbility( - new AddCountersTargetEffect(CounterType.P1P1.createInstance()) - .setTargetPointer(new EachTargetPointer()) - .setText("for each player, put a +1/+1 counter on up to one target creature that player controls"), - TargetController.YOU, false + new NilsDisciplineEnforcerEffect(), TargetController.YOU, false ); ability.setTargetAdjuster(NilsDisciplineEnforcerAdjuster.instance); this.addAbility(ability); @@ -77,11 +73,43 @@ enum NilsDisciplineEnforcerAdjuster implements TargetAdjuster { continue; } FilterPermanent filter = new FilterCreaturePermanent("creature controlled by " + player.getName()); + filter.add(new ControllerIdPredicate(playerId)); ability.addTarget(new TargetPermanent(0, 1, filter)); } } } +class NilsDisciplineEnforcerCountersEffect extends OneShotEffect { + + NilsDisciplineEnforcerCountersEffect() { + super(Outcome.Benefit); + staticText = "for each player, put a +1/+1 counter on up to one target creature that player controls"; + } + + private NilsDisciplineEnforcerCountersEffect(final NilsDisciplineEnforcerCountersEffect effect) { + super(effect); + } + + @Override + public NilsDisciplineEnforcerCountersEffect copy() { + return new NilsDisciplineEnforcerCountersEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + source.getTargets() + .stream() + .map(Target::getFirstTarget) + .map(game::getPermanent) + .filter(Objects::nonNull) + .map(permanent -> permanent.addCounters( + CounterType.P1P1.createInstance(), + source.getControllerId(), source, game + )); + return true; + } +} + class NilsDisciplineEnforcerEffect extends CantAttackYouUnlessPayManaAllEffect { NilsDisciplineEnforcerEffect() {