updated Citadel Siege targeting
@@ -15,21 +15,26 @@ import mage.constants.CardType;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
-import mage.filter.predicate.permanent.ControllerIdPredicate;
+import mage.filter.predicate.Predicate;
import mage.game.Game;
+import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
- *
* @author LevelX2
*/
public final class CitadelSiege extends CardImpl {
private final static String ruleTrigger1 = "&bull Khans &mdash; 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 &mdash; 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) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
@@ -51,20 +56,9 @@ public final class CitadelSiege extends CardImpl {
new BeginningOfCombatTriggeredAbility(new TapTargetEffect(), TargetController.OPPONENT, false),
new ModeChoiceSourceCondition("Dragons"),
ruleTrigger2);
- ability.addTarget(new TargetCreaturePermanent());
- 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));
+ this.addAbility(ability);
}
- }
-
public CitadelSiege(final CitadelSiege card) {
super(card);
@@ -75,3 +69,12 @@ public final class CitadelSiege extends CardImpl {
return new CitadelSiege(this);
}
}
+
+enum CitadelSiegePredicate implements Predicate<Permanent> {
+ instance;
+
+ @Override
+ public boolean apply(Permanent input, Game game) {
+ return input.getControllerId().equals(game.getActivePlayerId());
+ }
+}
\ No newline at end of file
