- Added check in DamageDealAi for planeswalkers

This commit is contained in:
excessum
2015-11-01 07:34:25 +00:00
parent ab8c60646b
commit 411039b779
5 changed files with 44 additions and 8 deletions

View File

@@ -97,6 +97,20 @@ public class ComputerUtilCard {
// get biggest Artifact
return Aggregates.itemWithMax(all, CardPredicates.Accessors.fnGetCmc);
}
/**
* Returns the best Planeswalker from a given list
* @param list list of cards to evaluate
* @return best Planeswalker
*/
public static Card getBestPlaneswalkerAI(final List<Card> list) {
List<Card> all = CardLists.filter(list, CardPredicates.Presets.PLANEWALKERS);
if (all.size() == 0) {
return null;
}
// no AI logic, just return most expensive
return Aggregates.itemWithMax(all, CardPredicates.Accessors.fnGetCmc);
}
// The AI doesn't really pick the best enchantment, just the most expensive.
/**

View File

@@ -2080,7 +2080,7 @@ public class ComputerUtilCombat {
*/
public static final int getEnoughDamageToKill(final Card c, final int maxDamage, final Card source, final boolean isCombat,
final boolean noPrevention) {
final int killDamage = ComputerUtilCombat.getDamageToKill(c);
final int killDamage = c.isPlaneswalker() ? c.getCurrentLoyalty() : ComputerUtilCombat.getDamageToKill(c);
if (c.hasKeyword("Indestructible") || c.getShieldCount() > 0) {
if (!(source.hasKeyword("Wither") || source.hasKeyword("Infect"))) {

View File

@@ -31,7 +31,6 @@ import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.card.CardCollectionView;
import forge.game.card.CardLists;
import forge.game.card.CardPredicates;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
@@ -175,8 +174,7 @@ public class ControlGainAi extends SpellAbilityAi {
}
if (hasPW) {
CardCollection planeswalkers = CardLists.filter(list, CardPredicates.Presets.PLANEWALKERS);
t = ComputerUtilCard.getMostExpensivePermanentAI(planeswalkers, sa, true);
t = ComputerUtilCard.getBestPlaneswalkerAI(list);
} else if (hasCreature) {
t = ComputerUtilCard.getBestCreatureAI(list);
if (lose != null && lose.contains("EOT")) {

View File

@@ -176,9 +176,14 @@ public class DamageDealAi extends DamageAiBase {
}
});
Card targetCard;
Card targetCard = null;
if (pl.isOpponentOf(ai) && !killables.isEmpty()) {
targetCard = ComputerUtilCard.getBestCreatureAI(killables);
if (sa.getTargetRestrictions().canTgtPlaneswalker()) {
targetCard = ComputerUtilCard.getBestPlaneswalkerAI(killables);
}
if (targetCard == null) {
targetCard = ComputerUtilCard.getBestCreatureAI(killables);
}
return targetCard;
}
@@ -189,7 +194,12 @@ public class DamageDealAi extends DamageAiBase {
if (!hPlay.isEmpty()) {
if (pl.isOpponentOf(ai)) {
targetCard = ComputerUtilCard.getBestCreatureAI(hPlay);
if (sa.getTargetRestrictions().canTgtPlaneswalker()) {
targetCard = ComputerUtilCard.getBestPlaneswalkerAI(hPlay);
}
if (targetCard == null) {
targetCard = ComputerUtilCard.getBestCreatureAI(hPlay);
}
} else {
targetCard = ComputerUtilCard.getWorstCreatureAI(hPlay);
}
@@ -400,7 +410,7 @@ public class DamageDealAi extends DamageAiBase {
}
}
} else if (tgt.canTgtCreature()) {
} else if (tgt.canTgtCreature() || tgt.canTgtPlaneswalker()) {
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, mandatory);
if (c != null) {
//option to hold removal instead only applies for single targeted removal

View File

@@ -422,6 +422,20 @@ public class TargetRestrictions {
}
return false;
}
/**
* Can tgt planeswalker.
*
* @return true, if successful
*/
public final boolean canTgtPlaneswalker() {
for (final String s : this.validTgts) {
if (s.startsWith("Planeswalker")) {
return true;
}
}
return false;
}
/**
* <p>