updated Flagbearer ability to reflect rules change

This commit is contained in:
Evan Kranzler 2019-01-22 19:13:21 -05:00
parent 1431e69b43
commit 9b94b27e54
4 changed files with 32 additions and 27 deletions

View file

@ -5,8 +5,6 @@
*/
package mage.abilities.effects.common.ruleModifying;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
@ -14,6 +12,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -22,11 +21,14 @@ import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.Target;
import java.util.List;
import java.util.UUID;
/**
* 6/8/2016 If a spell or ability's targets are changed, or if a copy of a spell
* or ability is put onto the stack and has new targets chosen, it doesn't have
* to target a Flagbearer.
*
* <p>
* 3/16/2017 A Flagbearer only requires targeting of itself when choosing targets
* as a result of casting a spell or activating an ability. Notably, triggered
* abilities are exempt from this targeting restriction (in addition to the note
@ -37,15 +39,22 @@ import mage.target.Target;
public class TargetsHaveToTargetPermanentIfAbleEffect extends ContinuousRuleModifyingEffectImpl {
private final FilterPermanent filter;
private static final FilterPermanent flagbearerFilter = new FilterPermanent(SubType.FLAGBEARER, "one Flagbearer");
public TargetsHaveToTargetPermanentIfAbleEffect() {
this(flagbearerFilter);
}
public TargetsHaveToTargetPermanentIfAbleEffect(FilterPermanent filter) {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
this.filter = filter;
staticText = "While choosing targets as part of casting a spell or activating an ability, your opponents must choose at least " + this.filter.getMessage() + " on the battlefield if able";
staticText = "While an opponent is choosing targets as part of casting a spell they control " +
"or activating an ability they control, that player must choose at least " +
this.filter.getMessage() + " on the battlefield if able";
}
public TargetsHaveToTargetPermanentIfAbleEffect(final TargetsHaveToTargetPermanentIfAbleEffect effect) {
private TargetsHaveToTargetPermanentIfAbleEffect(final TargetsHaveToTargetPermanentIfAbleEffect effect) {
super(effect);
this.filter = effect.filter;
}
@ -83,7 +92,11 @@ public class TargetsHaveToTargetPermanentIfAbleEffect extends ContinuousRuleModi
Ability stackAbility = stackObject.getStackAbility();
// Ensure that this ability is activated or a cast spell, because Flag Bearer effects don't require triggered abilities to choose a Standard Bearer
if (!(stackAbility instanceof ActivatedAbility) &&
!(stackAbility instanceof SpellAbility)) {
!(stackAbility instanceof SpellAbility)) {
return false;
}
// Also check that targeting player controls the ability
if (!stackAbility.isControlledBy(targetingPlayer.getId())) {
return false;
}
Ability ability = (Ability) getValue("targetAbility");