From ffd85cb1c898eccbe3a6124b4118a2864982c89d Mon Sep 17 00:00:00 2001 From: Sloth Date: Mon, 29 Oct 2012 07:15:21 +0000 Subject: [PATCH] - More getCards read-only list errors. --- src/main/java/forge/card/cost/CostDiscard.java | 5 +++-- src/main/java/forge/card/cost/CostExile.java | 4 ++-- src/main/java/forge/card/cost/CostMill.java | 3 ++- src/main/java/forge/card/cost/CostReturn.java | 5 +++-- src/main/java/forge/card/cost/CostReveal.java | 5 +++-- src/main/java/forge/card/cost/CostSacrifice.java | 7 ++++--- src/main/java/forge/card/cost/CostTapType.java | 5 +++-- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/forge/card/cost/CostDiscard.java b/src/main/java/forge/card/cost/CostDiscard.java index d44e0eb3077..68d934879be 100644 --- a/src/main/java/forge/card/cost/CostDiscard.java +++ b/src/main/java/forge/card/cost/CostDiscard.java @@ -17,6 +17,7 @@ */ package forge.card.cost; +import java.util.ArrayList; import java.util.List; import com.google.common.base.Predicate; @@ -114,7 +115,7 @@ public class CostDiscard 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)); String type = this.getType(); final Integer amount = this.convertAmount(); @@ -179,7 +180,7 @@ public class CostDiscard extends CostPartWithList { @Override public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) { final Player activator = ability.getActivatingPlayer(); - List handList = activator.getCardsIn(ZoneType.Hand); + List handList = new ArrayList(activator.getCardsIn(ZoneType.Hand)); String discType = this.getType(); final String amount = this.getAmount(); this.resetList(); diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index e3589ed48a5..439de279ef5 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -207,7 +207,7 @@ public class CostExile extends CostPartWithList { final String amount = this.getAmount(); Integer c = this.convertAmount(); final Player activator = ability.getActivatingPlayer(); - List list = activator.getCardsIn(this.getFrom()); + List list = new ArrayList(activator.getCardsIn(this.getFrom())); if (this.getType().equals("All")) { this.setList(list); for (final Card card : list) { @@ -258,7 +258,7 @@ public class CostExile extends CostPartWithList { if (this.getThis()) { this.getList().add(source); } else if (this.getType().equals("All")) { - this.setList(ability.getActivatingPlayer().getCardsIn(this.getFrom())); + this.setList(new ArrayList(ability.getActivatingPlayer().getCardsIn(this.getFrom()))); } else { Integer c = this.convertAmount(); if (c == null) { diff --git a/src/main/java/forge/card/cost/CostMill.java b/src/main/java/forge/card/cost/CostMill.java index 8dd3b4c5a8d..37106e8801e 100644 --- a/src/main/java/forge/card/cost/CostMill.java +++ b/src/main/java/forge/card/cost/CostMill.java @@ -17,6 +17,7 @@ */ package forge.card.cost; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -94,7 +95,7 @@ public class CostMill extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - this.setList(ai.getCardsIn(ZoneType.Library, c)); + this.setList(new ArrayList(ai.getCardsIn(ZoneType.Library, c))); if ((this.getList() == null) || (this.getList().size() < c)) { return false; diff --git a/src/main/java/forge/card/cost/CostReturn.java b/src/main/java/forge/card/cost/CostReturn.java index f1fd79e4900..b230d9d07da 100644 --- a/src/main/java/forge/card/cost/CostReturn.java +++ b/src/main/java/forge/card/cost/CostReturn.java @@ -17,6 +17,7 @@ */ package forge.card.cost; +import java.util.ArrayList; import java.util.List; import javax.swing.JOptionPane; @@ -108,7 +109,7 @@ public class CostReturn extends CostPartWithList { @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { if (!this.getThis()) { - List typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -233,7 +234,7 @@ public class CostReturn extends CostPartWithList { msg.append("s"); } - this.typeList = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); + this.typeList = new ArrayList(sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield)); this.typeList = CardLists.getValidCards(this.typeList, type.split(";"), sa.getActivatingPlayer(), sa.getSourceCard()); CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString()); ButtonUtil.enableOnlyCancel(); diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index 877f7971c5b..ba4fa496fd4 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -17,6 +17,7 @@ */ package forge.card.cost; +import java.util.ArrayList; import java.util.List; import forge.Card; @@ -98,7 +99,7 @@ public class CostReveal extends CostPartWithList { @Override public final boolean decideAIPayment(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) { final String type = this.getType(); - List hand = ai.getCardsIn(ZoneType.Hand); + List hand = new ArrayList(ai.getCardsIn(ZoneType.Hand)); this.resetList(); if (this.getThis()) { @@ -155,7 +156,7 @@ public class CostReveal extends CostPartWithList { this.addToList(source); payment.setPaidManaPart(this); } else if (this.getType().equals("Hand")) { - this.setList(activator.getCardsIn(ZoneType.Hand)); + this.setList(new ArrayList(activator.getCardsIn(ZoneType.Hand))); payment.setPaidManaPart(this); } else { Integer num = this.convertAmount(); diff --git a/src/main/java/forge/card/cost/CostSacrifice.java b/src/main/java/forge/card/cost/CostSacrifice.java index 280d2811a59..257513dbe4c 100644 --- a/src/main/java/forge/card/cost/CostSacrifice.java +++ b/src/main/java/forge/card/cost/CostSacrifice.java @@ -17,6 +17,7 @@ */ package forge.card.cost; +import java.util.ArrayList; import java.util.List; import javax.swing.JOptionPane; @@ -101,7 +102,7 @@ public class CostSacrifice extends CostPartWithList { public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { // You can always sac all if (!this.getThis()) { - List typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -156,7 +157,7 @@ public class CostSacrifice extends CostPartWithList { final String amount = this.getAmount(); final String type = this.getType(); final Player activator = ability.getActivatingPlayer(); - List list = activator.getCardsIn(ZoneType.Battlefield); + List list = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); list = CardLists.getValidCards(list, type.split(";"), activator, source); if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { list = CardLists.getNotType(list, "Creature"); @@ -206,7 +207,7 @@ public class CostSacrifice extends CostPartWithList { if (this.getThis()) { this.getList().add(source); } else if (this.getAmount().equals("All")) { - List typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { typeList = CardLists.getNotType(typeList, "Creature"); diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java index 149937dde06..f3c43b28e0e 100644 --- a/src/main/java/forge/card/cost/CostTapType.java +++ b/src/main/java/forge/card/cost/CostTapType.java @@ -17,6 +17,7 @@ */ package forge.card.cost; +import java.util.ArrayList; import java.util.List; import forge.Card; @@ -116,7 +117,7 @@ public class CostTapType extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - List typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); @@ -155,7 +156,7 @@ public class CostTapType extends CostPartWithList { */ @Override public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) { - List typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); + List typeList = new ArrayList(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield)); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = CardLists.filter(typeList, Presets.UNTAPPED); final String amount = this.getAmount();