Fix AI refusing Gilded Drake trigger when no targets

This commit is contained in:
tool4EvEr
2021-10-20 21:13:23 +02:00
parent 253cf35841
commit e7c9cdb111
4 changed files with 12 additions and 13 deletions

View File

@@ -30,7 +30,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
sa.resetTargets(); sa.resetTargets();
CardCollection list = CardCollection list =
CardLists.getValidCards(AiAttackController.choosePreferredDefenderPlayer(ai).getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa); CardLists.getValidCards(ai.getOpponents().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
// AI won't try to grab cards that are filtered out of AI decks on purpose // AI won't try to grab cards that are filtered out of AI decks on purpose
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
@@ -65,7 +65,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
} }
} else { } else {
if (mandatory) { if (mandatory) {
return chkAIDrawback(sa, aiPlayer); return chkAIDrawback(sa, aiPlayer) || sa.isTargetNumberValid();
} else { } else {
return canPlayAI(aiPlayer, sa); return canPlayAI(aiPlayer, sa);
} }
@@ -97,8 +97,12 @@ public class ControlExchangeAi extends SpellAbilityAi {
Card best = ComputerUtilCard.getBestAI(list); Card best = ComputerUtilCard.getBestAI(list);
// add best Target:
// do it here already even if we don't want to play this as it might be for targeting a trigger
sa.getTargets().add(best);
// if Param has Defined, check if the best Target is better than the Defined // if Param has Defined, check if the best Target is better than the Defined
if (sa.hasParam("Defined")) { if (sa.hasParam("Defined") && (!sa.isTrigger() || sa.getRootAbility().isOptionalTrigger())) {
final Card object = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0); final Card object = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).get(0);
// TODO add evaluate Land if able // TODO add evaluate Land if able
final Card realBest = ComputerUtilCard.getBestAI(Lists.newArrayList(best, object)); final Card realBest = ComputerUtilCard.getBestAI(Lists.newArrayList(best, object));
@@ -109,9 +113,6 @@ public class ControlExchangeAi extends SpellAbilityAi {
} }
} }
// add best Target
sa.getTargets().add(best);
// second target needed (the AI's own worst) // second target needed (the AI's own worst)
if ("TrigTwoTargets".equals(sa.getParam("AILogic"))) { if ("TrigTwoTargets".equals(sa.getParam("AILogic"))) {
return doTrigTwoTargetsLogic(aiPlayer, sa, best); return doTrigTwoTargetsLogic(aiPlayer, sa, best);

View File

@@ -72,7 +72,7 @@ public class DigEffect extends SpellAbilityEffect {
int libraryPosition = sa.hasParam("LibraryPosition") ? Integer.parseInt(sa.getParam("LibraryPosition")) : -1; int libraryPosition = sa.hasParam("LibraryPosition") ? Integer.parseInt(sa.getParam("LibraryPosition")) : -1;
int destZone1ChangeNum = 1; int destZone1ChangeNum = 1;
final boolean mitosis = sa.hasParam("Mitosis"); final boolean mitosis = sa.hasParam("Mitosis");
String changeValid = sa.hasParam("ChangeValid") ? sa.getParam("ChangeValid") : ""; String changeValid = sa.getParamOrDefault("ChangeValid", "");
final boolean anyNumber = sa.hasParam("AnyNumber"); final boolean anyNumber = sa.hasParam("AnyNumber");
final int libraryPosition2 = sa.hasParam("LibraryPosition2") ? Integer.parseInt(sa.getParam("LibraryPosition2")) : -1; final int libraryPosition2 = sa.hasParam("LibraryPosition2") ? Integer.parseInt(sa.getParam("LibraryPosition2")) : -1;
@@ -86,7 +86,7 @@ public class DigEffect extends SpellAbilityEffect {
// These parameters are used to indicate that a dialog box must be show to the player asking if the player wants to proceed // These parameters are used to indicate that a dialog box must be show to the player asking if the player wants to proceed
// with an optional ability, otherwise the optional ability is skipped. // with an optional ability, otherwise the optional ability is skipped.
final boolean mayBeSkipped = sa.hasParam("PromptToSkipOptionalAbility"); final boolean mayBeSkipped = sa.hasParam("PromptToSkipOptionalAbility");
final String optionalAbilityPrompt = sa.hasParam("OptionalAbilityPrompt") ? sa.getParam("OptionalAbilityPrompt") : ""; final String optionalAbilityPrompt = sa.getParamOrDefault("OptionalAbilityPrompt", "");
boolean remZone1 = false; boolean remZone1 = false;
boolean remZone2 = false; boolean remZone2 = false;

View File

@@ -35,7 +35,7 @@ public class DigMultipleEffect extends SpellAbilityEffect {
int libraryPosition = sa.hasParam("LibraryPosition") ? Integer.parseInt(sa.getParam("LibraryPosition")) : -1; int libraryPosition = sa.hasParam("LibraryPosition") ? Integer.parseInt(sa.getParam("LibraryPosition")) : -1;
final int libraryPosition2 = sa.hasParam("LibraryPosition2") ? Integer.parseInt(sa.getParam("LibraryPosition2")) : -1; final int libraryPosition2 = sa.hasParam("LibraryPosition2") ? Integer.parseInt(sa.getParam("LibraryPosition2")) : -1;
String changeValid = sa.hasParam("ChangeValid") ? sa.getParam("ChangeValid") : ""; String changeValid = sa.getParamOrDefault("ChangeValid", "");
boolean chooseOptional = sa.hasParam("Optional"); boolean chooseOptional = sa.hasParam("Optional");
CardZoneTable table = new CardZoneTable(); CardZoneTable table = new CardZoneTable();

View File

@@ -102,8 +102,7 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
add(new TotalMatchWins(100, 250, 500, 1000)); add(new TotalMatchWins(100, 250, 500, 1000));
if (isLimitedFormat) { //make need for speed goal more realistic for limited formats if (isLimitedFormat) { //make need for speed goal more realistic for limited formats
add(new NeedForSpeed(8, 6, 4, 2)); add(new NeedForSpeed(8, 6, 4, 2));
} } else {
else {
add(new NeedForSpeed(5, 3, 1, 0)); add(new NeedForSpeed(5, 3, 1, 0));
} }
add(new Overkill(-25, -50, -100, -200)); add(new Overkill(-25, -50, -100, -200));
@@ -114,8 +113,7 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
add(new ManaScrewed()); add(new ManaScrewed());
if (isLimitedFormat) { //lower gold and mythic thresholds based on smaller decks if (isLimitedFormat) { //lower gold and mythic thresholds based on smaller decks
add(new ManaFlooded(8, 11, 14, 17)); add(new ManaFlooded(8, 11, 14, 17));
} } else {
else {
add(new ManaFlooded(8, 12, 18, 24)); add(new ManaFlooded(8, 12, 18, 24));
} }
add(new RagsToRiches()); add(new RagsToRiches());