mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Removed all except filter from CardList
This commit is contained in:
@@ -279,8 +279,8 @@ public abstract class AllZoneUtil {
|
||||
public static int compareTypeAmountInPlay(final Player player, final String type) {
|
||||
// returns the difference between player's
|
||||
final Player opponent = player.getOpponent();
|
||||
final CardList playerList = player.getCardsIn(ZoneType.Battlefield).getType(type);
|
||||
final CardList opponentList = opponent.getCardsIn(ZoneType.Battlefield).getType(type);
|
||||
final CardList playerList = CardListUtil.getType(player.getCardsIn(ZoneType.Battlefield), type);
|
||||
final CardList opponentList = CardListUtil.getType(opponent.getCardsIn(ZoneType.Battlefield), type);
|
||||
return (playerList.size() - opponentList.size());
|
||||
}
|
||||
|
||||
@@ -298,8 +298,8 @@ public abstract class AllZoneUtil {
|
||||
public static int compareTypeAmountInGraveyard(final Player player, final String type) {
|
||||
// returns the difference between player's
|
||||
final Player opponent = player.getOpponent();
|
||||
final CardList playerList = player.getCardsIn(ZoneType.Graveyard).getType(type);
|
||||
final CardList opponentList = opponent.getCardsIn(ZoneType.Graveyard).getType(type);
|
||||
final CardList playerList = CardListUtil.getType(player.getCardsIn(ZoneType.Graveyard), type);
|
||||
final CardList opponentList = CardListUtil.getType(opponent.getCardsIn(ZoneType.Graveyard), type);
|
||||
return (playerList.size() - opponentList.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -6547,7 +6547,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
} else if (property.startsWith("ControllerControls")) {
|
||||
final String type = property.substring(18);
|
||||
final CardList list = this.getController().getCardsIn(ZoneType.Battlefield);
|
||||
if (list.getType(type).isEmpty()) {
|
||||
if (CardListUtil.getType(list, type).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("Other")) {
|
||||
|
||||
@@ -19,12 +19,8 @@ package forge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -56,24 +52,4 @@ public class CardList extends ArrayList<Card> {
|
||||
return new CardList(Iterables.filter(this, filt));
|
||||
}
|
||||
|
||||
// cardType is like "Land" or "Goblin", returns a new CardList that is a
|
||||
// subset of current CardList
|
||||
public final CardList getType(final String cardType) {
|
||||
return this.filter(CardPredicates.isType(cardType));
|
||||
}
|
||||
|
||||
// cardType is like "Land" or "Goblin", returns a new CardList with cards
|
||||
// that do not have this type
|
||||
public final CardList getNotType(final String cardType) {
|
||||
return this.filter(Predicates.not(CardPredicates.isType(cardType)));
|
||||
}
|
||||
|
||||
public final CardList getKeyword(final String keyword) {
|
||||
return this.filter(CardPredicates.hasKeyword(keyword));
|
||||
}
|
||||
|
||||
public final CardList getNotKeyword(final String keyword) {
|
||||
return this.filter(Predicates.not(CardPredicates.hasKeyword(keyword)));
|
||||
}
|
||||
|
||||
} // end class CardList
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -314,4 +315,22 @@ public class CardListUtil {
|
||||
public static CardList getTargetableCards(CardList cardList, SpellAbility source) {
|
||||
return cardList.filter(CardPredicates.isTargetableBy(source));
|
||||
}
|
||||
|
||||
public static CardList getKeyword(CardList cardList, String keyword) {
|
||||
return cardList.filter(CardPredicates.hasKeyword(keyword));
|
||||
}
|
||||
|
||||
public static CardList getNotKeyword(CardList cardList, String keyword) {
|
||||
return cardList.filter(Predicates.not(CardPredicates.hasKeyword(keyword)));
|
||||
}
|
||||
|
||||
// cardType is like "Land" or "Goblin", returns a new CardList that is a
|
||||
// subset of current CardList
|
||||
public static CardList getNotType(CardList cardList, String cardType) {
|
||||
return cardList.filter(Predicates.not(CardPredicates.isType(cardType)));
|
||||
}
|
||||
|
||||
public static CardList getType(CardList cardList, String cardType) {
|
||||
return cardList.filter(CardPredicates.isType(cardType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1233,7 +1233,7 @@ public class GameAction {
|
||||
continue;
|
||||
}
|
||||
|
||||
final CardList cl = list.getType(type);
|
||||
final CardList cl = CardListUtil.getType(list, type);
|
||||
|
||||
if (cl.size() > 1) {
|
||||
for (final Card crd : cl) {
|
||||
@@ -1250,14 +1250,14 @@ public class GameAction {
|
||||
* </p>
|
||||
*/
|
||||
private void destroyLegendaryCreatures() {
|
||||
final CardList a = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("Legendary");
|
||||
final CardList a = CardListUtil.getType(AllZoneUtil.getCardsIn(ZoneType.Battlefield), "Legendary");
|
||||
if (a.isEmpty() || AllZoneUtil.isCardInPlay("Mirror Gallery")) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!a.isEmpty()) {
|
||||
CardList b = AllZoneUtil.getCardsIn(ZoneType.Battlefield, a.get(0).getName());
|
||||
b = b.getType("Legendary");
|
||||
b = CardListUtil.getType(b, "Legendary");
|
||||
b = b.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
|
||||
@@ -502,7 +502,7 @@ public class AbilityFactoryAttach {
|
||||
public static Card attachAIAnimatePreference(final SpellAbility sa, final CardList list, final boolean mandatory,
|
||||
final Card attachSource) {
|
||||
// AI For choosing a Card to Animate.
|
||||
CardList betterList = list.getNotType("Creature");
|
||||
CardList betterList = CardListUtil.getNotType(list, "Creature");
|
||||
if (sa.getSourceCard().getName().equals("Animate Artifact")) {
|
||||
betterList = betterList.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -961,7 +961,7 @@ public class AbilityFactoryAttach {
|
||||
}
|
||||
}
|
||||
|
||||
list = list.getNotType(type); // Filter out Basic Lands that have the
|
||||
list = CardListUtil.getNotType(list, type); // Filter out Basic Lands that have the
|
||||
// same type as the changing type
|
||||
|
||||
final Card c = CardFactoryUtil.getBestAI(list);
|
||||
|
||||
@@ -1207,7 +1207,7 @@ public final class AbilityFactoryChangeZone {
|
||||
} else if (origin.contains(ZoneType.Library)
|
||||
&& (type.contains("Basic") || AbilityFactoryChangeZone.areAllBasics(type))) {
|
||||
c = AbilityFactoryChangeZone.basicManaFixing(fetchList);
|
||||
} else if (ZoneType.Hand.equals(destination) && fetchList.getNotType("Creature").size() == 0) {
|
||||
} else if (ZoneType.Hand.equals(destination) && CardListUtil.getNotType(fetchList, "Creature").size() == 0) {
|
||||
c = AbilityFactoryChangeZone.chooseCreature(fetchList);
|
||||
} else if (ZoneType.Battlefield.equals(destination) || ZoneType.Graveyard.equals(destination)) {
|
||||
c = CardFactoryUtil.getBestAI(fetchList);
|
||||
@@ -1233,7 +1233,7 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
if (c == null) {
|
||||
System.out.println("Don't need a land or none available; trying for a creature.");
|
||||
fetchList = fetchList.getNotType("Land");
|
||||
fetchList = CardListUtil.getNotType(fetchList, "Land");
|
||||
// Prefer to pull a creature, generally more useful for AI.
|
||||
c = chooseCreature(fetchList.filter(CardPredicates.Presets.CREATURES));
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ public final class AbilityFactoryChangeZone {
|
||||
|
||||
// what types can I go get?
|
||||
for (final String name : Constant.Color.BASIC_LANDS) {
|
||||
if (!list.getType(name).isEmpty()) {
|
||||
if (!CardListUtil.getType(list, name).isEmpty()) {
|
||||
basics.add(name);
|
||||
}
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ public final class AbilityFactoryChangeZone {
|
||||
|
||||
for (int i = 0; i < basics.size(); i++) {
|
||||
final String b = basics.get(i);
|
||||
final int num = combined.getType(b).size();
|
||||
final int num = CardListUtil.getType(combined, b).size();
|
||||
if (num < minSize) {
|
||||
minType = b;
|
||||
minSize = num;
|
||||
@@ -1386,7 +1386,7 @@ public final class AbilityFactoryChangeZone {
|
||||
|
||||
List<Card> result = list;
|
||||
if (minType != null) {
|
||||
result = list.getType(minType);
|
||||
result = CardListUtil.getType(list, minType);
|
||||
}
|
||||
|
||||
return result.get(0);
|
||||
@@ -1791,7 +1791,7 @@ public final class AbilityFactoryChangeZone {
|
||||
choice = mostExpensive;
|
||||
}
|
||||
} else if (destination.equals(ZoneType.Hand) || destination.equals(ZoneType.Library)) {
|
||||
CardList nonLands = list.getNotType("Land");
|
||||
CardList nonLands = CardListUtil.getNotType(list, "Land");
|
||||
// Prefer to pull a creature, generally more useful for AI.
|
||||
choice = chooseCreature(nonLands.filter(CardPredicates.Presets.CREATURES));
|
||||
if (choice == null) { // Could not find a creature.
|
||||
@@ -1904,7 +1904,7 @@ public final class AbilityFactoryChangeZone {
|
||||
} else if (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield)) {
|
||||
choice = CardFactoryUtil.getMostExpensivePermanentAI(list, sa, false);
|
||||
} else if (destination.equals(ZoneType.Hand) || destination.equals(ZoneType.Library)) {
|
||||
CardList nonLands = list.getNotType("Land");
|
||||
CardList nonLands = CardListUtil.getNotType(list, "Land");
|
||||
// Prefer to pull a creature, generally more useful for AI.
|
||||
choice = chooseCreature(nonLands.filter(CardPredicates.Presets.CREATURES));
|
||||
if (choice == null) { // Could not find a creature.
|
||||
@@ -2607,7 +2607,7 @@ public final class AbilityFactoryChangeZone {
|
||||
tgt.addTarget(AllZone.getHumanPlayer());
|
||||
computerType.clear();
|
||||
}
|
||||
if ((humanType.getNotType("Creature").size() == 0) && (computerType.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanType, "Creature").size() == 0) && (CardListUtil.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerType) + 200) >= CardFactoryUtil
|
||||
.evaluateCreatureList(humanType)) {
|
||||
return false;
|
||||
@@ -2645,7 +2645,7 @@ public final class AbilityFactoryChangeZone {
|
||||
if (destination.equals(ZoneType.Battlefield)) {
|
||||
if (params.get("GainControl") != null) {
|
||||
// Check if the cards are valuable enough
|
||||
if ((humanType.getNotType("Creature").size() == 0) && (computerType.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanType, "Creature").size() == 0) && (CardListUtil.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerType) + CardFactoryUtil
|
||||
.evaluateCreatureList(humanType)) < 400) {
|
||||
return false;
|
||||
@@ -2658,7 +2658,7 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
} else {
|
||||
// don't activate if human gets more back than AI does
|
||||
if ((humanType.getNotType("Creature").size() == 0) && (computerType.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanType, "Creature").size() == 0) && (CardListUtil.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if (CardFactoryUtil.evaluateCreatureList(computerType) <= (CardFactoryUtil
|
||||
.evaluateCreatureList(humanType) + 100)) {
|
||||
return false;
|
||||
@@ -2761,7 +2761,7 @@ public final class AbilityFactoryChangeZone {
|
||||
// if the AI is using it defensively, then something else needs to occur
|
||||
// if only creatures are affected evaluate both lists and pass only
|
||||
// if human creatures are more valuable
|
||||
if ((humanType.getNotType("Creature").isEmpty()) && (computerType.getNotType("Creature").isEmpty())) {
|
||||
if ((CardListUtil.getNotType(humanType, "Creature").isEmpty()) && (CardListUtil.getNotType(computerType, "Creature").isEmpty())) {
|
||||
if (CardFactoryUtil.evaluateCreatureList(computerType) >= CardFactoryUtil
|
||||
.evaluateCreatureList(humanType)) {
|
||||
return false;
|
||||
@@ -2795,7 +2795,7 @@ public final class AbilityFactoryChangeZone {
|
||||
if (destination.equals(ZoneType.Battlefield)) {
|
||||
if (params.get("GainControl") != null) {
|
||||
// Check if the cards are valuable enough
|
||||
if ((humanType.getNotType("Creature").size() == 0) && (computerType.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanType, "Creature").size() == 0) && (CardListUtil.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerType) + CardFactoryUtil
|
||||
.evaluateCreatureList(humanType)) < 1) {
|
||||
return false;
|
||||
@@ -2808,7 +2808,7 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
} else {
|
||||
// don't activate if human gets more back than AI does
|
||||
if ((humanType.getNotType("Creature").isEmpty()) && (computerType.getNotType("Creature").isEmpty())) {
|
||||
if ((CardListUtil.getNotType(humanType, "Creature").isEmpty()) && (CardListUtil.getNotType(computerType, "Creature").isEmpty())) {
|
||||
if (CardFactoryUtil.evaluateCreatureList(computerType) <= CardFactoryUtil
|
||||
.evaluateCreatureList(humanType)) {
|
||||
return false;
|
||||
|
||||
@@ -1947,7 +1947,7 @@ public final class AbilityFactoryChoose {
|
||||
final ArrayList<String> basic = CardUtil.getBasicTypes();
|
||||
|
||||
for (final String type : basic) {
|
||||
final CardList cl = land.getType(type);
|
||||
final CardList cl = CardListUtil.getType(land, type);
|
||||
if (cl.size() > 0) {
|
||||
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
|
||||
final Object o = GuiChoose.one(prompt, cl);
|
||||
|
||||
@@ -901,7 +901,7 @@ public final class AbilityFactoryClash {
|
||||
} else {
|
||||
int cmc1 = CardFactoryUtil.evaluatePermanentList(new CardList(pile1));
|
||||
int cmc2 = CardFactoryUtil.evaluatePermanentList(new CardList(pile2));
|
||||
if (pool.getNotType("Creature").isEmpty()) {
|
||||
if (CardListUtil.getNotType(pool, "Creature").isEmpty()) {
|
||||
cmc1 = CardFactoryUtil.evaluateCreatureList(new CardList(pile1));
|
||||
cmc2 = CardFactoryUtil.evaluateCreatureList(new CardList(pile2));
|
||||
System.out.println("value:" + cmc1 + " " + cmc2);
|
||||
|
||||
@@ -1255,7 +1255,7 @@ public class AbilityFactoryDealDamage {
|
||||
}
|
||||
};
|
||||
|
||||
list = list.getNotKeyword("Indestructible");
|
||||
list = CardListUtil.getNotKeyword(list, "Indestructible");
|
||||
list = list.filter(filterKillable);
|
||||
|
||||
return list;
|
||||
|
||||
@@ -501,7 +501,7 @@ public final class AbilityFactoryDebuff {
|
||||
}
|
||||
|
||||
Card c;
|
||||
if (pref.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(pref, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getBestCreatureAI(pref);
|
||||
} else {
|
||||
c = CardFactoryUtil.getMostExpensivePermanentAI(pref, sa, true);
|
||||
@@ -520,7 +520,7 @@ public final class AbilityFactoryDebuff {
|
||||
// TODO - if forced targeting, just pick something without the given
|
||||
// keyword
|
||||
Card c;
|
||||
if (forced.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(forced, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getWorstCreatureAI(forced);
|
||||
} else {
|
||||
c = CardFactoryUtil.getCheapestPermanentAI(forced, sa, true);
|
||||
|
||||
@@ -253,7 +253,7 @@ public class AbilityFactoryDestroy {
|
||||
if (params.containsKey("AITgts")) {
|
||||
list = CardListUtil.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source);
|
||||
}
|
||||
list = list.getNotKeyword("Indestructible");
|
||||
list = CardListUtil.getNotKeyword(list, "Indestructible");
|
||||
if (!AbilityFactory.playReusable(sa)) {
|
||||
list = list.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -294,9 +294,9 @@ public class AbilityFactoryDestroy {
|
||||
|
||||
Card choice = null;
|
||||
// If the targets are only of one type, take the best
|
||||
if (list.getNotType("Creature").isEmpty()) {
|
||||
if (CardListUtil.getNotType(list, "Creature").isEmpty()) {
|
||||
choice = CardFactoryUtil.getBestCreatureAI(list);
|
||||
} else if (list.getNotType("Land").isEmpty()) {
|
||||
} else if (CardListUtil.getNotType(list, "Land").isEmpty()) {
|
||||
choice = CardFactoryUtil.getBestLandAI(list);
|
||||
} else {
|
||||
choice = CardFactoryUtil.getMostExpensivePermanentAI(list, sa, true);
|
||||
@@ -320,7 +320,7 @@ public class AbilityFactoryDestroy {
|
||||
list = new CardList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa));
|
||||
if (list.isEmpty()
|
||||
|| !CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()).isEmpty()
|
||||
|| list.getNotKeyword("Indestructible").isEmpty()) {
|
||||
|| CardListUtil.getNotKeyword(list, "Indestructible").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class AbilityFactoryDestroy {
|
||||
|
||||
tgt.resetTargets();
|
||||
|
||||
CardList preferred = list.getNotKeyword("Indestructible");
|
||||
CardList preferred = CardListUtil.getNotKeyword(list, "Indestructible");
|
||||
preferred = CardListUtil.filterControlledBy(preferred, AllZone.getHumanPlayer());
|
||||
|
||||
// If NoRegen is not set, filter out creatures that have a
|
||||
@@ -422,9 +422,9 @@ public class AbilityFactoryDestroy {
|
||||
}
|
||||
} else {
|
||||
Card c;
|
||||
if (preferred.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(preferred, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getBestCreatureAI(preferred);
|
||||
} else if (preferred.getNotType("Land").size() == 0) {
|
||||
} else if (CardListUtil.getNotType(preferred, "Land").size() == 0) {
|
||||
c = CardFactoryUtil.getBestLandAI(preferred);
|
||||
} else {
|
||||
c = CardFactoryUtil.getMostExpensivePermanentAI(preferred, sa, false);
|
||||
@@ -439,7 +439,7 @@ public class AbilityFactoryDestroy {
|
||||
break;
|
||||
} else {
|
||||
Card c;
|
||||
if (list.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(list, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getWorstCreatureAI(list);
|
||||
} else {
|
||||
c = CardFactoryUtil.getCheapestPermanentAI(list, sa, false);
|
||||
@@ -881,7 +881,7 @@ public class AbilityFactoryDestroy {
|
||||
|
||||
// if only creatures are affected evaluate both lists and pass only if
|
||||
// human creatures are more valuable
|
||||
if ((humanlist.getNotType("Creature").size() == 0) && (computerlist.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanlist, "Creature").size() == 0) && (CardListUtil.getNotType(computerlist, "Creature").size() == 0)) {
|
||||
if (CardFactoryUtil.evaluateCreatureList(computerlist) >= CardFactoryUtil.evaluateCreatureList(humanlist)
|
||||
&& !computerlist.isEmpty()) {
|
||||
return false;
|
||||
@@ -972,13 +972,13 @@ public class AbilityFactoryDestroy {
|
||||
|
||||
// if only creatures are affected evaluate both lists and pass only if
|
||||
// human creatures are more valuable
|
||||
if ((humanlist.getNotType("Creature").size() == 0) && (computerlist.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanlist, "Creature").size() == 0) && (CardListUtil.getNotType(computerlist, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerlist) + 200) >= CardFactoryUtil
|
||||
.evaluateCreatureList(humanlist)) {
|
||||
return false;
|
||||
}
|
||||
} // only lands involved
|
||||
else if ((humanlist.getNotType("Land").size() == 0) && (computerlist.getNotType("Land").size() == 0)) {
|
||||
else if ((CardListUtil.getNotType(humanlist, "Land").size() == 0) && (CardListUtil.getNotType(computerlist, "Land").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluatePermanentList(computerlist) + 1) >= CardFactoryUtil
|
||||
.evaluatePermanentList(humanlist)) {
|
||||
return false;
|
||||
|
||||
@@ -431,7 +431,7 @@ public class AbilityFactoryPermanentState {
|
||||
}
|
||||
}
|
||||
|
||||
if (untapList.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(untapList, "Creature").size() == 0) {
|
||||
choice = CardFactoryUtil.getBestCreatureAI(untapList); // if
|
||||
// only
|
||||
// creatures
|
||||
@@ -551,7 +551,7 @@ public class AbilityFactoryPermanentState {
|
||||
}
|
||||
}
|
||||
|
||||
if (tapList.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(tapList, "Creature").size() == 0) {
|
||||
choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only
|
||||
// creatures
|
||||
// take
|
||||
@@ -638,7 +638,7 @@ public class AbilityFactoryPermanentState {
|
||||
AllZone.getInputControl().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid));
|
||||
} else {
|
||||
CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
list = list.getType(valid);
|
||||
list = CardListUtil.getType(list, valid);
|
||||
list = list.filter(Presets.TAPPED);
|
||||
|
||||
int count = 0;
|
||||
@@ -1191,7 +1191,7 @@ public class AbilityFactoryPermanentState {
|
||||
}
|
||||
}
|
||||
|
||||
if (tapList.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(tapList, "Creature").size() == 0) {
|
||||
// if only creatures take the best
|
||||
choice = CardFactoryUtil.getBestCreatureAI(tapList);
|
||||
} else {
|
||||
|
||||
@@ -508,7 +508,7 @@ public final class AbilityFactoryProtection {
|
||||
}
|
||||
|
||||
Card c;
|
||||
if (pref.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(pref, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getBestCreatureAI(pref);
|
||||
} else {
|
||||
c = CardFactoryUtil.getMostExpensivePermanentAI(pref, sa, true);
|
||||
@@ -525,7 +525,7 @@ public final class AbilityFactoryProtection {
|
||||
}
|
||||
|
||||
Card c;
|
||||
if (pref2.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(pref2, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getBestCreatureAI(pref2);
|
||||
} else {
|
||||
c = CardFactoryUtil.getMostExpensivePermanentAI(pref2, sa, true);
|
||||
@@ -542,7 +542,7 @@ public final class AbilityFactoryProtection {
|
||||
}
|
||||
|
||||
Card c;
|
||||
if (forced.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(forced, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getWorstCreatureAI(forced);
|
||||
} else {
|
||||
c = CardFactoryUtil.getCheapestPermanentAI(forced, sa, true);
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
@@ -347,7 +349,7 @@ public class AbilityFactoryPump {
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
|| ph.getPhase().isBefore(PhaseType.MAIN1)
|
||||
|| AllZoneUtil.getCreaturesInPlay(computer).getNotKeyword("Defender").isEmpty())) {
|
||||
|| CardListUtil.getNotKeyword(AllZoneUtil.getCreaturesInPlay(computer), "Defender").isEmpty())) {
|
||||
return false;
|
||||
}
|
||||
if (ph.isPlayerTurn(human) && (!card.isAttacking()
|
||||
@@ -405,22 +407,22 @@ public class AbilityFactoryPump {
|
||||
} else if (keyword.endsWith("Flying")) {
|
||||
if (ph.isPlayerTurn(human)
|
||||
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
&& !AllZone.getCombat().getAttackerList().getKeyword("Flying").isEmpty()
|
||||
&& !CardListUtil.getKeyword(AllZone.getCombat().getAttackerList(), "Flying").isEmpty()
|
||||
&& !card.hasKeyword("Reach")
|
||||
&& CombatUtil.canBlock(card)
|
||||
&& CombatUtil.lifeInDanger(AllZone.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
Predicate<Card> flyingOrReach = Predicates.or(CardPredicates.hasKeyword("Flying"), CardPredicates.hasKeyword("Reach"));
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| cardsCanBlock.getNotKeyword("Flying").getNotKeyword("Reach").isEmpty()) {
|
||||
|| card.getNetCombatDamage() <= 0 || !Iterables.any(cardsCanBlock, Predicates.not(flyingOrReach))) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("Horsemanship")) {
|
||||
if (ph.isPlayerTurn(human)
|
||||
&& ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
&& !AllZone.getCombat().getAttackerList().getKeyword("Horsemanship").isEmpty()
|
||||
&& !CardListUtil.getKeyword(AllZone.getCombat().getAttackerList(), "Horsemanship").isEmpty()
|
||||
&& CombatUtil.canBlock(card)
|
||||
&& CombatUtil.lifeInDanger(AllZone.getCombat())) {
|
||||
return true;
|
||||
@@ -428,7 +430,7 @@ public class AbilityFactoryPump {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| cardsCanBlock.getNotKeyword("Horsemanship").isEmpty()) {
|
||||
|| CardListUtil.getNotKeyword(cardsCanBlock, "Horsemanship").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("Haste")) {
|
||||
@@ -484,7 +486,7 @@ public class AbilityFactoryPump {
|
||||
} else if (keyword.startsWith("Flanking")) {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| cardsCanBlock.getNotKeyword("Flanking").isEmpty()) {
|
||||
|| CardListUtil.getNotKeyword(cardsCanBlock, "Flanking").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.startsWith("Trample")) {
|
||||
@@ -528,13 +530,13 @@ public class AbilityFactoryPump {
|
||||
} else if (keyword.equals("Vigilance")) {
|
||||
if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||
|| AllZoneUtil.getCreaturesInPlay(human).getNotKeyword("Defender").size() < 1) {
|
||||
|| CardListUtil.getNotKeyword(AllZoneUtil.getCreaturesInPlay(human), "Defender").size() < 1) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Reach")) {
|
||||
if (ph.isPlayerTurn(computer)
|
||||
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| AllZone.getCombat().getAttackerList().getKeyword("Flying").isEmpty()
|
||||
|| CardListUtil.getKeyword(AllZone.getCombat().getAttackerList(), "Flying").isEmpty()
|
||||
|| card.hasKeyword("Flying")
|
||||
|| !CombatUtil.canBlock(card)) {
|
||||
return false;
|
||||
@@ -565,7 +567,7 @@ public class AbilityFactoryPump {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| AllZoneUtil.getPlayerLandsInPlay(human).getType("Island").isEmpty()
|
||||
|| CardListUtil.getType(AllZoneUtil.getPlayerLandsInPlay(human), "Island").isEmpty()
|
||||
|| cardsCanBlock.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -573,7 +575,7 @@ public class AbilityFactoryPump {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| AllZoneUtil.getPlayerLandsInPlay(human).getType("Swamp").isEmpty()
|
||||
|| CardListUtil.getType(AllZoneUtil.getPlayerLandsInPlay(human), "Swamp").isEmpty()
|
||||
|| cardsCanBlock.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -581,7 +583,7 @@ public class AbilityFactoryPump {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| AllZoneUtil.getPlayerLandsInPlay(human).getType("Mountain").isEmpty()
|
||||
|| CardListUtil.getType(AllZoneUtil.getPlayerLandsInPlay(human), "Mountain").isEmpty()
|
||||
|| cardsCanBlock.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -589,7 +591,7 @@ public class AbilityFactoryPump {
|
||||
if (ph.isPlayerTurn(human) || !(CombatUtil.canAttack(card) || card.isAttacking())
|
||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|
||||
|| card.getNetCombatDamage() <= 0
|
||||
|| AllZoneUtil.getPlayerLandsInPlay(human).getType("Forest").isEmpty()
|
||||
|| CardListUtil.getType(AllZoneUtil.getPlayerLandsInPlay(human), "Forest").isEmpty()
|
||||
|| cardsCanBlock.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1088,7 +1090,7 @@ public class AbilityFactoryPump {
|
||||
}
|
||||
|
||||
Card c;
|
||||
if (pref.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(pref, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getBestCreatureAI(pref);
|
||||
} else {
|
||||
c = CardFactoryUtil.getMostExpensivePermanentAI(pref, sa, true);
|
||||
@@ -1105,7 +1107,7 @@ public class AbilityFactoryPump {
|
||||
}
|
||||
|
||||
Card c;
|
||||
if (forced.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(forced, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getWorstCreatureAI(forced);
|
||||
} else {
|
||||
c = CardFactoryUtil.getCheapestPermanentAI(forced, sa, true);
|
||||
|
||||
@@ -445,7 +445,7 @@ public class AbilityFactoryRegenerate {
|
||||
// can target
|
||||
|
||||
// choose my best X without regen
|
||||
if (compTargetables.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(compTargetables, "Creature").size() == 0) {
|
||||
for (final Card c : combatants) {
|
||||
if (c.getShield() == 0) {
|
||||
tgt.addTarget(c);
|
||||
|
||||
@@ -865,13 +865,13 @@ public class AbilityFactorySacrifice {
|
||||
|
||||
// if only creatures are affected evaluate both lists and pass only if
|
||||
// human creatures are more valuable
|
||||
if ((humanlist.getNotType("Creature").size() == 0) && (computerlist.getNotType("Creature").size() == 0)) {
|
||||
if ((CardListUtil.getNotType(humanlist, "Creature").size() == 0) && (CardListUtil.getNotType(computerlist, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerlist) + 200) >= CardFactoryUtil
|
||||
.evaluateCreatureList(humanlist)) {
|
||||
return false;
|
||||
}
|
||||
} // only lands involved
|
||||
else if ((humanlist.getNotType("Land").size() == 0) && (computerlist.getNotType("Land").size() == 0)) {
|
||||
else if ((CardListUtil.getNotType(humanlist, "Land").size() == 0) && (CardListUtil.getNotType(computerlist, "Land").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluatePermanentList(computerlist) + 1) >= CardFactoryUtil
|
||||
.evaluatePermanentList(humanlist)) {
|
||||
return false;
|
||||
|
||||
@@ -113,7 +113,7 @@ class CardFactoryAuras {
|
||||
|
||||
newType[0] = landTypes[minAt];
|
||||
CardList list = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer());
|
||||
list = list.getNotType(newType[0]); // Don't enchant lands
|
||||
list = CardListUtil.getNotType(list, newType[0]); // Don't enchant lands
|
||||
// that already have the
|
||||
// type
|
||||
if (list.isEmpty()) {
|
||||
@@ -266,7 +266,7 @@ class CardFactoryAuras {
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
||||
list = list.getKeyword("Flying");
|
||||
list = CardListUtil.getKeyword(list, "Flying");
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ public class CardFactoryCreatures {
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
List<Card> wolves = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Wolf");
|
||||
List<Card> wolves = CardListUtil.getType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), "Wolf");
|
||||
Iterable<Card> untappedWolves = Iterables.filter(wolves, untappedCreature);
|
||||
|
||||
final int totalPower = Aggregates.sum(untappedWolves, CardPredicates.Accessors.fnGetNetAttack);
|
||||
@@ -575,7 +575,7 @@ public class CardFactoryCreatures {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
CardList wolves = card.getController().getCardsIn(ZoneType.Battlefield).getType("Wolf");
|
||||
CardList wolves = CardListUtil.getType(card.getController().getCardsIn(ZoneType.Battlefield), "Wolf");
|
||||
wolves = wolves.filter(untappedCreature);
|
||||
|
||||
final Card target = this.getTargetCard();
|
||||
|
||||
@@ -4,6 +4,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Command;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Singletons;
|
||||
@@ -69,7 +70,7 @@ class CardFactoryEnchantments {
|
||||
public boolean canPlay() {
|
||||
final CardList grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard);
|
||||
final CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard);
|
||||
return ((grave.getType("Creature").size() > 1) || (aiGrave.getType("Creature").size() > 1))
|
||||
return ((CardListUtil.getType(grave, "Creature").size() > 1) || (CardListUtil.getType(aiGrave, "Creature").size() > 1))
|
||||
&& super.canPlay();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Command;
|
||||
@@ -479,7 +480,7 @@ public class CardFactoryInstants {
|
||||
final String[] choices = new String[] { "Artifact", "Creature", "Land" };
|
||||
final Object o = GuiChoose.one("Select permanent type", choices);
|
||||
final String cardType = (String) o;
|
||||
final CardList list = this.getTargetPlayer().getCardsIn(ZoneType.Battlefield).getType(cardType);
|
||||
final CardList list = CardListUtil.getType(this.getTargetPlayer().getCardsIn(ZoneType.Battlefield), cardType);
|
||||
|
||||
final String[] tapOrUntap = new String[] { "Tap", "Untap" };
|
||||
final Object z = GuiChoose.one("Tap or Untap?", tapOrUntap);
|
||||
|
||||
@@ -488,7 +488,7 @@ class CardFactoryLands {
|
||||
|
||||
public void computerExecute() {
|
||||
CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand);
|
||||
hand = hand.getType(type);
|
||||
hand = CardListUtil.getType(hand, type);
|
||||
if (hand.size() > 0) {
|
||||
this.revealCard(hand.get(0));
|
||||
} else {
|
||||
|
||||
@@ -356,7 +356,7 @@ public class CardFactorySorceries {
|
||||
CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer());
|
||||
|
||||
for (final String element : Constant.Color.BASIC_LANDS) {
|
||||
final CardList cl = land.getType(element);
|
||||
final CardList cl = CardListUtil.getType(land, element);
|
||||
if (!cl.isEmpty()) {
|
||||
// remove one land of this basic type from this list
|
||||
// the computer AI should really jump in here and
|
||||
@@ -438,7 +438,7 @@ public class CardFactorySorceries {
|
||||
// get all other basic[count] lands human player
|
||||
// controls and add them to target
|
||||
CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer());
|
||||
CardList cl = land.getType(humanBasic.get(this.count));
|
||||
CardList cl = CardListUtil.getType(land, humanBasic.get(this.count));
|
||||
cl = cl.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card crd) {
|
||||
@@ -488,7 +488,7 @@ public class CardFactorySorceries {
|
||||
final CardList land = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
for (final String element : Constant.Color.BASIC_LANDS) {
|
||||
final CardList c = land.getType(element);
|
||||
final CardList c = CardListUtil.getType(land, element);
|
||||
if (!c.isEmpty()) {
|
||||
humanBasic.add(element);
|
||||
countBase[0]++;
|
||||
|
||||
@@ -247,7 +247,7 @@ public class CardFactoryUtil {
|
||||
// lands of one type....
|
||||
int n = 0;
|
||||
for (String name : Constant.Color.BASIC_LANDS) {
|
||||
n = land.getType(name).size();
|
||||
n = CardListUtil.getType(land, name).size();
|
||||
if ((n < iminBL) && (n > 0)) {
|
||||
// if two or more are tied, only the
|
||||
// first
|
||||
@@ -260,7 +260,7 @@ public class CardFactoryUtil {
|
||||
return null; // no basic land was a minimum
|
||||
}
|
||||
|
||||
final CardList bLand = land.getType(sminBL);
|
||||
final CardList bLand = CardListUtil.getType(land, sminBL);
|
||||
|
||||
for( Card ut : Iterables.filter(bLand, CardPredicates.Presets.UNTAPPED) )
|
||||
{
|
||||
@@ -590,11 +590,11 @@ public class CardFactoryUtil {
|
||||
public static Card getBestAI(final CardList list) {
|
||||
// Get Best will filter by appropriate getBest list if ALL of the list
|
||||
// is of that type
|
||||
if (list.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(list, "Creature").size() == 0) {
|
||||
return CardFactoryUtil.getBestCreatureAI(list);
|
||||
}
|
||||
|
||||
if (list.getNotType("Land").size() == 0) {
|
||||
if (CardListUtil.getNotType(list, "Land").size() == 0) {
|
||||
return CardFactoryUtil.getBestLandAI(list);
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ public class CardFactoryUtil {
|
||||
return CardFactoryUtil.getWorstLand(lands);
|
||||
}
|
||||
|
||||
if ((list.getType("Artifact").size() > 0) || (list.getType("Enchantment").size() > 0)) {
|
||||
if ((CardListUtil.getType(list, "Artifact").size() > 0) || (CardListUtil.getType(list, "Enchantment").size() > 0)) {
|
||||
return CardFactoryUtil.getCheapestPermanentAI(list.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -735,8 +735,8 @@ public class CardFactoryUtil {
|
||||
}), null, false);
|
||||
}
|
||||
|
||||
if (list.getType("Creature").size() > 0) {
|
||||
return CardFactoryUtil.getWorstCreatureAI(list.getType("Creature"));
|
||||
if (CardListUtil.getType(list, "Creature").size() > 0) {
|
||||
return CardFactoryUtil.getWorstCreatureAI(CardListUtil.getType(list, "Creature"));
|
||||
}
|
||||
|
||||
// Planeswalkers fall through to here, lands will fall through if there
|
||||
@@ -2025,7 +2025,7 @@ public class CardFactoryUtil {
|
||||
final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" };
|
||||
|
||||
for (int i = 0; i < basic.length; i++) {
|
||||
if (!someCards.getType(basic[i]).isEmpty()) {
|
||||
if (!CardListUtil.getType(someCards, basic[i]).isEmpty()) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -2045,7 +2045,7 @@ public class CardFactoryUtil {
|
||||
}
|
||||
if (sq[0].contains("LandsInGraveyard")) {
|
||||
if (players.size() > 0) {
|
||||
return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Graveyard).getType("Land").size(), m,
|
||||
return CardFactoryUtil.doXMath(CardListUtil.getType(players.get(0).getCardsIn(ZoneType.Graveyard), "Land").size(), m,
|
||||
source);
|
||||
}
|
||||
}
|
||||
@@ -2353,7 +2353,7 @@ public class CardFactoryUtil {
|
||||
if (sq[0].contains("Domain")) {
|
||||
someCards.addAll(cardController.getCardsIn(ZoneType.Battlefield));
|
||||
for (String basic : Constant.Color.BASIC_LANDS) {
|
||||
if (!someCards.getType(basic).isEmpty()) {
|
||||
if (!CardListUtil.getType(someCards, basic).isEmpty()) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -2364,7 +2364,7 @@ public class CardFactoryUtil {
|
||||
if (sq[0].contains("OpponentDom")) {
|
||||
someCards.addAll(cardController.getOpponent().getCardsIn(ZoneType.Battlefield));
|
||||
for (String basic : Constant.Color.BASIC_LANDS) {
|
||||
if (!someCards.getType(basic).isEmpty()) {
|
||||
if (!CardListUtil.getType(someCards, basic).isEmpty()) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -2493,7 +2493,7 @@ public class CardFactoryUtil {
|
||||
CardList enchantedControllerInPlay = new CardList();
|
||||
if (c.getEnchantingCard() != null) {
|
||||
enchantedControllerInPlay = c.getEnchantingCard().getController().getCardsIn(ZoneType.Battlefield);
|
||||
enchantedControllerInPlay = enchantedControllerInPlay.getType("Creature");
|
||||
enchantedControllerInPlay = CardListUtil.getType(enchantedControllerInPlay, "Creature");
|
||||
}
|
||||
return enchantedControllerInPlay.size();
|
||||
}
|
||||
@@ -4695,7 +4695,7 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
final CardList cardsInPlay = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("World");
|
||||
final CardList cardsInPlay = CardListUtil.getType(AllZoneUtil.getCardsIn(ZoneType.Battlefield), "World");
|
||||
cardsInPlay.remove(card);
|
||||
for (int i = 0; i < cardsInPlay.size(); i++) {
|
||||
Singletons.getModel().getGameAction().sacrificeDestroy(cardsInPlay.get(i));
|
||||
|
||||
@@ -106,7 +106,7 @@ public class CostSacrifice extends CostPartWithList {
|
||||
final Integer amount = this.convertAmount();
|
||||
|
||||
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||
typeList = typeList.getNotType("Creature");
|
||||
typeList = CardListUtil.getNotType(typeList, "Creature");
|
||||
}
|
||||
|
||||
if ((amount != null) && (typeList.size() < amount)) {
|
||||
@@ -158,7 +158,7 @@ public class CostSacrifice extends CostPartWithList {
|
||||
CardList list = activator.getCardsIn(ZoneType.Battlefield);
|
||||
list = CardListUtil.getValidCards(list, type.split(";"), activator, source);
|
||||
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||
list = list.getNotType("Creature");
|
||||
list = CardListUtil.getNotType(list, "Creature");
|
||||
}
|
||||
|
||||
if (this.getThis()) {
|
||||
@@ -206,7 +206,7 @@ public class CostSacrifice extends CostPartWithList {
|
||||
CardList typeList = activator.getCardsIn(ZoneType.Battlefield);
|
||||
typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), activator, source);
|
||||
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||
typeList = typeList.getNotType("Creature");
|
||||
typeList = CardListUtil.getNotType(typeList, "Creature");
|
||||
}
|
||||
// Does the AI want to use Sacrifice All?
|
||||
return false;
|
||||
|
||||
@@ -362,7 +362,7 @@ public class SpellPermanent extends Spell {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
List<String> type = card.getType();
|
||||
final String subtype = type.get(type.size() - 1);
|
||||
final CardList cl = list.getType(subtype);
|
||||
final CardList cl = CardListUtil.getType(list, subtype);
|
||||
|
||||
if (cl.size() > 0) {
|
||||
return false;
|
||||
@@ -371,7 +371,7 @@ public class SpellPermanent extends Spell {
|
||||
}
|
||||
if (card.isType("World")) {
|
||||
CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
list = list.getType("World");
|
||||
list = CardListUtil.getType(list, "World");
|
||||
if (list.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -908,22 +908,22 @@ public class CombatUtil {
|
||||
} else if (keyword.equals("Defender") && !c.hasKeyword("CARDNAME can attack as though it didn't have defender.")) {
|
||||
return false;
|
||||
} else if (keyword.equals("CARDNAME can't attack unless defending player controls an Island.")) {
|
||||
temp = list.getType("Island");
|
||||
temp = CardListUtil.getType(list, "Island");
|
||||
if (temp.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("CARDNAME can't attack unless defending player controls a Forest.")) {
|
||||
temp = list.getType("Forest");
|
||||
temp = CardListUtil.getType(list, "Forest");
|
||||
if (temp.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("CARDNAME can't attack unless defending player controls a Swamp.")) {
|
||||
temp = list.getType("Swamp");
|
||||
temp = CardListUtil.getType(list, "Swamp");
|
||||
if (temp.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("CARDNAME can't attack unless defending player controls a Mountain.")) {
|
||||
temp = list.getType("Mountain");
|
||||
temp = CardListUtil.getType(list, "Mountain");
|
||||
if (temp.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
}
|
||||
} else { // computer
|
||||
|
||||
final CardList indestruct = targets.getKeyword("Indestructible");
|
||||
final CardList indestruct = CardListUtil.getKeyword(targets, "Indestructible");
|
||||
if (indestruct.size() > 0) {
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(indestruct.get(0));
|
||||
} else if (targets.size() > 0) {
|
||||
@@ -1216,11 +1216,11 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
CardList humanCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
||||
humanCreatures = CardListUtil.getValidCards(humanCreatures, smallCreatures, k.getController(), k);
|
||||
humanCreatures = humanCreatures.getNotKeyword("Indestructible");
|
||||
humanCreatures = CardListUtil.getNotKeyword(humanCreatures, "Indestructible");
|
||||
|
||||
CardList computerCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
|
||||
computerCreatures = CardListUtil.getValidCards(computerCreatures, smallCreatures, k.getController(), k);
|
||||
computerCreatures = computerCreatures.getNotKeyword("Indestructible");
|
||||
computerCreatures = CardListUtil.getNotKeyword(computerCreatures, "Indestructible");
|
||||
|
||||
// We assume that both players will want to peek, ask if
|
||||
// they want to reveal.
|
||||
@@ -2065,7 +2065,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
private static void upkeepKarma() {
|
||||
final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
|
||||
final CardList karmas = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Karma");
|
||||
final CardList swamps = player.getCardsIn(ZoneType.Battlefield).getType("Swamp");
|
||||
final CardList swamps = CardListUtil.getType(player.getCardsIn(ZoneType.Battlefield), "Swamp");
|
||||
|
||||
// determine how much damage to deal the current player
|
||||
final int damage = swamps.size();
|
||||
|
||||
@@ -179,7 +179,7 @@ public class AIPlayer extends Player {
|
||||
@Override
|
||||
public final void discardUnless(final int num, final String uType, final SpellAbility sa) {
|
||||
final CardList hand = this.getCardsIn(ZoneType.Hand);
|
||||
final CardList tHand = hand.getType(uType);
|
||||
final CardList tHand = CardListUtil.getType(hand, uType);
|
||||
|
||||
if (tHand.size() > 0) {
|
||||
Card toDiscard = Aggregates.itemWithMin(tHand, CardPredicates.Accessors.fnGetCmc);
|
||||
|
||||
@@ -1397,7 +1397,7 @@ public class ComputerUtil {
|
||||
|
||||
// what types can I go get?
|
||||
for (final String name : Constant.CardTypes.BASIC_TYPES) {
|
||||
if (!landList.getType(name).isEmpty()) {
|
||||
if (!CardListUtil.getType(landList, name).isEmpty()) {
|
||||
basics.add(name);
|
||||
}
|
||||
}
|
||||
@@ -1409,7 +1409,7 @@ public class ComputerUtil {
|
||||
|
||||
for (int i = 0; i < basics.size(); i++) {
|
||||
final String b = basics.get(i);
|
||||
final int num = combined.getType(b).size();
|
||||
final int num = CardListUtil.getType(combined, b).size();
|
||||
if (num < minSize) {
|
||||
minType = b;
|
||||
minSize = num;
|
||||
@@ -1417,7 +1417,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
if (minType != null) {
|
||||
landList = landList.getType(minType);
|
||||
landList = CardListUtil.getType(landList, minType);
|
||||
}
|
||||
|
||||
land = landList.get(0);
|
||||
@@ -1491,10 +1491,10 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// Discard lands
|
||||
final CardList landsInHand = typeList.getType("Land");
|
||||
final CardList landsInHand = CardListUtil.getType(typeList, "Land");
|
||||
if (!landsInHand.isEmpty()) {
|
||||
final CardList landsInPlay = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Land");
|
||||
final CardList nonLandsInHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).getNotType("Land");
|
||||
final CardList landsInPlay = CardListUtil.getType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), "Land");
|
||||
final CardList nonLandsInHand = CardListUtil.getNotType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), "Land");
|
||||
final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, CardPredicates.Accessors.fnGetCmc));
|
||||
if (landsInPlay.size() >= highestCMC
|
||||
|| (landsInPlay.size() + landsInHand.size() > 6 && landsInHand.size() > 1)) {
|
||||
@@ -1528,7 +1528,7 @@ public class ComputerUtil {
|
||||
CardList typeList = activator.getCardsIn(ZoneType.Battlefield);
|
||||
typeList = CardListUtil.getValidCards(typeList, type.split(";"), activate.getController(), activate);
|
||||
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||
typeList = typeList.getNotType("Creature");
|
||||
typeList = CardListUtil.getNotType(typeList, "Creature");
|
||||
}
|
||||
|
||||
if ((target != null) && target.getController().isComputer() && typeList.contains(target)) {
|
||||
@@ -2036,7 +2036,7 @@ public class ComputerUtil {
|
||||
Card c = null;
|
||||
|
||||
if (destroy) {
|
||||
final CardList indestructibles = list.getKeyword("Indestructible");
|
||||
final CardList indestructibles = CardListUtil.getKeyword(list, "Indestructible");
|
||||
if (!indestructibles.isEmpty()) {
|
||||
c = indestructibles.get(0);
|
||||
}
|
||||
@@ -2052,9 +2052,9 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
if (list.getNotType("Creature").size() == 0) {
|
||||
if (CardListUtil.getNotType(list, "Creature").size() == 0) {
|
||||
c = CardFactoryUtil.getWorstCreatureAI(list);
|
||||
} else if (list.getNotType("Land").size() == 0) {
|
||||
} else if (CardListUtil.getNotType(list, "Land").size() == 0) {
|
||||
c = CardFactoryUtil.getWorstLand(AllZone.getComputerPlayer());
|
||||
} else {
|
||||
c = CardFactoryUtil.getWorstPermanentAI(list, false, false, false, false);
|
||||
@@ -2299,7 +2299,7 @@ public class ComputerUtil {
|
||||
}
|
||||
final CardList landsInPlay = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).filter(CardPredicates.Presets.LANDS);
|
||||
final CardList landsInHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).filter(CardPredicates.Presets.LANDS);
|
||||
final CardList nonLandsInHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).getNotType("Land");
|
||||
final CardList nonLandsInHand = CardListUtil.getNotType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), "Land");
|
||||
final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, CardPredicates.Accessors.fnGetCmc));
|
||||
final int discardCMC = discard.getCMC();
|
||||
if (discard.isLand()) {
|
||||
|
||||
@@ -597,7 +597,7 @@ public class ComputerUtilBlock {
|
||||
|
||||
CardList chumpBlockers;
|
||||
|
||||
CardList tramplingAttackers = ComputerUtilBlock.getAttackers().getKeyword("Trample");
|
||||
CardList tramplingAttackers = CardListUtil.getKeyword(ComputerUtilBlock.getAttackers(), "Trample");
|
||||
tramplingAttackers = tramplingAttackers.filter(Predicates.not(rampagesOrNeedsManyToBlock));
|
||||
|
||||
// TODO - should check here for a "rampage-like" trigger that replaced
|
||||
@@ -675,8 +675,8 @@ public class ComputerUtilBlock {
|
||||
// Don't use blockers without First Strike or Double Strike if
|
||||
// attacker has it
|
||||
if (attacker.hasKeyword("First Strike") || attacker.hasKeyword("Double Strike")) {
|
||||
safeBlockers = blockers.getKeyword("First Strike");
|
||||
safeBlockers.addAll(blockers.getKeyword("Double Strike"));
|
||||
safeBlockers = CardListUtil.getKeyword(blockers, "First Strike");
|
||||
safeBlockers.addAll(CardListUtil.getKeyword(blockers, "Double Strike"));
|
||||
} else {
|
||||
safeBlockers = new CardList(blockers);
|
||||
}
|
||||
@@ -884,7 +884,7 @@ public class ComputerUtilBlock {
|
||||
}
|
||||
|
||||
// assign blockers that have to block
|
||||
chumpBlockers = ComputerUtilBlock.getBlockersLeft().getKeyword("CARDNAME blocks each turn if able.");
|
||||
chumpBlockers = CardListUtil.getKeyword(ComputerUtilBlock.getBlockersLeft(), "CARDNAME blocks each turn if able.");
|
||||
// if an attacker with lure attacks - all that can block
|
||||
for (final Card blocker : ComputerUtilBlock.getBlockersLeft()) {
|
||||
if (CombatUtil.mustBlockAnAttacker(blocker, combat)) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.base.Predicate;
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.control.input.Input;
|
||||
@@ -57,7 +58,7 @@ public final class PlayerUtil {
|
||||
public static boolean worshipFlag(final Player player) {
|
||||
// Instead of hardcoded Ali from Cairo like cards, it is now a Keyword
|
||||
CardList list = player.getCardsIn(ZoneType.Battlefield);
|
||||
list = list.getKeyword("Damage that would reduce your life total to less than 1 reduces it to 1 instead.");
|
||||
list = CardListUtil.getKeyword(list, "Damage that would reduce your life total to less than 1 reduces it to 1 instead.");
|
||||
list = list.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -260,7 +261,7 @@ public final class PlayerUtil {
|
||||
public static Input inputSacrificePermanents(final int nCards, final String type) {
|
||||
CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
list = list.getType(type);
|
||||
list = CardListUtil.getType(list, type);
|
||||
return PlayerUtil.inputSacrificePermanentsFromList(nCards, list, "Select a " + type + " to sacrifice");
|
||||
} // input_sacrificePermanents()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user