From 00e953ed19ae1bf942a64e95731671e43946d5c8 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 14 May 2018 11:54:49 -0400 Subject: [PATCH] fixed Kederekt Parasite dealing unpreventable damage --- .../src/mage/cards/k/KederektParasite.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Mage.Sets/src/mage/cards/k/KederektParasite.java b/Mage.Sets/src/mage/cards/k/KederektParasite.java index 5033645889..ac7309829d 100644 --- a/Mage.Sets/src/mage/cards/k/KederektParasite.java +++ b/Mage.Sets/src/mage/cards/k/KederektParasite.java @@ -29,17 +29,21 @@ package mage.cards.k; import java.util.UUID; import mage.MageInt; +import mage.ObjectColor; import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.ComparisonType; import mage.constants.SubType; import mage.constants.Zone; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.ColorPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; -import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; /** @@ -49,7 +53,7 @@ import mage.target.targetpointer.FixedTarget; public class KederektParasite extends CardImpl { public KederektParasite(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}"); this.subtype.add(SubType.HORROR); this.power = new MageInt(1); @@ -71,8 +75,14 @@ public class KederektParasite extends CardImpl { class KederektParasiteTriggeredAbility extends TriggeredAbilityImpl { + private static final FilterControlledPermanent filter = new FilterControlledPermanent(); + + static { + filter.add(new ColorPredicate(ObjectColor.RED)); + } + KederektParasiteTriggeredAbility() { - super(Zone.BATTLEFIELD, new DamageTargetEffect(1, false, "opponent"), true); + super(Zone.BATTLEFIELD, new DamageTargetEffect(1, true, "opponent"), true); } KederektParasiteTriggeredAbility(final KederektParasiteTriggeredAbility ability) { @@ -89,20 +99,16 @@ class KederektParasiteTriggeredAbility extends TriggeredAbilityImpl { return event.getType() == EventType.DREW_CARD; } + @Override + public boolean checkInterveningIfClause(Game game) { + return new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.EQUAL_TO, 0).apply(game, this); + } + @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(this.getControllerId()).contains(event.getPlayerId())) { - boolean youControlRedPermanent = false; - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(this.getControllerId())) { - if (permanent.getColor(game).isRed()) { - youControlRedPermanent = true; - break; - } - } - if (youControlRedPermanent) { - getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); - return true; - } + getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); + return true; } return false; } @@ -112,4 +118,3 @@ class KederektParasiteTriggeredAbility extends TriggeredAbilityImpl { return "Whenever an opponent draws a card, if you control a red permanent, you may have {this} deal 1 damage to that player."; } } -