- 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) {
for (SpellAbilityStackInstance si : game.getStack()) {
SpellAbility spell = si.getSpellAbility(true);
if (sa != spell) {
if (sa != spell && sa.getHostCard() != spell.getHostCard()) {
String s = ProtectAi.toProtectFrom(spell.getHostCard(), sa);
if (s != null) {
return s;

View File

@@ -87,6 +87,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")) {
CardCollection creatsYouCtrl = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
CardCollection leastToughness = new CardCollection(Aggregates.listWithMin(creatsYouCtrl, CardPredicates.Accessors.fnGetDefense));

View File

@@ -98,7 +98,7 @@ public class ProtectAi extends SpellAbilityAi {
* a {@link forge.game.ability.AbilityFactory} 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 Game game = ai.getGame();
final Combat combat = game.getCombat();