mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
moved that infiniteStock field from ItemPool to more approriate place
This commit is contained in:
@@ -252,7 +252,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.computerChoose();
|
this.computerChoose();
|
||||||
return ItemPool.createFrom(this.pack.get(this.getCurrentBoosterIndex()), CardPrinted.class, false);
|
return ItemPool.createFrom(this.pack.get(this.getCurrentBoosterIndex()), CardPrinted.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class CustomLimited extends DeckBase {
|
|||||||
final String deckName = data.get("DeckFile");
|
final String deckName = data.get("DeckFile");
|
||||||
final Deck deckCube = cubes.get(deckName);
|
final Deck deckCube = cubes.get(deckName);
|
||||||
cd.cardPool = deckCube == null ? ItemPool.createFrom(
|
cd.cardPool = deckCube == null ? ItemPool.createFrom(
|
||||||
CardDb.instance().getAllUniqueCards(), CardPrinted.class, false)
|
CardDb.instance().getAllUniqueCards(), CardPrinted.class)
|
||||||
: deckCube.getMain();
|
: deckCube.getMain();
|
||||||
|
|
||||||
return cd;
|
return cd;
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public final class CEditorConstructed extends ACEditorBase<CardPrinted, Deck> {
|
|||||||
@Override
|
@Override
|
||||||
public void resetTables() {
|
public void resetTables() {
|
||||||
// Constructed mode can use all cards, no limitations.
|
// Constructed mode can use all cards, no limitations.
|
||||||
this.getTableCatalog().setDeck(ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), CardPrinted.class, true));
|
this.getTableCatalog().setDeck(ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), CardPrinted.class), true);
|
||||||
this.getTableDeck().setDeck(this.controller.getModel().getMain());
|
this.getTableDeck().setDeck(this.controller.getModel().getMain());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public final class CEditorConstructed extends ACEditorBase<CardPrinted, Deck> {
|
|||||||
} else {
|
} else {
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
this.getTableCatalog().setAvailableColumns(lstCatalogCols);
|
this.getTableCatalog().setAvailableColumns(lstCatalogCols);
|
||||||
this.getTableCatalog().setDeck(ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), CardPrinted.class, true));
|
this.getTableCatalog().setDeck(ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), CardPrinted.class), true);
|
||||||
this.getTableDeck().setDeck(this.controller.getModel().getMain());
|
this.getTableDeck().setDeck(this.controller.getModel().getMain());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
|||||||
|
|
||||||
private ItemPoolView<InventoryItem> cardsForSale;
|
private ItemPoolView<InventoryItem> cardsForSale;
|
||||||
private final ItemPool<InventoryItem> fullCatalogCards =
|
private final ItemPool<InventoryItem> fullCatalogCards =
|
||||||
ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), InventoryItem.class, true);
|
ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), InventoryItem.class);
|
||||||
private boolean showingFullCatalog = false;
|
private boolean showingFullCatalog = false;
|
||||||
|
|
||||||
// get pricelist:
|
// get pricelist:
|
||||||
@@ -137,7 +137,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
|||||||
showingFullCatalog = !showingFullCatalog;
|
showingFullCatalog = !showingFullCatalog;
|
||||||
|
|
||||||
if (showingFullCatalog) {
|
if (showingFullCatalog) {
|
||||||
this.getTableCatalog().setDeck(fullCatalogCards);
|
this.getTableCatalog().setDeck(fullCatalogCards, true);
|
||||||
VCardCatalog.SINGLETON_INSTANCE.getBtnAdd().setEnabled(false);
|
VCardCatalog.SINGLETON_INSTANCE.getBtnAdd().setEnabled(false);
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove().setEnabled(false);
|
VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove().setEnabled(false);
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove4().setEnabled(false);
|
VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove4().setEnabled(false);
|
||||||
@@ -342,7 +342,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
|||||||
final PreconDeck deck = (PreconDeck) item;
|
final PreconDeck deck = (PreconDeck) item;
|
||||||
this.questData.getCards().buyPreconDeck(deck, value);
|
this.questData.getCards().buyPreconDeck(deck, value);
|
||||||
final ItemPool<InventoryItem> newInventory =
|
final ItemPool<InventoryItem> newInventory =
|
||||||
ItemPool.createFrom(deck.getDeck().getMain(), InventoryItem.class, false);
|
ItemPool.createFrom(deck.getDeck().getMain(), InventoryItem.class);
|
||||||
getTableDeck().addCards(newInventory);
|
getTableDeck().addCards(newInventory);
|
||||||
JOptionPane.showMessageDialog(null, String.format(
|
JOptionPane.showMessageDialog(null, String.format(
|
||||||
"Deck '%s' was added to your decklist.%n%nCards from it were also added to your pool.",
|
"Deck '%s' was added to your decklist.%n%nCards from it were also added to your pool.",
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public final class CEditorVariant extends ACEditorBase<CardPrinted, Deck> {
|
|||||||
Iterable<CardPrinted> allNT = CardDb.instance().getAllNonTraditionalCards();
|
Iterable<CardPrinted> allNT = CardDb.instance().getAllNonTraditionalCards();
|
||||||
allNT = Iterables.filter(allNT, cardPoolCondition);
|
allNT = Iterables.filter(allNT, cardPoolCondition);
|
||||||
|
|
||||||
this.getTableCatalog().setDeck(ItemPool.createFrom(allNT, CardPrinted.class, true));
|
this.getTableCatalog().setDeck(ItemPool.createFrom(allNT, CardPrinted.class), true);
|
||||||
this.getTableDeck().setDeck(this.controller.getModel().getSideboard());
|
this.getTableDeck().setDeck(this.controller.getModel().getSideboard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ public enum CProbabilities implements ICDoc {
|
|||||||
final ACEditorBase<T, TModel> ed = (ACEditorBase<T, TModel>)
|
final ACEditorBase<T, TModel> ed = (ACEditorBase<T, TModel>)
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
|
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
|
||||||
|
|
||||||
final ItemPoolView<CardPrinted> deck = ItemPool.createFrom(
|
final ItemPoolView<CardPrinted> deck = ItemPool.createFrom(ed.getTableDeck().getCards(), CardPrinted.class);
|
||||||
ed.getTableDeck().getCards(), CardPrinted.class, false);
|
|
||||||
|
|
||||||
final List<String> cardProbabilities = new ArrayList<String>();
|
final List<String> cardProbabilities = new ArrayList<String>();
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ public enum CStatistics implements ICDoc {
|
|||||||
|
|
||||||
if (ed == null) { return; }
|
if (ed == null) { return; }
|
||||||
|
|
||||||
final ItemPoolView<CardPrinted> deck = ItemPool.createFrom(
|
final ItemPoolView<CardPrinted> deck = ItemPool.createFrom(ed.getTableDeck().getCards(), CardPrinted.class);
|
||||||
ed.getTableDeck().getCards(), CardPrinted.class, false);
|
|
||||||
|
|
||||||
int total = deck.countAll();
|
int total = deck.countAll();
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public final class EditorTableView<T extends InventoryItem> {
|
|||||||
private boolean alwaysNonUnique = false;
|
private boolean alwaysNonUnique = false;
|
||||||
|
|
||||||
private final Class<T> genericType;
|
private final Class<T> genericType;
|
||||||
|
private boolean infiniteSupply;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -278,7 +279,8 @@ public final class EditorTableView<T extends InventoryItem> {
|
|||||||
* an Iterable<InventoryITem>
|
* an Iterable<InventoryITem>
|
||||||
*/
|
*/
|
||||||
public void setDeck(final Iterable<InventoryItem> cards) {
|
public void setDeck(final Iterable<InventoryItem> cards) {
|
||||||
this.setDeckImpl(ItemPool.createFrom(cards, this.genericType, false));
|
this.setDeckImpl(ItemPool.createFrom(cards, this.genericType));
|
||||||
|
this.infiniteSupply = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,10 +289,13 @@ public final class EditorTableView<T extends InventoryItem> {
|
|||||||
* @param poolView
|
* @param poolView
|
||||||
* an ItemPoolView
|
* an ItemPoolView
|
||||||
*/
|
*/
|
||||||
public void setDeck(final ItemPoolView<T> poolView) {
|
public void setDeck(final ItemPoolView<T> poolView, boolean infinite) {
|
||||||
this.setDeckImpl(ItemPool.createFrom(poolView, this.genericType, false));
|
this.setDeckImpl(ItemPool.createFrom(poolView, this.genericType));
|
||||||
|
this.infiniteSupply = infinite;
|
||||||
|
}
|
||||||
|
public void setDeck(final ItemPoolView<T> poolView) {
|
||||||
|
this.setDeck(poolView, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the deck.
|
* Sets the deck.
|
||||||
*
|
*
|
||||||
@@ -299,6 +304,7 @@ public final class EditorTableView<T extends InventoryItem> {
|
|||||||
*/
|
*/
|
||||||
public void setDeck(final ItemPool<T> pool) {
|
public void setDeck(final ItemPool<T> pool) {
|
||||||
this.setDeckImpl(pool);
|
this.setDeckImpl(pool);
|
||||||
|
this.infiniteSupply = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -426,7 +432,7 @@ public final class EditorTableView<T extends InventoryItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getCardCount(final T card) {
|
public int getCardCount(final T card) {
|
||||||
return this.pool.count(card);
|
return infiniteSupply ? Integer.MAX_VALUE : this.pool.count(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate<T> getFilter() {
|
public Predicate<T> getFilter() {
|
||||||
|
|||||||
@@ -43,27 +43,10 @@ public class ItemPool<T extends InventoryItem> extends ItemPoolView<T> {
|
|||||||
super(cls);
|
super(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemPool(final Class<T> cls, boolean infiniteStock) {
|
|
||||||
super(cls, infiniteStock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createFrom method.
|
|
||||||
*
|
|
||||||
* @param <Tin>
|
|
||||||
* an InventoryItem
|
|
||||||
* @param <Tout>
|
|
||||||
* an InventoryItem
|
|
||||||
* @param from
|
|
||||||
* a Tin
|
|
||||||
* @param clsHint
|
|
||||||
* a Tout
|
|
||||||
* @return InventoryItem
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(
|
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final ItemPoolView<Tin> from, final Class<Tout> clsHint) {
|
||||||
final ItemPoolView<Tin> from, final Class<Tout> clsHint, boolean infiniteStock) {
|
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint);
|
||||||
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint, infiniteStock);
|
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
for (final Entry<Tin, Integer> e : from) {
|
for (final Entry<Tin, Integer> e : from) {
|
||||||
final Tin srcKey = e.getKey();
|
final Tin srcKey = e.getKey();
|
||||||
@@ -75,23 +58,10 @@ public class ItemPool<T extends InventoryItem> extends ItemPoolView<T> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* createFrom method.
|
|
||||||
*
|
|
||||||
* @param <Tin>
|
|
||||||
* an InventoryItem
|
|
||||||
* @param <Tout>
|
|
||||||
* an InventoryItem
|
|
||||||
* @param from
|
|
||||||
* a Iterable<Tin>
|
|
||||||
* @param clsHint
|
|
||||||
* a Class<Tout>
|
|
||||||
* @return <Tin> an InventoryItem
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(
|
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final Iterable<Tin> from, final Class<Tout> clsHint) {
|
||||||
final Iterable<Tin> from, final Class<Tout> clsHint, boolean infiniteStock) {
|
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint);
|
||||||
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint, infiniteStock);
|
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
for (final Tin srcKey : from) {
|
for (final Tin srcKey : from) {
|
||||||
if (clsHint.isInstance(srcKey)) {
|
if (clsHint.isInstance(srcKey)) {
|
||||||
@@ -138,7 +108,7 @@ public class ItemPool<T extends InventoryItem> extends ItemPoolView<T> {
|
|||||||
if (amount <= 0) {
|
if (amount <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.getCards().put(card, this.count(card) + amount);
|
this.getCards().put(card, Integer.valueOf(this.count(card) + amount));
|
||||||
this.setListInSync(false);
|
this.setListInSync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,27 +77,15 @@ public class ItemPoolView<T extends InventoryItem> implements Iterable<Entry<T,
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
public ItemPoolView(final Class<T> cls) {
|
public ItemPoolView(final Class<T> cls) {
|
||||||
this(cls, false);
|
this(new Hashtable<T, Integer>(), cls);
|
||||||
}
|
|
||||||
|
|
||||||
public ItemPoolView(final Class<T> cls, boolean infiniteStock) {
|
|
||||||
this(new Hashtable<T, Integer>(), cls, infiniteStock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemPoolView(final Map<T, Integer> inMap, final Class<T> cls) {
|
public ItemPoolView(final Map<T, Integer> inMap, final Class<T> cls) {
|
||||||
this(inMap, cls, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemPoolView(final Map<T, Integer> inMap, final Class<T> cls, boolean infiniteStock) {
|
|
||||||
this.cards = inMap;
|
this.cards = inMap;
|
||||||
this.myClass = cls;
|
this.myClass = cls;
|
||||||
this.infiniteStock = infiniteStock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
// if this is true, queries for card count will return INT_MAX
|
|
||||||
private final boolean infiniteStock;
|
|
||||||
|
|
||||||
/** The cards. */
|
/** The cards. */
|
||||||
private final Map<T, Integer> cards;
|
private final Map<T, Integer> cards;
|
||||||
|
|
||||||
@@ -152,7 +140,7 @@ public class ItemPoolView<T extends InventoryItem> implements Iterable<Entry<T,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
final Integer boxed = this.getCards().get(card);
|
final Integer boxed = this.getCards().get(card);
|
||||||
return boxed == null ? 0 : (infiniteStock ? Integer.MAX_VALUE : boxed.intValue());
|
return boxed == null ? 0 : boxed.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class BoosterDraftTest implements IBoosterDraft {
|
|||||||
this.n--;
|
this.n--;
|
||||||
BoosterData booster = Singletons.getModel().getBoosters().get("M11");
|
BoosterData booster = Singletons.getModel().getBoosters().get("M11");
|
||||||
final BoosterGenerator pack = new BoosterGenerator(booster.getEditionFilter());
|
final BoosterGenerator pack = new BoosterGenerator(booster.getEditionFilter());
|
||||||
return ItemPool.createFrom(pack.getBoosterPack(booster), CardPrinted.class, false);
|
return ItemPool.createFrom(pack.getBoosterPack(booster), CardPrinted.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|||||||
Reference in New Issue
Block a user