mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
*Variants:Keep separate lists of traditional/nontraditional CardPrinted's in CardDb.
*Variants:Fixed crash when only playing against 1 opponent on vanguard. *Variants:Fixed vanguard match not starting when selecting non-random avatar.
This commit is contained in:
@@ -122,7 +122,7 @@ public class BoosterGenerator {
|
||||
public BoosterGenerator(Predicate<CardPrinted> filter) {
|
||||
this();
|
||||
|
||||
for (final CardPrinted c : Iterables.filter(CardDb.instance().getTraditionalCards(), filter)) {
|
||||
for (final CardPrinted c : Iterables.filter(CardDb.instance().getAllTraditionalCards(), filter)) {
|
||||
this.addToRarity(c);
|
||||
// System.out.println(c);
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class MetaSet {
|
||||
// NOTE: The following code is far from ideal in a number of ways. If someone can
|
||||
// think of a way to improve it, please do so. --BBU
|
||||
// ItemPool<CardPrinted> cardPool = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||
for (CardPrinted aCard : CardDb.instance().getTraditionalCards()) {
|
||||
for (CardPrinted aCard : CardDb.instance().getAllTraditionalCards()) {
|
||||
if (data.indexOf(aCard.getEdition()) > -1) {
|
||||
cardPool.add(aCard);
|
||||
// System.out.println("Added card" + aCard.getName());
|
||||
@@ -293,7 +293,7 @@ public class MetaSet {
|
||||
if (mSet.type.equalsIgnoreCase("meta") || mSet.type.equalsIgnoreCase("booster")
|
||||
|| mSet.type.equalsIgnoreCase("pack")) {
|
||||
final String mData = new String(mSet.data);
|
||||
for (CardPrinted aCard : CardDb.instance().getTraditionalCards()) {
|
||||
for (CardPrinted aCard : CardDb.instance().getAllTraditionalCards()) {
|
||||
if (mData.indexOf(aCard.getEdition()) > -1) {
|
||||
if (!cardPool.contains(aCard)) {
|
||||
cardPool.add(aCard);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class CardCollections {
|
||||
private final IStorage<DeckGroup> draft;
|
||||
private final IStorage<DeckGroup> sealed;
|
||||
private final IStorage<Deck> cube;
|
||||
private final IStorage<Deck> scheme;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for Constructor.
|
||||
@@ -45,8 +46,9 @@ public class CardCollections {
|
||||
this.draft = new StorageImmediatelySerialized<DeckGroup>(new DeckGroupSerializer(new File(file, "draft")));
|
||||
this.sealed = new StorageImmediatelySerialized<DeckGroup>(new DeckGroupSerializer(new File(file, "sealed")));
|
||||
this.cube = new StorageImmediatelySerialized<Deck>(new DeckSerializer(new File(file, "cube")));
|
||||
this.scheme = new StorageImmediatelySerialized<Deck>(new DeckSerializer(new File(file, "scheme")));
|
||||
|
||||
System.out.printf("Read decks: %d constructed, %d sealed, %d draft, %d cubes.%n", constructed.getCount(), sealed.getCount(), draft.getCount(), cube.getCount());
|
||||
System.out.printf("Read decks: %d constructed, %d sealed, %d draft, %d cubes, %d scheme.%n", constructed.getCount(), sealed.getCount(), draft.getCount(), cube.getCount(), scheme.getCount());
|
||||
|
||||
// remove this after most people have been switched to new layout
|
||||
final OldDeckParser oldParser = new OldDeckParser(file, this.constructed, this.draft, this.sealed, this.cube);
|
||||
@@ -89,4 +91,12 @@ public class CardCollections {
|
||||
return this.sealed;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public IStorage<Deck> getScheme() {
|
||||
return this.scheme;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public abstract class GenerateColoredDeckBase {
|
||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS)) {
|
||||
hasColor = Predicates.or(hasColor, GenerateDeckUtil.COLORLESS_CARDS);
|
||||
}
|
||||
return Iterables.filter(CardDb.instance().getTraditionalCards(), Predicates.compose(Predicates.and(canPlay, hasColor), CardPrinted.FN_GET_RULES));
|
||||
return Iterables.filter(CardDb.instance().getAllTraditionalCards(), Predicates.compose(Predicates.and(canPlay, hasColor), CardPrinted.FN_GET_RULES));
|
||||
}
|
||||
|
||||
protected static Map<String, Integer> countLands(ItemPool<CardPrinted> outList) {
|
||||
|
||||
@@ -491,7 +491,7 @@ public final class GuiMigrateLocalMWSSetPicturesHQ extends DefaultBoundedRangeMo
|
||||
final String urlBase = "C:\\MTGForge\\HQPICS\\";
|
||||
String imgFN = "";
|
||||
|
||||
for (final CardPrinted cp : CardDb.instance().getAllCards())
|
||||
for (final CardPrinted cp : CardDb.instance().getAllTraditionalCards())
|
||||
{
|
||||
// String url = c.getSVar("Picture");
|
||||
// String[] URLs = url.split("\\\\");
|
||||
|
||||
@@ -121,7 +121,7 @@ public final class CEditorConstructed extends ACEditorBase<CardPrinted, Deck> {
|
||||
@Override
|
||||
public void resetTables() {
|
||||
// Constructed mode can use all cards, no limitations.
|
||||
this.getTableCatalog().setDeck(ItemPool.createFrom(CardDb.instance().getTraditionalCards(), CardPrinted.class));
|
||||
this.getTableCatalog().setDeck(ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), CardPrinted.class));
|
||||
this.getTableDeck().setDeck(this.controller.getModel().getMain());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
@@ -90,7 +92,9 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
||||
// read token names and urls
|
||||
final ArrayList<DownloadObject> cList = new ArrayList<DownloadObject>();
|
||||
|
||||
for (final CardPrinted c : CardDb.instance().getAllCards()) {
|
||||
Iterable<CardPrinted> allPrinted = Iterables.concat(CardDb.instance().getAllTraditionalCards(),CardDb.instance().getAllNonTraditionalCards());
|
||||
|
||||
for (final CardPrinted c : allPrinted) {
|
||||
final String setCode3 = c.getEdition();
|
||||
if (StringUtils.isBlank(setCode3) || "???".equals(setCode3)) {
|
||||
continue; // we don't want cards from unknown sets
|
||||
|
||||
@@ -151,6 +151,10 @@ public enum CSubmenuVanguard implements ICDoc {
|
||||
avatar = Iterables.get(view.getAllAiAvatars(),rnd.nextInt(Iterables.size(view.getAllAiAvatars())));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar = (CardPrinted)playerAvatars.get(i);
|
||||
}
|
||||
|
||||
helper.addVanguardPlayer(player, playerDecks.get(i), avatar);
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
||||
private final JCheckBox cbArtifacts = new FCheckBox("Remove Artifacts");
|
||||
private final JCheckBox cbRemoveSmall = new FCheckBox("Remove Small Creatures");
|
||||
|
||||
private final Predicate<CardPrinted> avatarTypePred = CardPrinted.Predicates.type("Vanguard");
|
||||
private final Iterable<CardPrinted> allAvatars = Iterables.filter(CardDb.instance().getAllCards(), avatarTypePred);
|
||||
private final Iterable<CardPrinted> allAvatars = Iterables.filter(CardDb.instance().getAllNonTraditionalCards(), CardPrinted.Predicates.type("Vanguard"));
|
||||
private final List<CardPrinted> allAiAvatars = new ArrayList<CardPrinted>();
|
||||
|
||||
//////////////////////////////
|
||||
@@ -333,7 +332,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
||||
|
||||
public int getNumPlayers()
|
||||
{
|
||||
return currentNumTabsShown-1;
|
||||
return currentNumTabsShown;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,9 @@ public final class CardDb {
|
||||
// need this to obtain cardReference by name+set+artindex
|
||||
private final Map<String, Map<String, CardPrinted[]>> allCardsBySet = new Hashtable<String, Map<String, CardPrinted[]>>();
|
||||
// this is the same list in flat storage
|
||||
private final List<CardPrinted> allCardsFlat = new ArrayList<CardPrinted>();
|
||||
private final List<CardPrinted> allTraditionalCardsFlat = new ArrayList<CardPrinted>();
|
||||
|
||||
private final List<CardPrinted> allNonTraditionalCardsFlat = new ArrayList<CardPrinted>();
|
||||
|
||||
// Lambda to get rules for selects from list of printed cards
|
||||
/** The Constant fnGetCardPrintedByForgeCard. */
|
||||
@@ -167,7 +169,11 @@ public final class CardDb {
|
||||
setMap.put(cardName, cardCopies);
|
||||
for (int i = 0; i < count; i++) {
|
||||
lastAdded = CardPrinted.build(card, set, s.getValue().getRarity(), i);
|
||||
this.allCardsFlat.add(lastAdded);
|
||||
if(lastAdded.isTraditional()) {
|
||||
this.allTraditionalCardsFlat.add(lastAdded);
|
||||
} else {
|
||||
this.allNonTraditionalCardsFlat.add(lastAdded);
|
||||
}
|
||||
cardCopies[i] = lastAdded;
|
||||
}
|
||||
|
||||
@@ -360,17 +366,12 @@ public final class CardDb {
|
||||
*
|
||||
* @return the all cards
|
||||
*/
|
||||
public Iterable<CardPrinted> getAllCards() {
|
||||
return this.allCardsFlat;
|
||||
public Iterable<CardPrinted> getAllTraditionalCards() {
|
||||
return this.allTraditionalCardsFlat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all "traditional" (non-scheme/vanguard/plane) cards
|
||||
*
|
||||
* @return the cards
|
||||
*/
|
||||
public Iterable<CardPrinted> getTraditionalCards() {
|
||||
return Iterables.filter(getAllCards(), CardPrinted.Predicates.Presets.TRADITIONAL);
|
||||
public Iterable<CardPrinted> getAllNonTraditionalCards() {
|
||||
return this.allNonTraditionalCardsFlat;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,7 +401,7 @@ public final class CardDb {
|
||||
} else {
|
||||
// OK, plain name here
|
||||
final Predicate<CardPrinted> predicate = CardPrinted.Predicates.name(nameWithSet.left);
|
||||
final Iterable<CardPrinted> namedCards = Iterables.filter(this.allCardsFlat, predicate);
|
||||
final Iterable<CardPrinted> namedCards = Iterables.filter(this.allTraditionalCardsFlat, predicate);
|
||||
// Find card with maximal set index
|
||||
result = Aggregates.itemWithMax(namedCards, CardPrinted.FN_GET_EDITION_INDEX);
|
||||
if (null == result) {
|
||||
|
||||
@@ -110,6 +110,10 @@ public final class CardPrinted implements Comparable<CardPrinted>, InventoryItem
|
||||
public boolean isFoil() {
|
||||
return this.foiled;
|
||||
}
|
||||
|
||||
public boolean isTraditional() {
|
||||
return !(getType().contains("Vanguard") || getType().contains("Scheme") || getType().contains("Plane"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card.
|
||||
|
||||
@@ -175,7 +175,7 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
Predicate<CardPrinted> cardsRule = Predicates.and(
|
||||
CardPrinted.Predicates.printedInSets(setCode),
|
||||
Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES));
|
||||
return Aggregates.random(Iterables.filter(CardDb.instance().getTraditionalCards(), cardsRule), count);
|
||||
return Aggregates.random(Iterables.filter(CardDb.instance().getAllTraditionalCards(), cardsRule), count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public final class BoosterUtils {
|
||||
}
|
||||
|
||||
// This will save CPU time when sets are limited
|
||||
final List<CardPrinted> cardpool = Lists.newArrayList(Iterables.filter(CardDb.instance().getTraditionalCards(), filter));
|
||||
final List<CardPrinted> cardpool = Lists.newArrayList(Iterables.filter(CardDb.instance().getAllTraditionalCards(), filter));
|
||||
|
||||
final Predicate<CardPrinted> pCommon = CardPrinted.Predicates.Presets.IS_COMMON;
|
||||
cards.addAll(BoosterUtils.generateDefinetlyColouredCards(cardpool, pCommon, numCommon, colorFilters));
|
||||
@@ -180,7 +180,7 @@ public final class BoosterUtils {
|
||||
* @return the list
|
||||
*/
|
||||
public static List<CardPrinted> generateDistinctCards(final Predicate<CardPrinted> filter, final int cntNeeded) {
|
||||
return BoosterUtils.generateDistinctCards(CardDb.instance().getTraditionalCards(), filter, cntNeeded);
|
||||
return BoosterUtils.generateDistinctCards(CardDb.instance().getAllTraditionalCards(), filter, cntNeeded);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -189,7 +189,7 @@ public final class QuestUtilCards {
|
||||
|
||||
final Predicate<CardPrinted> myFilter = applyFormatFilter(QuestUtilCards.RARE_PREDICATE);
|
||||
|
||||
final CardPrinted card = Aggregates.random(Iterables.filter(CardDb.instance().getTraditionalCards(), myFilter));
|
||||
final CardPrinted card = Aggregates.random(Iterables.filter(CardDb.instance().getAllTraditionalCards(), myFilter));
|
||||
this.addSingleCard(card);
|
||||
return card;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public final class QuestUtilCards {
|
||||
public List<CardPrinted> addRandomRare(final int n) {
|
||||
final Predicate<CardPrinted> myFilter = applyFormatFilter(QuestUtilCards.RARE_PREDICATE);
|
||||
|
||||
final List<CardPrinted> newCards = Aggregates.random(Iterables.filter(CardDb.instance().getTraditionalCards(), myFilter), n);
|
||||
final List<CardPrinted> newCards = Aggregates.random(Iterables.filter(CardDb.instance().getAllTraditionalCards(), myFilter), n);
|
||||
this.addAllCards(newCards);
|
||||
return newCards;
|
||||
}
|
||||
@@ -486,9 +486,9 @@ public final class QuestUtilCards {
|
||||
|
||||
Iterable<CardPrinted> cardList = null;
|
||||
if (qc.getFormat() == null) {
|
||||
cardList = CardDb.instance().getTraditionalCards(); }
|
||||
cardList = CardDb.instance().getAllTraditionalCards(); }
|
||||
else {
|
||||
cardList = Iterables.filter(CardDb.instance().getTraditionalCards(), qc.getFormat().getFilterPrinted());
|
||||
cardList = Iterables.filter(CardDb.instance().getAllTraditionalCards(), qc.getFormat().getFilterPrinted());
|
||||
}
|
||||
|
||||
final BoosterGenerator pack = new BoosterGenerator(cardList);
|
||||
|
||||
Reference in New Issue
Block a user