mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Better logic for Desecration Demon: only sac creatures to it if in critical condition to lose to it and have no active flying/reach blockers that are useful.
This commit is contained in:
@@ -668,7 +668,7 @@ public class ComputerUtil {
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public static CardCollection choosePermanentsToSacrifice(final Player ai, final CardCollectionView cardlist, final int amount, SpellAbility source,
|
||||
public static CardCollection choosePermanentsToSacrifice(final Player ai, final CardCollectionView cardlist, final int amount, final SpellAbility source,
|
||||
final boolean destroy, final boolean isOptional) {
|
||||
CardCollection remaining = new CardCollection(cardlist);
|
||||
final CardCollection sacrificed = new CardCollection();
|
||||
@@ -680,6 +680,10 @@ public class ComputerUtil {
|
||||
if(!source.getActivatingPlayer().isOpponentOf(ai)) {
|
||||
return sacrificed; // sacrifice none
|
||||
}
|
||||
} else if ("DesecrationDemon".equals(source.getParam("AILogic"))) {
|
||||
if (!SpecialCardAi.DesecrationDemon.considerSacrificingCreature(ai, source)) {
|
||||
return sacrificed; // don't sacrifice unless in special conditions specified by DesecrationDemon AI
|
||||
}
|
||||
} else if (isOptional && source.getActivatingPlayer().isOpponentOf(ai)) {
|
||||
if ("Pillar Tombs of Aku".equals(host.getName())) {
|
||||
if (!ai.canLoseLife() || ai.cantLose()) {
|
||||
@@ -715,7 +719,15 @@ public class ComputerUtil {
|
||||
remaining = CardLists.filter(remaining, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) < (considerSacThreshold != -1 ? considerSacThreshold : 190)) {
|
||||
int sacThreshold = 190;
|
||||
|
||||
if ("DesecrationDemon".equals(source.getParam("AILogic"))) {
|
||||
sacThreshold = SpecialCardAi.DesecrationDemon.getSacThreshold();
|
||||
} else if (considerSacLogic) {
|
||||
sacThreshold = considerSacThreshold;
|
||||
}
|
||||
|
||||
if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) < sacThreshold) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.card.MagicColor;
|
||||
@@ -107,6 +108,32 @@ public class SpecialCardAi {
|
||||
}
|
||||
}
|
||||
|
||||
// Desecration Demon
|
||||
public static class DesecrationDemon {
|
||||
private static final int demonSacThreshold = Integer.MAX_VALUE; // if we're in dire conditions, sac everything from worst to best hoping to find an answer
|
||||
|
||||
public static boolean considerSacrificingCreature(Player ai, SpellAbility sa) {
|
||||
CardCollection flyingCreatures = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.UNTAPPED, Predicates.or(CardPredicates.hasKeyword("Flying"), CardPredicates.hasKeyword("Reach"))));
|
||||
boolean hasUsefulBlocker = false;
|
||||
|
||||
for (Card c : flyingCreatures) {
|
||||
if (!ComputerUtilCard.isUselessCreature(ai, c)) {
|
||||
hasUsefulBlocker = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ai.getLife() <= sa.getHostCard().getNetPower() && !hasUsefulBlocker) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getSacThreshold() {
|
||||
return demonSacThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
// Donate
|
||||
public static class Donate {
|
||||
public static boolean considerTargetingOpponent(Player ai, SpellAbility sa) {
|
||||
|
||||
Reference in New Issue
Block a user