diff --git a/Mage.Sets/src/mage/cards/m/MadDog.java b/Mage.Sets/src/mage/cards/m/MadDog.java index a0eb9e4ad4d..d451b2813c8 100644 --- a/Mage.Sets/src/mage/cards/m/MadDog.java +++ b/Mage.Sets/src/mage/cards/m/MadDog.java @@ -1,14 +1,14 @@ package mage.cards.m; -import java.util.List; -import java.util.Set; import java.util.UUID; import mage.MageInt; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; import mage.abilities.condition.Condition; +import mage.abilities.condition.InvertCondition; +import mage.abilities.condition.OrCondition; +import mage.abilities.condition.common.AttackedThisTurnSourceCondition; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.effects.common.SacrificeSourceEffect; import mage.constants.SubType; @@ -19,12 +19,11 @@ import mage.constants.TargetController; import mage.game.Game; import mage.game.permanent.Permanent; import mage.watchers.common.AttackedThisTurnWatcher; -import mage.watchers.common.PermanentsEnteredBattlefieldWatcher; /** - * - * @author jeffwadsworth + * @author xenohedron */ + public final class MadDog extends CardImpl { public MadDog(UUID ownerId, CardSetInfo setInfo) { @@ -35,9 +34,11 @@ public final class MadDog extends CardImpl { this.toughness = new MageInt(2); // At the beginning of your end step, if Mad Dog didn't attack or come under your control this turn, sacrifice it. - Ability ability = new ConditionalInterveningIfTriggeredAbility(new BeginningOfEndStepTriggeredAbility(new SacrificeSourceEffect(), TargetController.YOU, false), MadDogCondition.instance, "At the beginning of your end step, if {this} didn't attack or come under your control this turn, sacrifice it"); + Condition condition = new InvertCondition(new OrCondition(AttackedThisTurnSourceCondition.instance, MadDogCondition.instance)); + Ability ability = new ConditionalInterveningIfTriggeredAbility(new BeginningOfEndStepTriggeredAbility( + new SacrificeSourceEffect(), TargetController.YOU, false), condition, + "At the beginning of your end step, if {this} didn't attack or come under your control this turn, sacrifice it"); ability.addWatcher(new AttackedThisTurnWatcher()); - ability.addWatcher(new PermanentsEnteredBattlefieldWatcher()); this.addAbility(ability); } @@ -57,23 +58,8 @@ enum MadDogCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - Permanent madDog = game.getPermanent(source.getSourceId()); - PermanentsEnteredBattlefieldWatcher watcher = game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); - AttackedThisTurnWatcher watcher2 = game.getState().getWatcher(AttackedThisTurnWatcher.class); - if (watcher != null - && watcher2 != null - && madDog != null) { - // For some reason, compare did not work when checking the lists. Thus the interation. - List permanents = watcher.getThisTurnEnteringPermanents(source.getControllerId()); - if (permanents.stream().anyMatch((p) -> (p.getId().equals(madDog.getId())))) { - return false; - } - Set mor = watcher2.getAttackedThisTurnCreatures(); - if (mor.stream().anyMatch((m) -> (m.getPermanent(game).equals(madDog)))) { - return false; - } - return true; // Mad Dog did not come into play this turn nor did he attack this turn. Sacrifice the hound. - } - return false; + Permanent permanent = source.getSourcePermanentOrLKI(game); + // TRUE if came under your control this turn + return permanent != null && !permanent.wasControlledFromStartOfControllerTurn(); } }