fixed Kederekt Parasite dealing unpreventable damage

This commit is contained in:
Evan Kranzler 2018-05-14 11:54:49 -04:00
parent e0bead005a
commit 00e953ed19

View file

@ -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.";
}
}