mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
fix bugs in minimal set calculation.
added that column to itemmanager
This commit is contained in:
@@ -214,15 +214,15 @@ public final class CardDb implements ICardDatabase {
|
|||||||
List<PaperCard> cards = this.allCardsByName.get(cardName);
|
List<PaperCard> cards = this.allCardsByName.get(cardName);
|
||||||
|
|
||||||
int sz = cards.size();
|
int sz = cards.size();
|
||||||
if( fromSet == SetPreference.Earliest ) {
|
if( fromSet == SetPreference.Latest ) {
|
||||||
for(int i = 0 ; i < sz ; i++)
|
for(int i = 0 ; i < sz ; i++)
|
||||||
if( printedBefore == null || editions.get(cards.get(i).getEdition()).getDate().after(printedBefore) )
|
if( printedBefore == null || editions.get(cards.get(i).getEdition()).getDate().after(printedBefore) )
|
||||||
return cards.get(i);
|
return cards.get(i);
|
||||||
return null;
|
return null;
|
||||||
} else if( fromSet == SetPreference.Latest || fromSet == null || fromSet == SetPreference.Random ) {
|
} else if( fromSet == SetPreference.Earliest || fromSet == null || fromSet == SetPreference.Random ) {
|
||||||
for(int i = sz - 1 ; i >= 0 ; i--)
|
for(int i = sz - 1 ; i >= 0 ; i--)
|
||||||
if( printedBefore == null || editions.get(cards.get(i).getEdition()).getDate().after(printedBefore) ) {
|
if( printedBefore == null || editions.get(cards.get(i).getEdition()).getDate().after(printedBefore) ) {
|
||||||
if( fromSet == SetPreference.Latest )
|
if( fromSet == SetPreference.Earliest )
|
||||||
return cards.get(i);
|
return cards.get(i);
|
||||||
return cards.get(MyRandom.getRandom().nextInt(i+1));
|
return cards.get(MyRandom.getRandom().nextInt(i+1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,12 +420,15 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
minEditions.add(cp.getEdition());
|
minEditions.add(cp.getEdition());
|
||||||
}
|
}
|
||||||
|
|
||||||
CardEdition earliestOne = null;
|
|
||||||
for(CardEdition ed : getOrderedEditions()) {
|
for(CardEdition ed : getOrderedEditions()) {
|
||||||
if( minEditions.contains(ed.getCode()) )
|
if( minEditions.contains(ed.getCode()) && ( ed.getType() == Type.CORE || ed.getType() == Type.EXPANSION ) )
|
||||||
earliestOne = ed;
|
return ed;
|
||||||
}
|
}
|
||||||
return earliestOne;
|
for(CardEdition ed : getOrderedEditions()) {
|
||||||
|
if(minEditions.contains(ed.getCode()))
|
||||||
|
return ed;
|
||||||
|
}
|
||||||
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class Predicates {
|
public static class Predicates {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.google.common.base.Predicate;
|
|||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.StaticData;
|
import forge.StaticData;
|
||||||
|
import forge.card.CardEdition;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.deck.CardPool;
|
import forge.deck.CardPool;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -48,7 +49,7 @@ public class DeckProxy implements InventoryItem {
|
|||||||
private int sbSize = Integer.MIN_VALUE;
|
private int sbSize = Integer.MIN_VALUE;
|
||||||
private final String path;
|
private final String path;
|
||||||
private final Function<IHasName, Deck> fnGetDeck;
|
private final Function<IHasName, Deck> fnGetDeck;
|
||||||
private String edition;
|
private CardEdition edition;
|
||||||
|
|
||||||
public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) {
|
public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) {
|
||||||
this(deck, type, "", storage, null);
|
this(deck, type, "", storage, null);
|
||||||
@@ -85,12 +86,12 @@ public class DeckProxy implements InventoryItem {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEdition() {
|
public CardEdition getEdition() {
|
||||||
if ( null == edition ) {
|
if ( null == edition ) {
|
||||||
if ( deck instanceof PreconDeck )
|
if ( deck instanceof PreconDeck )
|
||||||
edition = ((PreconDeck) deck).getEdition();
|
edition = StaticData.instance().getEditions().get(((PreconDeck) deck).getEdition());
|
||||||
if ( !isGeneratedDeck() )
|
if ( !isGeneratedDeck() )
|
||||||
edition = StaticData.instance().getEditions().getEarliestEditionWithAllCards(getDeck().getAllCardsInASinglePool()).getCode();
|
edition = StaticData.instance().getEditions().getEarliestEditionWithAllCards(getDeck().getAllCardsInASinglePool());
|
||||||
}
|
}
|
||||||
return edition;
|
return edition;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
|
|||||||
ColumnDef.NAME,
|
ColumnDef.NAME,
|
||||||
ColumnDef.DECK_COLOR,
|
ColumnDef.DECK_COLOR,
|
||||||
ColumnDef.DECK_FORMAT,
|
ColumnDef.DECK_FORMAT,
|
||||||
|
ColumnDef.DECK_EDITION,
|
||||||
ColumnDef.DECK_MAIN,
|
ColumnDef.DECK_MAIN,
|
||||||
ColumnDef.DECK_SIDE);
|
ColumnDef.DECK_SIDE);
|
||||||
|
|
||||||
|
|||||||
@@ -337,6 +337,19 @@ public enum ColumnDef {
|
|||||||
return StringUtils.join(Iterables.transform(deck.getFormats(), GameFormat.FN_GET_NAME) , ", ");
|
return StringUtils.join(Iterables.transform(deck.getFormats(), GameFormat.FN_GET_NAME) , ", ");
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
DECK_EDITION("Min.Set", "Min.Set", 30, 30, 30, SortState.ASC, new ItemCellRenderer(),
|
||||||
|
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toDeck(from.getKey()).getEdition();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
|
||||||
|
return toDeck(from.getKey()).getEdition().getCode();
|
||||||
|
}
|
||||||
|
}),
|
||||||
DECK_MAIN("Main", "Main Deck", 30, 30, 30, SortState.ASC, new IntegerRenderer(),
|
DECK_MAIN("Main", "Main Deck", 30, 30, 30, SortState.ASC, new IntegerRenderer(),
|
||||||
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
|
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user