diff --git a/forge-core/src/main/java/forge/deck/Deck.java b/forge-core/src/main/java/forge/deck/Deck.java index a2ce2f9a314..de3df860190 100644 --- a/forge-core/src/main/java/forge/deck/Deck.java +++ b/forge-core/src/main/java/forge/deck/Deck.java @@ -32,6 +32,8 @@ import org.apache.commons.lang3.StringUtils; import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.collect.Lists; + import forge.StaticData; import forge.card.CardDb; @@ -209,7 +211,7 @@ public class Deck extends DeckBase implements Iterable writeCardPool(final ItemPoolView pool) { - final List> main2sort = pool.getOrderedList(); + List> main2sort = Lists.newArrayList(pool); Collections.sort(main2sort, ItemPoolSorter.BY_NAME_THEN_SET); final List out = new ArrayList(); for (final Entry e : main2sort) { diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java index f49e2a48982..83c1153048b 100644 --- a/forge-core/src/main/java/forge/util/ItemPool.java +++ b/forge-core/src/main/java/forge/util/ItemPool.java @@ -33,8 +33,6 @@ import forge.item.InventoryItem; */ public class ItemPool extends ItemPoolView { - - // Constructors here /** * @@ -47,7 +45,6 @@ public class ItemPool extends ItemPoolView { super(cls); } - @SuppressWarnings("unchecked") public static ItemPool createFrom(final ItemPoolView from, final Class clsHint) { final ItemPool result = new ItemPool(clsHint); @@ -113,7 +110,6 @@ public class ItemPool extends ItemPoolView { return; } this.items.put(item, Integer.valueOf(this.count(item) + amount)); - this.isListInSync = false; } /** @@ -131,7 +127,6 @@ public class ItemPool extends ItemPoolView { this.add((T) cr); } } - this.isListInSync = false; } /** @@ -150,7 +145,6 @@ public class ItemPool extends ItemPoolView { this.add((T) e.getKey(), e.getValue()); } } - this.isListInSync = false; } /** @@ -183,7 +177,6 @@ public class ItemPool extends ItemPoolView { } else { this.items.put(item, count - amount); } - this.isListInSync = false; return true; } @@ -223,6 +216,5 @@ public class ItemPool extends ItemPoolView { */ public void clear() { this.items.clear(); - this.isListInSync = false; } } diff --git a/forge-core/src/main/java/forge/util/ItemPoolView.java b/forge-core/src/main/java/forge/util/ItemPoolView.java index c651e87c300..d5de0e3530e 100644 --- a/forge-core/src/main/java/forge/util/ItemPoolView.java +++ b/forge-core/src/main/java/forge/util/ItemPoolView.java @@ -84,14 +84,6 @@ public class ItemPoolView implements Iterable myClass; // class does not keep this in runtime by // itself - // same thing as above, it was copied to provide sorting (needed by table - // views in deck editors) - /** The items ordered. */ - private final transient List> itemsOrdered = new ArrayList>(); - - /** Whether list is in sync. */ - protected transient boolean isListInSync = false; - /** * iterator. * @@ -183,29 +175,6 @@ public class ItemPoolView implements Iterable> - */ - public final List> getOrderedList() { - if (!this.isListInSync) { - this.rebuildOrderedList(); - } - return this.itemsOrdered; - } - - private void rebuildOrderedList() { - this.itemsOrdered.clear(); - if (this.items != null) { - for (final Entry e : this.items.entrySet()) { - this.itemsOrdered.add(e); - } - } - this.isListInSync = true; - } - /** * * toFlatList. diff --git a/forge-gui/res/cardsfolder/b/back_from_the_brink.txt b/forge-gui/res/cardsfolder/b/back_from_the_brink.txt index 0ba7707ee9b..3f874e296c3 100644 --- a/forge-gui/res/cardsfolder/b/back_from_the_brink.txt +++ b/forge-gui/res/cardsfolder/b/back_from_the_brink.txt @@ -1,7 +1,7 @@ Name:Back from the Brink ManaCost:4 U U Types:Enchantment -A:AB$ CopyPermanent | Cost$ ExileAndPay | Defined$ Exiled | SorcerySpeed$ True | SpellDescription$ Put a token onto the battlefield that's a copy of that card. Activate this ability only any time you could cast a sorcery. +A:AB$ CopyPermanent | Cost$ ExileFromGrave<1/Creature> Mana | Defined$ Exiled | SorcerySpeed$ True | SpellDescription$ Put a token onto the battlefield that's a copy of that card. Activate this ability only any time you could cast a sorcery. SVar:NonStackingEffect:True SVar:Picture:http://www.wizards.com/global/images/magic/general/back_from_the_brink.jpg Oracle:Exile a creature card from your graveyard and pay its mana cost: Put a token onto the battlefield that's a copy of that card. Activate this ability only any time you could cast a sorcery. \ No newline at end of file diff --git a/forge-gui/src/main/java/forge/deck/io/DeckHtmlSerializer.java b/forge-gui/src/main/java/forge/deck/io/DeckHtmlSerializer.java index 9b304d62e8b..2624ac60b13 100644 --- a/forge-gui/src/main/java/forge/deck/io/DeckHtmlSerializer.java +++ b/forge-gui/src/main/java/forge/deck/io/DeckHtmlSerializer.java @@ -81,7 +81,7 @@ public class DeckHtmlSerializer { } final TreeMap map = new TreeMap(); - for (final Entry entry : d.getMain().getOrderedList()) { + for (final Entry entry : d.getMain()) { map.put(entry.getKey().getName(), entry.getValue()); // System.out.println(entry.getValue() + " " + // entry.getKey().getName()); diff --git a/forge-gui/src/main/java/forge/gui/toolbox/itemmanager/ItemManagerModel.java b/forge-gui/src/main/java/forge/gui/toolbox/itemmanager/ItemManagerModel.java index 29ac85663d6..90306dec2b5 100644 --- a/forge-gui/src/main/java/forge/gui/toolbox/itemmanager/ItemManagerModel.java +++ b/forge-gui/src/main/java/forge/gui/toolbox/itemmanager/ItemManagerModel.java @@ -17,7 +17,9 @@ */ package forge.gui.toolbox.itemmanager; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import forge.item.InventoryItem; @@ -63,10 +65,33 @@ public final class ItemManagerModel { * * @return List> */ + + + // same thing as above, it was copied to provide sorting (needed by table + // views in deck editors) + /** The items ordered. */ + private final transient List> itemsOrdered = new ArrayList>(); + + /** Whether list is in sync. */ + protected transient boolean isListInSync = false; + public final List> getOrderedList() { - return this.data.getOrderedList(); + if (!this.isListInSync) { + this.rebuildOrderedList(); + } + return this.itemsOrdered; } + private void rebuildOrderedList() { + this.itemsOrdered.clear(); + if (this.data != null) { + for (final Entry e : this.data) { + this.itemsOrdered.add(e); + } + } + this.isListInSync = true; + } + /** * * countDistinct. @@ -97,6 +122,7 @@ public final class ItemManagerModel { final boolean wasThere = this.data.count(item0) > 0; if (wasThere) { this.data.remove(item0, qty); + isListInSync = false; this.itemManager.getTable().getTableModel().fireTableDataChanged(); } } @@ -108,6 +134,7 @@ public final class ItemManagerModel { */ public void addItem(final T item0, int qty) { this.data.add(item0, qty); + isListInSync = false; this.itemManager.getTable().getTableModel().fireTableDataChanged(); } @@ -118,6 +145,7 @@ public final class ItemManagerModel { */ public void addItems(final Iterable> items0) { this.data.addAll(items0); + isListInSync = false; this.itemManager.getTable().getTableModel().fireTableDataChanged(); }