updated Citadel Siege targeting

This commit is contained in:
Evan Kranzler 2018-09-30 20:08:37 -04:00
parent 081cac6b2e
commit 57470be67f

View file

@ -15,21 +15,26 @@ import mage.constants.CardType;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.filter.predicate.Predicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID; import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class CitadelSiege extends CardImpl { public final class CitadelSiege extends CardImpl {
private final static String ruleTrigger1 = "&bull Khans — At the beginning of combat on your turn, put two +1/+1 counters on target creature you control."; private final static String ruleTrigger1 = "&bull Khans — At the beginning of combat on your turn, put two +1/+1 counters on target creature you control.";
private final static String ruleTrigger2 = "&bull Dragons — At the beginning of combat on each opponent's turn, tap target creature that player controls."; private final static String ruleTrigger2 = "&bull Dragons — At the beginning of combat on each opponent's turn, tap target creature that player controls.";
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature controlled by the active player");
static {
filter.add(CitadelSiegePredicate.instance);
}
public CitadelSiege(UUID ownerId, CardSetInfo setInfo) { public CitadelSiege(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
@ -51,21 +56,10 @@ public final class CitadelSiege extends CardImpl {
new BeginningOfCombatTriggeredAbility(new TapTargetEffect(), TargetController.OPPONENT, false), new BeginningOfCombatTriggeredAbility(new TapTargetEffect(), TargetController.OPPONENT, false),
new ModeChoiceSourceCondition("Dragons"), new ModeChoiceSourceCondition("Dragons"),
ruleTrigger2); ruleTrigger2);
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(ability); this.addAbility(ability);
} }
@Override
public void adjustTargets(Ability ability, Game game) {
if (this.getAbilities().contains(ability) && ability.getRule().startsWith("&bull Dragons")) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls");
filter.add(new ControllerIdPredicate(game.getCombat().getAttackingPlayerId()));
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(filter));
}
}
public CitadelSiege(final CitadelSiege card) { public CitadelSiege(final CitadelSiege card) {
super(card); super(card);
} }
@ -75,3 +69,12 @@ public final class CitadelSiege extends CardImpl {
return new CitadelSiege(this); return new CitadelSiege(this);
} }
} }
enum CitadelSiegePredicate implements Predicate<Permanent> {
instance;
@Override
public boolean apply(Permanent input, Game game) {
return input.getControllerId().equals(game.getActivePlayerId());
}
}