fixed Kederekt Parasite dealing unpreventable damage
@@ -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;
/**
@@ -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,21 +99,17 @@ 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;
}
- }
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.";
}
}
-
