- Fixed the AI trying to cast Animate Dead/Dance of the Dead on cards which will have Protection from Black once they hit the battlefield.

This commit is contained in:
Agetian
2018-12-01 21:19:44 +03:00
parent f4475bff37
commit 67cac41d3e

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 com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.ai.*; import forge.ai.*;
import forge.card.MagicColor;
import forge.game.Game; import forge.game.Game;
import forge.game.GameObject; import forge.game.GameObject;
import forge.game.GlobalRuleChange; import forge.game.GlobalRuleChange;
@@ -88,6 +89,19 @@ public class AttachAi extends SpellAbilityAi {
if (!attachPreference(sa, tgt, false)) { if (!attachPreference(sa, tgt, false)) {
return false; return false;
} }
// Don't try to attach an aura to a card which will have protection from the relevant color
Card targeted = sa.getTargets().getFirstTargetedCard();
if (targeted != null && !targeted.getZone().is(ZoneType.Battlefield)) {
byte color = sa.getTargets().getFirstTargetedCard().getCurrentState().getColor();
for (byte c : MagicColor.WUBRG) {
if ((color & c) == c) {
if (targeted.hasKeyword("Protection from " + MagicColor.toLongString(c))) {
return false;
}
}
}
}
} }
// Flash logic // Flash logic