- Some AI support for CantSearchLibrary / Ashiok effect.

This commit is contained in:
Agetian
2019-05-14 12:13:10 +03:00
parent 72d623784a
commit 3913f7661f
2 changed files with 11 additions and 0 deletions

View File

@@ -316,6 +316,11 @@ public class ChangeZoneAi extends SpellAbilityAi {
for (final Player p : pDefined) { for (final Player p : pDefined) {
CardCollectionView list = p.getCardsIn(origin); CardCollectionView list = p.getCardsIn(origin);
// remove cards that won't be seen if library can't be searched
if (ai.hasKeyword("CantSearchLibrary") || (ai.hasKeyword("Spells and abilities you control can't cause you to search your library.") && !ai.canSearchOwnLibraryWith(sa, p))) {
list = CardLists.filter(list, Predicates.not(CardPredicates.inZone(ZoneType.Library)));
}
if (type != null && p == ai) { if (type != null && p == ai) {
// AI only "knows" about his information // AI only "knows" about his information
list = CardLists.getValidCards(list, type, source.getController(), source); list = CardLists.getValidCards(list, type, source.getController(), source);

View File

@@ -1,5 +1,6 @@
package forge.ai.ability; package forge.ai.ability;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.ai.*; import forge.ai.*;
@@ -57,6 +58,11 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
CardCollectionView oppType = CardLists.filterControlledBy(game.getCardsIn(origin), ai.getOpponents()); CardCollectionView oppType = CardLists.filterControlledBy(game.getCardsIn(origin), ai.getOpponents());
CardCollectionView computerType = ai.getCardsIn(origin); CardCollectionView computerType = ai.getCardsIn(origin);
// remove cards that won't be seen in AI's own library if it can't be searched
if (ai.hasKeyword("CantSearchLibrary") || (ai.hasKeyword("Spells and abilities you control can't cause you to search your library.") && !ai.canSearchOwnLibraryWith(sa, ai))) {
computerType = CardLists.filter(computerType, Predicates.not(CardPredicates.inZone(ZoneType.Library)));
}
// Ugin check need to be done before filterListByType because of ChosenX // Ugin check need to be done before filterListByType because of ChosenX
// Ugin AI: always try to sweep before considering +1 // Ugin AI: always try to sweep before considering +1
if (sourceName.equals("Ugin, the Spirit Dragon")) { if (sourceName.equals("Ugin, the Spirit Dragon")) {