mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- Added check in DamageDealAi for planeswalkers
This commit is contained in:
@@ -97,6 +97,20 @@ public class ComputerUtilCard {
|
|||||||
// get biggest Artifact
|
// get biggest Artifact
|
||||||
return Aggregates.itemWithMax(all, CardPredicates.Accessors.fnGetCmc);
|
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.
|
// The AI doesn't really pick the best enchantment, just the most expensive.
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2080,7 +2080,7 @@ public class ComputerUtilCombat {
|
|||||||
*/
|
*/
|
||||||
public static final int getEnoughDamageToKill(final Card c, final int maxDamage, final Card source, final boolean isCombat,
|
public static final int getEnoughDamageToKill(final Card c, final int maxDamage, final Card source, final boolean isCombat,
|
||||||
final boolean noPrevention) {
|
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 (c.hasKeyword("Indestructible") || c.getShieldCount() > 0) {
|
||||||
if (!(source.hasKeyword("Wither") || source.hasKeyword("Infect"))) {
|
if (!(source.hasKeyword("Wither") || source.hasKeyword("Infect"))) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import forge.game.card.Card;
|
|||||||
import forge.game.card.CardCollection;
|
import forge.game.card.CardCollection;
|
||||||
import forge.game.card.CardCollectionView;
|
import forge.game.card.CardCollectionView;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.card.CardPredicates;
|
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -175,8 +174,7 @@ public class ControlGainAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasPW) {
|
if (hasPW) {
|
||||||
CardCollection planeswalkers = CardLists.filter(list, CardPredicates.Presets.PLANEWALKERS);
|
t = ComputerUtilCard.getBestPlaneswalkerAI(list);
|
||||||
t = ComputerUtilCard.getMostExpensivePermanentAI(planeswalkers, sa, true);
|
|
||||||
} else if (hasCreature) {
|
} else if (hasCreature) {
|
||||||
t = ComputerUtilCard.getBestCreatureAI(list);
|
t = ComputerUtilCard.getBestCreatureAI(list);
|
||||||
if (lose != null && lose.contains("EOT")) {
|
if (lose != null && lose.contains("EOT")) {
|
||||||
|
|||||||
@@ -176,9 +176,14 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Card targetCard;
|
Card targetCard = null;
|
||||||
if (pl.isOpponentOf(ai) && !killables.isEmpty()) {
|
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;
|
return targetCard;
|
||||||
}
|
}
|
||||||
@@ -189,7 +194,12 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
|
|
||||||
if (!hPlay.isEmpty()) {
|
if (!hPlay.isEmpty()) {
|
||||||
if (pl.isOpponentOf(ai)) {
|
if (pl.isOpponentOf(ai)) {
|
||||||
targetCard = ComputerUtilCard.getBestCreatureAI(hPlay);
|
if (sa.getTargetRestrictions().canTgtPlaneswalker()) {
|
||||||
|
targetCard = ComputerUtilCard.getBestPlaneswalkerAI(hPlay);
|
||||||
|
}
|
||||||
|
if (targetCard == null) {
|
||||||
|
targetCard = ComputerUtilCard.getBestCreatureAI(hPlay);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
targetCard = ComputerUtilCard.getWorstCreatureAI(hPlay);
|
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);
|
final Card c = this.dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, mandatory);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
//option to hold removal instead only applies for single targeted removal
|
//option to hold removal instead only applies for single targeted removal
|
||||||
|
|||||||
@@ -422,6 +422,20 @@ public class TargetRestrictions {
|
|||||||
}
|
}
|
||||||
return false;
|
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>
|
* <p>
|
||||||
|
|||||||
Reference in New Issue
Block a user