refactored cardDb, added getEdition method to DeckProxy

This commit is contained in:
Maxmtg
2014-01-25 15:43:48 +00:00
parent 28f7f7baaf
commit 6d34dbc286
15 changed files with 170 additions and 225 deletions

View File

@@ -33,7 +33,6 @@ import forge.StaticData;
import forge.card.CardEdition;
import forge.deck.CardPool;
import forge.deck.Deck;
import forge.deck.DeckSection;
import forge.item.PaperCard;
import forge.item.IPaperCard;
import forge.util.FileSection;
@@ -186,18 +185,8 @@ public class GameFormat implements Comparable<GameFormat> {
return true;
}
private static CardPool getAllDecksCards(final Deck deck) {
CardPool allCards = new CardPool(); // will count cards in this pool to enforce restricted
allCards.addAll(deck.getMain());
if (deck.has(DeckSection.Sideboard))
allCards.addAll(deck.get(DeckSection.Sideboard));
if (deck.has(DeckSection.Commander))
allCards.addAll(deck.get(DeckSection.Commander));
return allCards;
}
public boolean isDeckLegal(final Deck deck) {
return isPoolLegal(getAllDecksCards(deck));
return isPoolLegal(deck.getAllCardsInASinglePool());
}
/*
@@ -304,7 +293,7 @@ public class GameFormat implements Comparable<GameFormat> {
public Iterable<GameFormat> getAllFormatsOfDeck(Deck deck) {
List<GameFormat> result = new ArrayList<GameFormat>();
CardPool allCards = GameFormat.getAllDecksCards(deck);
CardPool allCards = deck.getAllCardsInASinglePool();
for(GameFormat gf : naturallyOrdered) {
if (gf.isPoolLegal(allCards))
result.add(gf);

View File

@@ -49,6 +49,7 @@ import forge.card.CardRarity;
import forge.card.CardRules;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.card.CardDb.SetPreference;
import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostParser;
import forge.game.Game;
@@ -8694,18 +8695,16 @@ public class Card extends GameEntity implements Comparable<Card> {
return fromPaperCard(pc, null);
}
// Fetch from Forge's Card instance. Well, there should be no errors, but
// we'll still check
public PaperCard getPaperCard() {
final String name = getName();
final String set = getCurSetCode();
if (StringUtils.isNotBlank(set)) {
PaperCard cp = StaticData.instance().getVariantCards().tryGetCard(name, set);
PaperCard cp = StaticData.instance().getVariantCards().getCard(name, set);
return cp == null ? StaticData.instance().getCommonCards().getCard(name, set) : cp;
}
PaperCard cp = StaticData.instance().getVariantCards().tryGetCard(name, true);
return cp == null ? StaticData.instance().getCommonCards().getCard(name) : cp;
PaperCard cp = StaticData.instance().getVariantCards().getCard(name);
return cp == null ? StaticData.instance().getCommonCards().getCardFromEdition(name, SetPreference.Latest) : cp;
}
/**