mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
replacing CardList calls with iterables where possible
This commit is contained in:
@@ -32,6 +32,7 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.card.CardCharacteristics;
|
||||
import forge.card.CardManaCost;
|
||||
@@ -8275,7 +8276,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
final CardList auras = new CardList(this.getEnchantedBy());
|
||||
|
||||
if (auras.containsName("Treacherous Link")) {
|
||||
if (Iterables.any(auras, CardPredicates.nameEquals("Treacherous Link"))) {
|
||||
this.getController().addDamage(damageIn, source);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,15 +59,6 @@ public class CardList extends ArrayList<Card> {
|
||||
return new CardList(Iterables.filter(this, filt));
|
||||
}
|
||||
|
||||
public final boolean containsName(final String name) {
|
||||
return Iterables.any(this, CardPredicates.nameEquals(name));
|
||||
}
|
||||
|
||||
public final CardList getController(final Player player) {
|
||||
return this.filter(CardPredicates.isController(player));
|
||||
}
|
||||
|
||||
|
||||
// cardType is like "Land" or "Goblin", returns a new CardList that is a
|
||||
// subset of current CardList
|
||||
public final CardList getType(final String cardType) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
@@ -295,4 +296,8 @@ public class CardListUtil {
|
||||
Collections.shuffle(list, MyRandom.getRandom());
|
||||
Collections.shuffle(list, MyRandom.getRandom());
|
||||
}
|
||||
|
||||
public static CardList filterControlledBy(CardList cardList, Player player) {
|
||||
return cardList.filter(CardPredicates.isController(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
@@ -368,7 +371,7 @@ public final class AbilityFactoryAnimate {
|
||||
// don't animate if the AI won't attack anyway
|
||||
if (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
|
||||
&& AllZone.getComputerPlayer().getLife() < 6 && AllZone.getHumanPlayer().getLife() > 6
|
||||
&& !AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature").isEmpty()) {
|
||||
&& Iterables.any(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ public class AbilityFactoryAttach {
|
||||
}
|
||||
// Some ChangeType cards are beneficial, and PrefPlayer should be
|
||||
// changed to represent that
|
||||
final CardList prefList = list.getController(prefPlayer);
|
||||
final CardList prefList = CardListUtil.filterControlledBy(list, prefPlayer);
|
||||
|
||||
// If there are no preferred cards, and not mandatory bail out
|
||||
if (prefList.size() == 0) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.CardListUtil;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.GameActionUtil;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
@@ -1356,34 +1357,15 @@ public final class AbilityFactoryChangeZone {
|
||||
*/
|
||||
private static Card basicManaFixing(final CardList list) { // Search for a
|
||||
// Basic Land
|
||||
return AbilityFactoryChangeZone.basicManaFixing(list, "Plains, Island, Swamp, Mountain, Forest");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* basicManaFixing.
|
||||
* </p>
|
||||
*
|
||||
* @param list
|
||||
* a {@link forge.CardList} object.
|
||||
* @param type
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
private static Card basicManaFixing(CardList list, final String type) { // type
|
||||
// =
|
||||
// basic
|
||||
// land
|
||||
// types
|
||||
final CardList combined = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
combined.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand));
|
||||
|
||||
final String[] names = type.split(",");
|
||||
final ArrayList<String> basics = new ArrayList<String>();
|
||||
|
||||
// what types can I go get?
|
||||
for (final String name : names) {
|
||||
if (list.getType(name).size() != 0) {
|
||||
for (final String name : Constant.Color.BASIC_LANDS) {
|
||||
if (!list.getType(name).isEmpty()) {
|
||||
basics.add(name);
|
||||
}
|
||||
}
|
||||
@@ -1402,11 +1384,12 @@ public final class AbilityFactoryChangeZone {
|
||||
}
|
||||
}
|
||||
|
||||
List<Card> result = list;
|
||||
if (minType != null) {
|
||||
list = list.getType(minType);
|
||||
result = list.getType(minType);
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1665,7 +1648,7 @@ public final class AbilityFactoryChangeZone {
|
||||
if (origin.equals(ZoneType.Battlefield)) {
|
||||
// filter out untargetables
|
||||
list = list.getTargetableCards(sa);
|
||||
CardList aiPermanents = list.getController(AllZone.getComputerPlayer());
|
||||
CardList aiPermanents = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
|
||||
// Don't blink cards that will die.
|
||||
aiPermanents = aiPermanents.filter(new Predicate<Card>() {
|
||||
@@ -1736,7 +1719,7 @@ public final class AbilityFactoryChangeZone {
|
||||
} else if (origin.equals(ZoneType.Graveyard)) {
|
||||
if (destination.equals(ZoneType.Hand)) {
|
||||
// only retrieve cards from computer graveyard
|
||||
list = list.getController(AllZone.getComputerPlayer());
|
||||
list = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
System.out.println("changeZone:" + list);
|
||||
}
|
||||
|
||||
@@ -1761,7 +1744,7 @@ public final class AbilityFactoryChangeZone {
|
||||
&& AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
list = list.getController(AllZone.getHumanPlayer());
|
||||
list = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer());
|
||||
list = list.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
|
||||
@@ -34,6 +34,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.CardUtil;
|
||||
@@ -389,13 +390,11 @@ public final class AbilityFactoryChoose {
|
||||
chosen = CardFactoryUtil.getMostProminentCreatureType(AllZone.getHumanPlayer()
|
||||
.getCardsIn(ZoneType.Battlefield));
|
||||
if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) {
|
||||
chosen = CardFactoryUtil.getMostProminentCreatureType(AllZoneUtil.getCardsInGame()
|
||||
.getController(AllZone.getHumanPlayer()));
|
||||
chosen = CardFactoryUtil.getMostProminentCreatureType(CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer()));
|
||||
}
|
||||
}
|
||||
if (logic.equals("MostProminentInComputerDeck")) {
|
||||
chosen = CardFactoryUtil.getMostProminentCreatureType(AllZoneUtil.getCardsInGame()
|
||||
.getController(AllZone.getComputerPlayer()));
|
||||
chosen = CardFactoryUtil.getMostProminentCreatureType(CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getComputerPlayer()));
|
||||
}
|
||||
if (logic.equals("MostProminentInComputerGraveyard")) {
|
||||
chosen = CardFactoryUtil.getMostProminentCreatureType(AllZone.getComputerPlayer()
|
||||
@@ -726,11 +725,9 @@ public final class AbilityFactoryChoose {
|
||||
if (params.containsKey("AILogic")) {
|
||||
final String logic = params.get("AILogic");
|
||||
if (logic.equals("MostProminentInHumanDeck")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame().getController(
|
||||
AllZone.getHumanPlayer()));
|
||||
chosen = CardFactoryUtil.getMostProminentColor(CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer()));
|
||||
} else if (logic.equals("MostProminentInComputerDeck")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame().getController(
|
||||
AllZone.getComputerPlayer()));
|
||||
chosen = CardFactoryUtil.getMostProminentColor(CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getComputerPlayer()));
|
||||
}
|
||||
else if (logic.equals("MostProminentInGame")) {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame());
|
||||
@@ -738,7 +735,7 @@ public final class AbilityFactoryChoose {
|
||||
else if (logic.equals("MostProminentHumanCreatures")) {
|
||||
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
||||
if (list.isEmpty()) {
|
||||
list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer())
|
||||
list = CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer())
|
||||
.filter(CardPredicates.Presets.CREATURES);
|
||||
}
|
||||
chosen = CardFactoryUtil.getMostProminentColor(list);
|
||||
@@ -1644,7 +1641,7 @@ public final class AbilityFactoryChoose {
|
||||
.getCardsIn(ZoneType.Library));
|
||||
}
|
||||
} else {
|
||||
CardList list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer());
|
||||
CardList list = CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer());
|
||||
list = list.filter(Predicates.not(Presets.LANDS));
|
||||
if (!list.isEmpty()) {
|
||||
chosen = list.get(0).getName();
|
||||
|
||||
@@ -30,6 +30,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Counters;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -1898,8 +1899,8 @@ public class AbilityFactoryCounters {
|
||||
|
||||
tgt.addTarget(pl);
|
||||
|
||||
hList = hList.getController(pl);
|
||||
cList = cList.getController(pl);
|
||||
hList = CardListUtil.filterControlledBy(hList, pl);
|
||||
cList = CardListUtil.filterControlledBy(cList, pl);
|
||||
}
|
||||
|
||||
// TODO improve X value to don't overpay when extra mana won't do
|
||||
@@ -2011,7 +2012,7 @@ public class AbilityFactoryCounters {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
final Player pl = sa.getTargetPlayer();
|
||||
cards = cards.getController(pl);
|
||||
cards = CardListUtil.filterControlledBy(cards, pl);
|
||||
}
|
||||
|
||||
for (final Card tgtCard : cards) {
|
||||
@@ -2266,7 +2267,7 @@ public class AbilityFactoryCounters {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
final Player pl = sa.getTargetPlayer();
|
||||
cards = cards.getController(pl);
|
||||
cards = CardListUtil.filterControlledBy(cards, pl);
|
||||
}
|
||||
|
||||
for (final Card tgtCard : cards) {
|
||||
|
||||
@@ -22,11 +22,14 @@ import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -462,7 +465,7 @@ public class AbilityFactoryDealDamage {
|
||||
return false;
|
||||
}
|
||||
// burn Planeswalkers
|
||||
if (!human.getCardsIn(ZoneType.Battlefield).getType("Planeswalker").isEmpty()) {
|
||||
if (Iterables.any(human.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1360,7 +1363,7 @@ public class AbilityFactoryDealDamage {
|
||||
}
|
||||
|
||||
if (targetPlayer != null) {
|
||||
list = list.getController(targetPlayer);
|
||||
list = CardListUtil.filterControlledBy(list, targetPlayer);
|
||||
}
|
||||
|
||||
list = AbilityFactory.filterListByType(list, params.get("ValidCards"), sa);
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -490,8 +491,8 @@ public final class AbilityFactoryDebuff {
|
||||
list.remove(c);
|
||||
}
|
||||
|
||||
final CardList pref = list.getController(AllZone.getHumanPlayer());
|
||||
final CardList forced = list.getController(AllZone.getComputerPlayer());
|
||||
final CardList pref = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer());
|
||||
final CardList forced = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.CardUtil;
|
||||
import forge.Counters;
|
||||
import forge.Singletons;
|
||||
@@ -318,7 +319,7 @@ public class AbilityFactoryDestroy {
|
||||
if (params.containsKey("Defined")) {
|
||||
list = new CardList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa));
|
||||
if (list.isEmpty()
|
||||
|| !list.getController(AllZone.getComputerPlayer()).isEmpty()
|
||||
|| !CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()).isEmpty()
|
||||
|| list.getNotKeyword("Indestructible").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -387,7 +388,7 @@ public class AbilityFactoryDestroy {
|
||||
tgt.resetTargets();
|
||||
|
||||
CardList preferred = list.getNotKeyword("Indestructible");
|
||||
preferred = preferred.getController(AllZone.getHumanPlayer());
|
||||
preferred = CardListUtil.filterControlledBy(preferred, AllZone.getHumanPlayer());
|
||||
|
||||
// If NoRegen is not set, filter out creatures that have a
|
||||
// regeneration shield
|
||||
@@ -1040,7 +1041,7 @@ public class AbilityFactoryDestroy {
|
||||
CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
if (targetPlayer != null) {
|
||||
list = list.getController(targetPlayer);
|
||||
list = CardListUtil.filterControlledBy(list, targetPlayer);
|
||||
}
|
||||
|
||||
list = AbilityFactory.filterListByType(list, valid, sa);
|
||||
|
||||
@@ -28,6 +28,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Command;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
@@ -559,8 +560,7 @@ public class AbilityFactoryGainControl {
|
||||
private boolean gainControlDrawbackAI(final SpellAbility sa) {
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
if (this.params.containsKey("AllValid")) {
|
||||
CardList tgtCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield)
|
||||
.getController(AllZone.getHumanPlayer());
|
||||
CardList tgtCards = CardListUtil.filterControlledBy(AllZoneUtil.getCardsIn(ZoneType.Battlefield), AllZone.getHumanPlayer());
|
||||
tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa);
|
||||
if (tgtCards.isEmpty()) {
|
||||
return false;
|
||||
|
||||
@@ -22,10 +22,15 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
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;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardPredicates;
|
||||
import forge.Constant;
|
||||
import forge.Counters;
|
||||
import forge.Singletons;
|
||||
@@ -995,9 +1000,9 @@ public class AbilityFactoryMana {
|
||||
*/
|
||||
private static boolean hasUrzaLands(final Player p) {
|
||||
final CardList landsControlled = p.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
return (landsControlled.containsName("Urza's Mine") && landsControlled.containsName("Urza's Tower") && landsControlled
|
||||
.containsName("Urza's Power Plant"));
|
||||
return Iterables.any(landsControlled, CardPredicates.nameEquals("Urza's Mine")) &&
|
||||
Iterables.any(landsControlled, CardPredicates.nameEquals("Urza's Tower")) &&
|
||||
Iterables.any(landsControlled, CardPredicates.nameEquals("Urza's Power Plant"));
|
||||
}
|
||||
|
||||
// ****************************************
|
||||
|
||||
@@ -459,7 +459,7 @@ public class AbilityFactoryPreventDamage {
|
||||
// filter AIs battlefield by what I can target
|
||||
CardList targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield);
|
||||
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
||||
final CardList compTargetables = targetables.getController(AllZone.getComputerPlayer());
|
||||
final CardList compTargetables = CardListUtil.filterControlledBy(targetables, AllZone.getComputerPlayer());
|
||||
|
||||
if (targetables.size() == 0) {
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.Constant;
|
||||
@@ -482,7 +483,7 @@ public final class AbilityFactoryProtection {
|
||||
list.remove(c);
|
||||
}
|
||||
|
||||
CardList pref = list.getController(AllZone.getComputerPlayer());
|
||||
CardList pref = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
pref = pref.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -490,7 +491,7 @@ public final class AbilityFactoryProtection {
|
||||
AbilityFactoryProtection.getProtectionList(host, params));
|
||||
}
|
||||
});
|
||||
final CardList pref2 = list.getController(AllZone.getComputerPlayer());
|
||||
final CardList pref2 = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
pref = pref.filter(new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -498,7 +499,7 @@ public final class AbilityFactoryProtection {
|
||||
AbilityFactoryProtection.getProtectionList(host, params));
|
||||
}
|
||||
});
|
||||
final CardList forced = list.getController(AllZone.getHumanPlayer());
|
||||
final CardList forced = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer());
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
@@ -743,7 +744,7 @@ public final class AbilityFactoryProtection {
|
||||
if (logic.equals("MostProminentHumanCreatures")) {
|
||||
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
||||
if (list.isEmpty()) {
|
||||
list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer());
|
||||
list = CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer());
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
choice = CardFactoryUtil.getMostProminentColor(list);
|
||||
|
||||
@@ -1075,11 +1075,11 @@ public class AbilityFactoryPump {
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
if (af.isCurse()) {
|
||||
pref = list.getController(AllZone.getHumanPlayer());
|
||||
forced = list.getController(AllZone.getComputerPlayer());
|
||||
pref = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer());
|
||||
forced = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
} else {
|
||||
pref = list.getController(AllZone.getComputerPlayer());
|
||||
forced = list.getController(AllZone.getHumanPlayer());
|
||||
pref = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer());
|
||||
forced = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer());
|
||||
}
|
||||
|
||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
|
||||
@@ -419,7 +419,7 @@ public class AbilityFactoryRegenerate {
|
||||
// filter AIs battlefield by what I can target
|
||||
CardList targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield);
|
||||
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
||||
final CardList compTargetables = targetables.getController(AllZone.getComputerPlayer());
|
||||
final CardList compTargetables = CardListUtil.filterControlledBy(targetables, AllZone.getComputerPlayer());
|
||||
|
||||
if (targetables.size() == 0) {
|
||||
return false;
|
||||
|
||||
@@ -26,6 +26,7 @@ import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.Spell;
|
||||
@@ -472,7 +473,7 @@ public class AbilityFactorySetState {
|
||||
CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
if (targetPlayer != null) {
|
||||
list = list.getController(targetPlayer);
|
||||
list = CardListUtil.filterControlledBy(list, targetPlayer);
|
||||
}
|
||||
|
||||
list = AbilityFactory.filterListByType(list, valid, sa);
|
||||
|
||||
@@ -1021,8 +1021,7 @@ public class CardFactorySorceries {
|
||||
}
|
||||
|
||||
// Actually put everything on the battlefield
|
||||
CardList bidded = AllZoneUtil.getCardsIn(ZoneType.Graveyard);
|
||||
bidded = bidded.getType("Creature");
|
||||
CardList bidded = AllZoneUtil.getCardsIn(ZoneType.Graveyard).filter(CardPredicates.Presets.CREATURES);
|
||||
for (final Card c : bidded) {
|
||||
if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) {
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class CardFactoryUtil {
|
||||
|
||||
// Add all cost of all auras with the same controller
|
||||
final CardList auras = new CardList(card.getEnchantedBy());
|
||||
auras.getController(card.getController());
|
||||
CardListUtil.filterControlledBy(auras, card.getController());
|
||||
curCMC += CardListUtil.sumCMC(auras) + auras.size();
|
||||
|
||||
if (curCMC >= bigCMC) {
|
||||
@@ -4151,7 +4151,7 @@ public class CardFactoryUtil {
|
||||
AllZone.getInputControl().setInput(target);
|
||||
} else {
|
||||
// AI choosing what to haunt
|
||||
final CardList oppCreats = creats.getController(AllZone.getHumanPlayer());
|
||||
final CardList oppCreats = CardListUtil.filterControlledBy(creats, AllZone.getHumanPlayer());
|
||||
if (oppCreats.size() != 0) {
|
||||
haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats));
|
||||
} else {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Random;
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Counters;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.mana.ManaCost;
|
||||
@@ -77,7 +78,7 @@ public class CostUtil {
|
||||
return false;
|
||||
}
|
||||
CardList auras = new CardList(source.getEnchantedBy());
|
||||
if (!auras.getController(source.getController()).isEmpty()) {
|
||||
if (!CardListUtil.filterControlledBy(auras, source.getController()).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.control.input.Input;
|
||||
import forge.game.player.Player;
|
||||
@@ -293,11 +294,11 @@ public class TargetSelection {
|
||||
|
||||
// If all cards must be from the same zone
|
||||
if (tgt.isSingleZone() && !targeted.isEmpty()) {
|
||||
choices = choices.getController(targeted.get(0).getController());
|
||||
choices = CardListUtil.filterControlledBy(choices, targeted.get(0).getController());
|
||||
}
|
||||
// If all cards must be from different zones
|
||||
if (tgt.isDifferentZone() && !targeted.isEmpty()) {
|
||||
choices = choices.getController(targeted.get(0).getController().getOpponent());
|
||||
choices = CardListUtil.filterControlledBy(choices, targeted.get(0).getController().getOpponent());
|
||||
}
|
||||
// If the cards can't share a creature type
|
||||
if (tgt.isWithoutSameCreatureType() && !targeted.isEmpty()) {
|
||||
@@ -314,7 +315,7 @@ public class TargetSelection {
|
||||
ArrayList<Player> pl = AbilityFactory.getDefinedPlayers(card, tgt.getDefinedController(), this.ability);
|
||||
if (pl != null && !pl.isEmpty()) {
|
||||
Player controller = pl.get(0);
|
||||
choices = choices.getController(controller);
|
||||
choices = CardListUtil.filterControlledBy(choices, controller);
|
||||
} else {
|
||||
choices.clear();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.Command;
|
||||
import forge.CommandArgs;
|
||||
import forge.GameActionUtil;
|
||||
@@ -315,7 +316,7 @@ public class TriggerHandler {
|
||||
|
||||
// AP
|
||||
allCards = playerAP.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
|
||||
allCards.addAll(AllZoneUtil.getCardsIn(ZoneType.Stack).getController(playerAP));
|
||||
allCards.addAll(CardListUtil.filterControlledBy(AllZoneUtil.getCardsIn(ZoneType.Stack), playerAP));
|
||||
// add cards that move to hidden zones
|
||||
if (runParams.containsKey("Destination") && runParams.containsKey("Card")) {
|
||||
Card card = (Card) runParams.get("Card");
|
||||
@@ -341,7 +342,7 @@ public class TriggerHandler {
|
||||
|
||||
// NAP
|
||||
allCards = playerAP.getOpponent().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES);
|
||||
allCards.addAll(AllZoneUtil.getCardsIn(ZoneType.Stack).getController(playerAP.getOpponent()));
|
||||
allCards.addAll(CardListUtil.filterControlledBy(AllZoneUtil.getCardsIn(ZoneType.Stack), playerAP.getOpponent()));
|
||||
// add cards that move to hidden zones
|
||||
if (runParams.containsKey("Destination") && runParams.containsKey("Card")) {
|
||||
Card card = (Card) runParams.get("Card");
|
||||
|
||||
@@ -2026,7 +2026,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
final Ability ability = new Ability(oathList.get(0), "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
final CardList graveyardCreatures = player.getCardsIn(ZoneType.Graveyard).getType("Creature");
|
||||
final CardList graveyardCreatures = player.getCardsIn(ZoneType.Graveyard).filter(CardPredicates.Presets.CREATURES);
|
||||
|
||||
if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) {
|
||||
if (player.isHuman()) {
|
||||
|
||||
@@ -1354,7 +1354,7 @@ public class ComputerUtil {
|
||||
}
|
||||
if (c.isType("Legendary") && !c.getName().equals("Flagstones of Trokair")) {
|
||||
final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
if (list.containsName(c.getName())) {
|
||||
if (Iterables.any(list, CardPredicates.nameEquals(c.getName()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1366,7 +1366,7 @@ public class ComputerUtil {
|
||||
final CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand);
|
||||
CardList lands = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
||||
lands.addAll(hand);
|
||||
lands = lands.getType("Land");
|
||||
lands = lands.filter(CardPredicates.Presets.LANDS);
|
||||
int maxCmcInHand = Aggregates.max(hand, CardPredicates.Accessors.fnGetCmc);
|
||||
for (final SpellAbility sa : spellAbilities) {
|
||||
if (sa.isCycling()) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListUtil;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Command;
|
||||
import forge.GameActionUtil;
|
||||
@@ -941,7 +942,7 @@ public class MagicStack extends MyObservable {
|
||||
AllZone.getInputControl().setInput(target);
|
||||
} else {
|
||||
// AI choosing what to haunt
|
||||
final CardList oppCreats = creats.getController(AllZone.getHumanPlayer());
|
||||
final CardList oppCreats = CardListUtil.filterControlledBy(creats, AllZone.getHumanPlayer());
|
||||
if (oppCreats.size() != 0) {
|
||||
haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user