- The AI will now be aware of opponents Royal Assassin and similar cards.

This commit is contained in:
Sloth
2014-10-26 19:51:55 +00:00
parent bf6209734b
commit 0cc2ece573
2 changed files with 39 additions and 1 deletions

View File

@@ -973,7 +973,15 @@ public class AiAttackController {
}
}
}
if (ComputerUtilCard.canBeBlockedProfitably(defendingOpponent, attacker)) {
if (!attacker.hasKeyword("vigilance") && ComputerUtilCard.canBeKilledByRoyalAssassin(ai, attacker)) {
canKillAllDangerous = false;
canBeKilled = true;
canBeKilledByOne = true;
isWorthLessThanAllKillers = false;
hasCombatEffect = false;
}
else if (ComputerUtilCard.canBeBlockedProfitably(defendingOpponent, attacker)) {
canKillAllDangerous = false;
canBeKilled = true;
}

View File

@@ -14,6 +14,7 @@ import forge.deck.Deck;
import forge.deck.DeckSection;
import forge.game.Game;
import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType;
import forge.game.card.*;
import forge.game.combat.Combat;
import forge.game.combat.CombatUtil;
@@ -593,6 +594,35 @@ public class ComputerUtilCard {
return combat.isAttacking(card);
}
public static boolean canBeKilledByRoyalAssassin(final Player ai, final Card card) {
boolean wasTapped = card.isTapped();
for (Player opp : ai.getOpponents()) {
for (Card c : opp.getCardsIn(ZoneType.Battlefield)) {
for (SpellAbility sa : c.getSpellAbilities()) {
if (sa.getApi() != ApiType.Destroy) {
continue;
}
if (!ComputerUtilCost.canPayCost(sa, opp)) {
continue;
}
sa.setActivatingPlayer(opp);
if (sa.canTarget(card)) {
continue;
}
// check whether the ability can only target tapped creatures
card.setTapped(true);
if (!sa.canTarget(card)) {
card.setTapped(wasTapped);
continue;
}
card.setTapped(wasTapped);
return true;
}
}
}
return false;
}
/**
* Create a mock combat and returns the list of likely blockers.
* @param ai blocking player