- Implemented AI for Feat of Resistance

This commit is contained in:
excessum
2015-03-02 13:33:03 +00:00
parent 29a0411833
commit f064fd5602
3 changed files with 10 additions and 2 deletions

View File

@@ -606,7 +606,7 @@ public class PlayerControllerAi extends PlayerController {
if (game.stack.size() > 1) { if (game.stack.size() > 1) {
for (SpellAbilityStackInstance si : game.getStack()) { for (SpellAbilityStackInstance si : game.getStack()) {
SpellAbility spell = si.getSpellAbility(true); SpellAbility spell = si.getSpellAbility(true);
if (sa != spell) { if (sa != spell && sa.getHostCard() != spell.getHostCard()) {
String s = ProtectAi.toProtectFrom(spell.getHostCard(), sa); String s = ProtectAi.toProtectFrom(spell.getHostCard(), sa);
if (s != null) { if (s != null) {
return s; return s;

View File

@@ -86,6 +86,14 @@ public class CountersPutAi extends SpellAbilityAi {
} }
} }
} }
if (source.getName().equals("Feat of Resistance")) { // sub-ability should take precedence
CardCollection prot = ProtectAi.getProtectCreatures(ai, sa.getSubAbility());
if (!prot.isEmpty()) {
sa.getTargets().add(prot.get(0));
return true;
}
}
if (sa.hasParam("Bolster")) { if (sa.hasParam("Bolster")) {
CardCollection creatsYouCtrl = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); CardCollection creatsYouCtrl = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);

View File

@@ -98,7 +98,7 @@ public class ProtectAi extends SpellAbilityAi {
* a {@link forge.game.ability.AbilityFactory} object. * a {@link forge.game.ability.AbilityFactory} object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
private static CardCollection getProtectCreatures(final Player ai, final SpellAbility sa) { public static CardCollection getProtectCreatures(final Player ai, final SpellAbility sa) {
final List<String> gains = ProtectEffect.getProtectionList(sa); final List<String> gains = ProtectEffect.getProtectionList(sa);
final Game game = ai.getGame(); final Game game = ai.getGame();
final Combat combat = game.getCombat(); final Combat combat = game.getCombat();