From c7f6d8b37a46422f33fc7e914a18f58fe2f49f66 Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 19 Nov 2018 06:36:02 +0300 Subject: [PATCH] - Added a Legendary Rule check. --- forge-ai/src/main/java/forge/ai/ability/AttachAi.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 03631d86ce2..3ff51f33d7d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -4,6 +4,7 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import forge.ai.*; import forge.game.GameObject; +import forge.game.GlobalRuleChange; import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; @@ -56,8 +57,13 @@ public class AttachAi extends SpellAbilityAi { } } - if (source.getType().isLegendary() && ai.isCardInPlay(source.getName())) { + 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; }