fixed Tyrant's Familiar not targeting correctly

This commit is contained in:
Evan Kranzler 2018-05-11 11:24:50 -04:00
parent d6ff7f851d
commit 25b10c4d67

View file

@ -41,10 +41,10 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.DefendingPlayerControlsPredicate;
import mage.target.TargetPermanent;
/**
*
@ -52,10 +52,15 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class TyrantsFamiliar extends CardImpl {
private final UUID originalId;
private static final FilterPermanent filter = new FilterPermanent("creature defending player controls");
static {
filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(new DefendingPlayerControlsPredicate());
}
public TyrantsFamiliar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{R}");
this.subtype.add(SubType.DRAGON);
this.power = new MageInt(5);
@ -69,32 +74,18 @@ public class TyrantsFamiliar extends CardImpl {
// Lieutenant - As long as you control your commander, Tyrant's Familiar gets +2/+2 and has "Whenever Tyrant's Familiar attacks, it deals 7 damage to target creature defending player controls."
Ability gainedAbility = new AttacksTriggeredAbility(new DamageTargetEffect(7, "it"), false);
gainedAbility.addTarget(new TargetCreaturePermanent());
gainedAbility.addTarget(new TargetPermanent(filter));
ContinuousEffect effect = new GainAbilitySourceEffect(gainedAbility);
effect.setText("and has \"Whenever {this} attacks, it deals 7 damage to target creature defending player controls\"");
originalId = gainedAbility.getOriginalId();
this.addAbility(new LieutenantAbility(effect));
}
public TyrantsFamiliar(final TyrantsFamiliar card) {
super(card);
this.originalId = card.originalId;
}
@Override
public TyrantsFamiliar copy() {
return new TyrantsFamiliar(this);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
ability.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId());
filter.add(new ControllerIdPredicate(defenderId));
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
ability.addTarget(target);
}
}
}