diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java index 2b2617697e7..bc960d18e34 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java @@ -1244,7 +1244,6 @@ public final class AbilityFactoryChangeZone { // Does AI need a land? List hand = ai.getCardsIn(ZoneType.Hand); - System.out.println("Lands in hand = " + CardLists.filter(hand, Presets.LANDS).size() + ", on battlefield = " + CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size()); if (CardLists.filter(hand, Presets.LANDS).size() == 0 && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() < 4) { boolean canCastSomething = false; for (Card cardInHand : hand) { @@ -1388,7 +1387,7 @@ public final class AbilityFactoryChangeZone { private static Card basicManaFixing(final Player ai, final List list) { // Search for a // Basic Land - final List combined = ai.getCardsIn(ZoneType.Battlefield); + final List combined = new ArrayList(ai.getCardsIn(ZoneType.Battlefield)); combined.addAll(ai.getCardsIn(ZoneType.Hand)); final ArrayList basics = new ArrayList(); @@ -1586,7 +1585,7 @@ public final class AbilityFactoryChangeZone { } // don't return something to your hand if your hand is full of good stuff if (destination.equals(ZoneType.Hand) && origin.equals(ZoneType.Graveyard)) { - int handSize = ai.getCardsIn(ZoneType.Hand).size(); + final int handSize = ai.getCardsIn(ZoneType.Hand).size(); if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN1)) { return false; } @@ -2596,8 +2595,7 @@ public final class AbilityFactoryChangeZone { // ex. "Return all blocking/blocked by target creature" final Player opp = ai.getOpponent(); - List humanType = opp.getCardsIn(origin); - humanType = AbilityFactory.filterListByType(humanType, params.get("ChangeType"), sa); + final List humanType = AbilityFactory.filterListByType(opp.getCardsIn(origin), params.get("ChangeType"), sa); List computerType = ai.getCardsIn(origin); computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa); final Target tgt = sa.getTarget(); @@ -2762,8 +2760,7 @@ public final class AbilityFactoryChangeZone { final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); final Player opp = ai.getOpponent(); - List humanType = opp.getCardsIn(origin); - humanType = AbilityFactory.filterListByType(humanType, params.get("ChangeType"), sa); + final List humanType = AbilityFactory.filterListByType(opp.getCardsIn(origin), params.get("ChangeType"), sa); List computerType = ai.getCardsIn(origin); computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java index 9ba635ff0dc..89d0a58e100 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java @@ -527,8 +527,7 @@ public class AbilityFactoryDealDamage { final Target tgt = saMe.getTarget(); final Card source = saMe.getSourceCard(); final HashMap params = this.abilityFactory.getMapParams(); - List hPlay = pl.getCardsIn(ZoneType.Battlefield); - hPlay = CardLists.getValidCards(hPlay, tgt.getValidTgts(), ai, source); + List hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source); final ArrayList objects = tgt.getTargets(); if (params.containsKey("TargetUnique")) { @@ -1254,8 +1253,8 @@ public class AbilityFactoryDealDamage { } // TODO: X may be something different than X paid - List list = player.getCardsIn(ZoneType.Battlefield); - list = CardLists.getValidCards(list, validC.split(","), source.getController(), source); + List list = + CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), validC.split(","), source.getController(), source); final Predicate filterKillable = new Predicate() { @Override diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java index a5f65834200..b854b5b2f86 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java @@ -811,10 +811,8 @@ public final class AbilityFactoryDebuff { valid = params.get("ValidCards"); } - List comp = ai.getCardsIn(ZoneType.Battlefield); - comp = CardLists.getValidCards(comp, valid, hostCard.getController(), hostCard); - List human = opp.getCardsIn(ZoneType.Battlefield); - human = CardLists.getValidCards(human, valid, hostCard.getController(), hostCard); + List comp = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid, hostCard.getController(), hostCard); + List human = CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid, hostCard.getController(), hostCard); // TODO - add blocking situations here also diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java index 24f25b7f347..3e170feb23f 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java @@ -246,8 +246,7 @@ public class AbilityFactoryDestroy { // Targeting if (abTgt != null) { abTgt.resetTargets(); - list = ai.getOpponent().getCardsIn(ZoneType.Battlefield); - list = CardLists.getTargetableCards(list, sa); + list = CardLists.getTargetableCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), sa); list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); if (params.containsKey("AITgts")) { list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source); @@ -846,21 +845,22 @@ public class AbilityFactoryDestroy { final HashMap params = af.getMapParams(); final Target tgt = sa.getTarget(); String valid = ""; + if (mandatory) { + return true; + } if (params.containsKey("ValidCards")) { valid = params.get("ValidCards"); } - List humanlist = ai.getOpponent().getCardsIn(ZoneType.Battlefield); - List computerlist = ai.getCardsIn(ZoneType.Battlefield); + List humanlist = + CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); + List computerlist = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); if (sa.getTarget() != null) { tgt.resetTargets(); sa.getTarget().addTarget(ai.getOpponent()); computerlist.clear(); } - if (mandatory) { - return true; - } - humanlist = CardLists.getValidCards(humanlist, valid.split(","), source.getController(), source); - computerlist = CardLists.getValidCards(computerlist, valid.split(","), source.getController(), source); + humanlist = CardLists.filter(humanlist, new Predicate() { @Override public boolean apply(final Card c) { @@ -930,20 +930,18 @@ public class AbilityFactoryDestroy { valid = valid.replace("X", Integer.toString(xPay)); } - List humanlist = ai.getOpponent().getCardsIn(ZoneType.Battlefield); - List computerlist = ai.getCardsIn(ZoneType.Battlefield); - final Target tgt = sa.getTarget(); + List humanlist = + CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); + List computerlist = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source); if (sa.getTarget() != null) { tgt.resetTargets(); sa.getTarget().addTarget(ai.getOpponent()); computerlist.clear(); } - humanlist = CardLists.getValidCards(humanlist, valid.split(","), source.getController(), source); - computerlist = CardLists.getValidCards(computerlist, valid.split(","), source.getController(), source); - humanlist = CardLists.filter(humanlist, new Predicate() { @Override public boolean apply(final Card c) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java index a617ea2285e..6c2609c602c 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java @@ -334,8 +334,8 @@ public class AbilityFactoryGainControl { } } - List list = opp.getCardsIn(ZoneType.Battlefield); - list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getSourceCard().getController(), sa.getSourceCard()); + List list = + CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); // AI won't try to grab cards that are filtered out of AI decks on // purpose list = CardLists.filter(list, new Predicate() { @@ -854,8 +854,8 @@ public class AbilityFactoryGainControl { final Target tgt = sa.getTarget(); tgt.resetTargets(); - List list = ai.getOpponent().getCardsIn(ZoneType.Battlefield); - list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, sa.getSourceCard()); + List list = + CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getSourceCard()); // AI won't try to grab cards that are filtered out of AI decks on // purpose list = CardLists.filter(list, new Predicate() { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java index 708f3623ddd..a4d6cecf7bd 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java @@ -1328,8 +1328,8 @@ public class AbilityFactoryZoneAffecting { } if (mode.equals("NotRemembered")) { - List dPHand = p.getCardsIn(ZoneType.Hand); - dPHand = CardLists.getValidCards(dPHand, "Card.IsNotRemembered", source.getController(), source); + final List dPHand = + CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), "Card.IsNotRemembered", source.getController(), source); for (final Card c : dPHand) { p.discard(c, sa); discarded.add(c); @@ -1395,7 +1395,7 @@ public class AbilityFactoryZoneAffecting { } else if (mode.equals("RevealYouChoose") || mode.equals("RevealOppChoose") || mode.equals("TgtChoose")) { // Is Reveal you choose right? I think the wrong player is // being used? - List dPHand = p.getCardsIn(ZoneType.Hand); + List dPHand = new ArrayList(p.getCardsIn(ZoneType.Hand)); if (dPHand.size() != 0) { if (params.containsKey("RevealNumber")) { String amountString = params.get("RevealNumber"); @@ -1717,7 +1717,7 @@ public class AbilityFactoryZoneAffecting { private static boolean discardTargetAI(final Player ai, final AbilityFactory af, final SpellAbility sa) { final Target tgt = sa.getTarget(); Player opp = ai.getOpponent(); - if (opp.getCardsIn(ZoneType.Hand).size() < 1) { + if (opp.getCardsIn(ZoneType.Hand).isEmpty()) { return false; } if (tgt != null) { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java index 5360a777cd1..ff56950d4a4 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java @@ -118,7 +118,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - List perms = getActivatingPlayer().getCardsIn(ZoneType.Battlefield); + List perms = new ArrayList(getActivatingPlayer().getCardsIn(ZoneType.Battlefield)); perms = CardLists.filter(CardLists.getTargetableCards(perms, this), new Predicate() { @Override public boolean apply(final Card c) { @@ -155,7 +155,8 @@ public class CardFactoryCreatures { @Override public void execute() { - final List artifacts = CardLists.filter(card.getController().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS); + final List artifacts = + CardLists.filter(card.getController().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS); if (card.getController().isHuman()) { @@ -419,7 +420,7 @@ public class CardFactoryCreatures { return false; } - List targetables = getActivatingPlayer().getOpponent().getCardsIn(ZoneType.Battlefield); + List targetables = new ArrayList(getActivatingPlayer().getOpponent().getCardsIn(ZoneType.Battlefield)); targetables = CardLists.filter(CardLists.getTargetableCards(targetables, this), new Predicate() { @Override @@ -587,15 +588,15 @@ public class CardFactoryCreatures { } // resolve() public int countKithkin() { - List kithkin = card.getController().getCardsIn(ZoneType.Battlefield); - kithkin = CardLists.filter(kithkin, new Predicate() { + final List kithkin = + CardLists.filter(card.getController().getCardsIn(ZoneType.Battlefield), new Predicate() { - @Override - public boolean apply(final Card c) { - return (c.isType("Kithkin")) && !c.equals(card); - } - - }); + @Override + public boolean apply(final Card c) { + return (c.isType("Kithkin")) && !c.equals(card); + } + + }); return kithkin.size(); } @@ -713,7 +714,7 @@ public class CardFactoryCreatures { } // Get rid of Planeswalkers: - list = ai.getOpponent().getCardsIn(ZoneType.Battlefield); + list = new ArrayList(ai.getOpponent().getCardsIn(ZoneType.Battlefield)); list = CardLists.filter(list, new Predicate() { @Override public boolean apply(final Card crd) { @@ -757,8 +758,8 @@ public class CardFactoryCreatures { int intermSumPower = 0; int intermSumToughness = 0; // intermSumPower = intermSumToughness = 0; - List creats = card.getController().getCardsIn(ZoneType.Graveyard); - creats = CardLists.filter(creats, new Predicate() { + List creats = + CardLists.filter(card.getController().getCardsIn(ZoneType.Graveyard), new Predicate() { @Override public boolean apply(final Card c) { return c.isCreature() && !c.equals(card); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java index 4ab0be3a196..f153a935aac 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java @@ -164,7 +164,7 @@ public class CardFactoryInstants { } public void computerResolve() { - final List list = card.getController().getCardsIn(ZoneType.Library); + final List list = new ArrayList(card.getController().getCardsIn(ZoneType.Library)); final List selectedCards = new ArrayList(); // pick best creature diff --git a/src/main/java/forge/card/cardfactory/CardFactoryLands.java b/src/main/java/forge/card/cardfactory/CardFactoryLands.java index 0c5a6b0e47f..900a2c73d3d 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryLands.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryLands.java @@ -279,8 +279,7 @@ class CardFactoryLands { } public void computerExecute() { - List hand = card.getController().getCardsIn(ZoneType.Hand); - hand = CardLists.getType(hand, type); + List hand = CardLists.getType(card.getController().getCardsIn(ZoneType.Hand), type); if (hand.size() > 0) { this.revealCard(hand.get(0)); } else { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index 1074531e5cb..2ac96cf3cb8 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -4732,8 +4732,8 @@ public class CardFactoryUtil { public void execute() { // Target as Modular is Destroyed if (card.getController().isComputer()) { - List choices = card.getController().getCardsIn(ZoneType.Battlefield); - choices = CardLists.filter(choices, new Predicate() { + List choices = + CardLists.filter(card.getController().getCardsIn(ZoneType.Battlefield), new Predicate() { @Override public boolean apply(final Card c) { return c.isCreature() && c.isArtifact(); diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index 439de279ef5..bc62c77dcf9 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -157,7 +157,7 @@ public class CostExile extends CostPartWithList { typeList.add(Singletons.getModel().getGame().getStack().peekAbility(i).getSourceCard()); } } else { - typeList = activator.getCardsIn(this.getFrom()); + typeList = new ArrayList(activator.getCardsIn(this.getFrom())); } if (!this.getThis()) { typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); diff --git a/src/main/java/forge/card/cost/CostPutCounter.java b/src/main/java/forge/card/cost/CostPutCounter.java index b10ab5b0c89..185fc367996 100644 --- a/src/main/java/forge/card/cost/CostPutCounter.java +++ b/src/main/java/forge/card/cost/CostPutCounter.java @@ -217,7 +217,8 @@ public class CostPutCounter extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - final List typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), ai, source); + final List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), ai, source); Card card = null; if (this.getType().equals("Creature.YouCtrl")) { diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index cb6caaa2be6..88d73cf88f7 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -289,7 +289,8 @@ public class CostRemoveCounter extends CostPartWithList { if (!this.getThis()) { this.getList().clear(); - final List typeList = CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source); + final List typeList = + CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source); for (Card card : typeList) { if (card.getCounters(this.getCounter()) >= c) { this.addToList(card); diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index ba4fa496fd4..3ed3972b6ac 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -64,7 +64,7 @@ public class CostReveal extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - List handList = activator.getCardsIn(ZoneType.Hand); + List handList = new ArrayList(activator.getCardsIn(ZoneType.Hand)); final String type = this.getType(); final Integer amount = this.convertAmount(); @@ -109,7 +109,7 @@ public class CostReveal extends CostPartWithList { this.getList().add(source); } else if (this.getType().equals("Hand")) { - this.setList(ai.getCardsIn(ZoneType.Hand)); + this.setList(new ArrayList(ai.getCardsIn(ZoneType.Hand))); return true; } else { hand = CardLists.getValidCards(hand, type.split(";"), ai, source); diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java index f3c43b28e0e..6d455ca6af9 100644 --- a/src/main/java/forge/card/cost/CostTapType.java +++ b/src/main/java/forge/card/cost/CostTapType.java @@ -191,8 +191,8 @@ public class CostTapType extends CostPartWithList { if (c == null) { final String sVar = ability.getSVar(amount); if (sVar.equals("XChoice")) { - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); + List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = CardLists.filter(typeList, Presets.UNTAPPED); c = typeList.size(); source.setSVar("ChosenX", "Number$" + Integer.toString(c)); diff --git a/src/main/java/forge/card/cost/CostUtil.java b/src/main/java/forge/card/cost/CostUtil.java index d184b8e9813..c1e8a9eff2a 100644 --- a/src/main/java/forge/card/cost/CostUtil.java +++ b/src/main/java/forge/card/cost/CostUtil.java @@ -83,8 +83,8 @@ public class CostUtil { continue; } - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, type.split(","), source.getController(), source); + final List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(ai, source, "SacCost", typeList) == null) { return false; } @@ -118,8 +118,7 @@ public class CostUtil { continue; } - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, type.split(","), source.getController(), source); + final List typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(ai, source, "SacCost", typeList) == null) { return false; } @@ -212,11 +211,10 @@ public class CostUtil { final CostDiscard disc = (CostDiscard) part; final String type = disc.getType(); - List typeList = ai.getCardsIn(ZoneType.Hand); + final List typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Hand), type.split(","), source.getController(), source); if (typeList.size() > ai.getMaxHandSize()) { continue; } - typeList = CardLists.getValidCards(typeList, type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(ai, source, "DiscardCost", typeList) == null) { return false; } diff --git a/src/main/java/forge/game/phase/Combat.java b/src/main/java/forge/game/phase/Combat.java index 2bcd838e739..d30cd208748 100644 --- a/src/main/java/forge/game/phase/Combat.java +++ b/src/main/java/forge/game/phase/Combat.java @@ -120,8 +120,8 @@ public class Combat { private void fillDefenderMaps(final Player defender) { this.defenders.add(defender); this.defenderMap.put(defender, new ArrayList()); - List planeswalkers = defender.getCardsIn(ZoneType.Battlefield); - planeswalkers = CardLists.filter(planeswalkers, CardPredicates.Presets.PLANEWALKERS); + List planeswalkers = + CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS); for (final Card pw : planeswalkers) { this.defenders.add(pw); this.defenderMap.put(pw, new ArrayList()); diff --git a/src/main/java/forge/game/phase/EndOfTurn.java b/src/main/java/forge/game/phase/EndOfTurn.java index ab7d1096877..f0e610932e3 100644 --- a/src/main/java/forge/game/phase/EndOfTurn.java +++ b/src/main/java/forge/game/phase/EndOfTurn.java @@ -229,7 +229,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable { private static void endOfTurnLighthouseChronologist() { final Player player = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn(); final Player opponent = player.getOpponent(); - List list = opponent.getCardsIn(ZoneType.Battlefield); + List list = new ArrayList(opponent.getCardsIn(ZoneType.Battlefield)); list = CardLists.filter(list, new Predicate() { @Override diff --git a/src/main/java/forge/game/phase/Untap.java b/src/main/java/forge/game/phase/Untap.java index 84ace75d6a3..374da0612da 100644 --- a/src/main/java/forge/game/phase/Untap.java +++ b/src/main/java/forge/game/phase/Untap.java @@ -111,7 +111,7 @@ public class Untap extends Phase implements java.io.Serializable { final Player player = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn(); final Predicate tappedCanUntap = Predicates.and(Presets.TAPPED, Presets.CANUNTAP); - List list = player.getCardsIn(ZoneType.Battlefield); + List list = new ArrayList(player.getCardsIn(ZoneType.Battlefield)); for (final Card c : list) { if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) { @@ -185,7 +185,7 @@ public class Untap extends Phase implements java.io.Serializable { } // opponent untapping during your untap phase - final List opp = player.getOpponent().getCardsIn(ZoneType.Battlefield); + final List opp = new ArrayList(player.getOpponent().getCardsIn(ZoneType.Battlefield)); for (final Card oppCard : opp) { if (oppCard.hasKeyword("CARDNAME untaps during each other player's untap step.")) { oppCard.untap(); @@ -235,7 +235,7 @@ public class Untap extends Phase implements java.io.Serializable { if (Singletons.getModel().getGame().isCardInPlay("Damping Field") || Singletons.getModel().getGame().isCardInPlay("Imi Statue")) { final Player turnOwner = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn(); if (turnOwner.isComputer()) { - List artList = turnOwner.getCardsIn(ZoneType.Battlefield); + List artList = new ArrayList(turnOwner.getCardsIn(ZoneType.Battlefield)); artList = CardLists.filter(artList, Presets.ARTIFACTS); artList = CardLists.filter(artList, tappedCanUntap); if (artList.size() > 0) { @@ -265,7 +265,7 @@ public class Untap extends Phase implements java.io.Serializable { } } // selectCard() }; // Input - List artList = turnOwner.getCardsIn(ZoneType.Battlefield); + List artList = new ArrayList(turnOwner.getCardsIn(ZoneType.Battlefield)); artList = CardLists.filter(artList, Presets.ARTIFACTS); artList = CardLists.filter(artList, tappedCanUntap); if (artList.size() > 0) { @@ -304,8 +304,7 @@ public class Untap extends Phase implements java.io.Serializable { } } // selectCard() }; // Input - List creatures = player.getCreaturesInPlay(); - creatures = CardLists.filter(creatures, tappedCanUntap); + final List creatures = CardLists.filter(player.getCreaturesInPlay(), tappedCanUntap); if (creatures.size() > 0) { Singletons.getModel().getMatch().getInput().setInput(target); } diff --git a/src/main/java/forge/game/player/ComputerUtil.java b/src/main/java/forge/game/player/ComputerUtil.java index 31fb78ae4fa..226d517a3ca 100644 --- a/src/main/java/forge/game/player/ComputerUtil.java +++ b/src/main/java/forge/game/player/ComputerUtil.java @@ -1460,8 +1460,8 @@ public class ComputerUtil { */ public static List chooseSacrificeType(final Player ai, final String type, final Card activate, final Card target, final int amount) { - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, type.split(";"), activate.getController(), activate); + List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate); if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { typeList = CardLists.getNotType(typeList, "Creature"); } @@ -1559,7 +1559,7 @@ public class ComputerUtil { if (hand.size() <= 0) { continue; } - List aiCards = ai.getCardsIn(ZoneType.Battlefield); + final List aiCards = ai.getCardsIn(ZoneType.Battlefield); final int numLandsInPlay = Iterables.size(Iterables.filter(aiCards, CardPredicates.Presets.LANDS)); final List landsInHand = CardLists.filter(hand, CardPredicates.Presets.LANDS); final int numLandsInHand = landsInHand.size(); @@ -1619,8 +1619,7 @@ public class ComputerUtil { typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate); } } else { - typeList = ai.getCardsIn(zone); - typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate); + typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(","), activate.getController(), activate); } if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { typeList.remove(target); // don't exile the card we're pumping @@ -1655,8 +1654,8 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static List chooseTapType(final Player ai, final String type, final Card activate, final boolean tap, final int amount) { - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate); + List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate); // is this needed? typeList = CardLists.filter(typeList, Presets.UNTAPPED); @@ -1695,8 +1694,8 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static List chooseUntapType(final Player ai, final String type, final Card activate, final boolean untap, final int amount) { - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate); + List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate); // is this needed? typeList = CardLists.filter(typeList, Presets.TAPPED); @@ -1735,14 +1734,10 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static List chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) { - List typeList = ai.getCardsIn(ZoneType.Battlefield); - typeList = CardLists.getValidCards(typeList, type.split(","), activate.getController(), activate); + final List typeList = + CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(","), activate.getController(), activate); if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { - // bounce - // the - // card - // we're - // pumping + // don't bounce the card we're pumping typeList.remove(target); } diff --git a/src/main/java/forge/game/player/ComputerUtilAttack.java b/src/main/java/forge/game/player/ComputerUtilAttack.java index 545981ee911..98595e1a7a4 100644 --- a/src/main/java/forge/game/player/ComputerUtilAttack.java +++ b/src/main/java/forge/game/player/ComputerUtilAttack.java @@ -831,15 +831,12 @@ public class ComputerUtilAttack { * @return a int. */ public final int countExaltedBonus(final Player player) { - List list = player.getCardsIn(ZoneType.Battlefield); - list = CardLists.filter(list, new Predicate() { - @Override - public boolean apply(final Card c) { - return c.hasKeyword("Exalted"); - } - }); + int bonus = 0; + for (Card c : player.getCardsIn(ZoneType.Battlefield)) { + bonus += c.getKeywordAmount("Exalted"); + } - return list.size(); + return bonus; } /** diff --git a/src/main/java/forge/game/player/Player.java b/src/main/java/forge/game/player/Player.java index 4f9b3d1f52d..b5821a4187c 100644 --- a/src/main/java/forge/game/player/Player.java +++ b/src/main/java/forge/game/player/Player.java @@ -1599,7 +1599,7 @@ public abstract class Player extends GameEntity implements Comparable { * @return the card list */ public final List discardHand(final SpellAbility sa) { - final List list = this.getCardsIn(ZoneType.Hand); + final List list = new ArrayList(this.getCardsIn(ZoneType.Hand)); this.discardRandom(list.size(), sa); return list; } @@ -1648,8 +1648,8 @@ public abstract class Player extends GameEntity implements Comparable { public final List discardRandom(final int num, final SpellAbility sa, final String valid) { final List discarded = new ArrayList(); for (int i = 0; i < num; i++) { - List list = this.getCardsIn(ZoneType.Hand); - list = CardLists.getValidCards(list, valid, sa.getSourceCard().getController(), sa.getSourceCard()); + final List list = + CardLists.getValidCards(this.getCardsIn(ZoneType.Hand), valid, sa.getSourceCard().getController(), sa.getSourceCard()); if (list.size() != 0) { final Card disc = CardUtil.getRandom(list); discarded.add(disc); diff --git a/src/main/java/forge/gui/match/ControlWinLose.java b/src/main/java/forge/gui/match/ControlWinLose.java index 4b942525bd7..fe30a65dc93 100644 --- a/src/main/java/forge/gui/match/ControlWinLose.java +++ b/src/main/java/forge/gui/match/ControlWinLose.java @@ -126,7 +126,7 @@ public class ControlWinLose { continue; // not a loser } - List compAntes = loser.getCardsIn(ZoneType.Ante); + List compAntes = new ArrayList(loser.getCardsIn(ZoneType.Ante)); Deck cDeck = match.getPlayersDeck(loser.getLobbyPlayer()); for (Card c : compAntes) {