Merge pull request #2975 from HanClinto/CMH-FlagbearerFix

Fix Flagbearer to not require triggered abilities to target a flagbearer
This commit is contained in:
LevelX2 2017-03-16 16:49:43 +01:00 committed by GitHub
commit 61b8829819

View file

@ -9,6 +9,8 @@ import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -24,6 +26,11 @@ import mage.target.Target;
* 6/8/2016 If a spell or abilitys targets are changed, or if a copy of a spell
* or ability is put onto the stack and has new targets chosen, it doesnt have
* to target a Flagbearer.
*
* 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
* about choosing targets for a copy from 6/8/2016).
*
* @author LevelX2
*/
@ -73,6 +80,12 @@ public class TargetsHaveToTargetPermanentIfAbleEffect extends ContinuousRuleModi
if (stackObject.isCopy()) {
return false;
}
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)) {
return false;
}
Ability ability = (Ability) getValue("targetAbility");
if (ability != null) {
// Get all the allowed permanents on the battlefield in range of the abilities controller