Merge branch 'master' into 'master'

AttachAi: do not play the second copy of a legendary enchantment.

See merge request core-developers/forge!1116
This commit is contained in:
Michael Kamensky
2018-11-19 03:48:36 +00:00

View File

@@ -4,6 +4,7 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import forge.ai.*; import forge.ai.*;
import forge.game.GameObject; import forge.game.GameObject;
import forge.game.GlobalRuleChange;
import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType; import forge.game.ability.ApiType;
@@ -56,6 +57,16 @@ public class AttachAi extends SpellAbilityAi {
} }
} }
if (!ai.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)
&& source.getType().isLegendary()
&& ai.isCardInPlay(source.getName())) {
// Don't play the second copy of a legendary enchantment already in play
// TODO: Add some extra checks for where the AI may want to cast a replacement aura
// on another creature and keep it when the original enchanted creature is useless
return false;
}
if (ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) if (ai.getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
&& !"Curse".equals(sa.getParam("AILogic"))) { && !"Curse".equals(sa.getParam("AILogic"))) {
return false; return false;