Improve deck manager list view some more

This commit is contained in:
drdev
2014-04-26 23:57:54 +00:00
parent 39a204c5ba
commit 76f03c61b6
5 changed files with 95 additions and 16 deletions

View File

@@ -2,9 +2,11 @@ package forge.deck;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.StaticData;
import forge.card.CardEdition;
import forge.card.CardRarity;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.deck.CardPool;
@@ -54,6 +56,7 @@ public class DeckProxy implements InventoryItem {
private final String path;
private final Function<IHasName, Deck> fnGetDeck;
private CardEdition edition;
private CardRarity highestRarity;
protected DeckProxy() {
this(null, "", null, "", null, null);
@@ -128,6 +131,7 @@ public class DeckProxy implements InventoryItem {
public void invalidateCache() {
color = null;
colorIdentity = null;
highestRarity = null;
formats = null;
edition = null;
mainSize = Integer.MIN_VALUE;
@@ -176,6 +180,45 @@ public class DeckProxy implements InventoryItem {
return colorIdentity;
}
public CardRarity getHighestRarity() {
if (highestRarity == null) {
highestRarity = CardRarity.Common;
for (Entry<DeckSection, CardPool> deckEntry : getDeck()) {
switch (deckEntry.getKey()) {
case Main:
case Sideboard:
case Commander:
for (Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) {
switch (poolEntry.getKey().getRarity()) {
case MythicRare:
highestRarity = CardRarity.MythicRare;
return highestRarity; //can return right away since nothing is higher
case Special:
highestRarity = CardRarity.Special; //can always set this since only mythic should be treated higher
break;
case Rare:
if (highestRarity != CardRarity.Special) {
highestRarity = CardRarity.Rare; //can set to rare unless deck contains Special rarity
}
break;
case Uncommon:
if (highestRarity != CardRarity.Rare && highestRarity != CardRarity.Special) {
highestRarity = CardRarity.Uncommon; //can set to uncommon unless deck contains rare or uncommon
}
break;
default:
break; //treat other rarities as equivalent to common
}
}
break;
default:
break; //ignore other sections
}
}
}
return highestRarity;
}
public Iterable<GameFormat> getFormats() {
if (formats == null) {
formats = FModel.getFormats().getAllFormatsOfDeck(getDeck());
@@ -183,6 +226,10 @@ public class DeckProxy implements InventoryItem {
return formats;
}
public String getFormatsString() {
return StringUtils.join(Iterables.transform(getFormats(), GameFormat.FN_GET_NAME), ", ");
}
public int getMainSize() {
if (mainSize == Integer.MIN_VALUE) {
if (deck == null) {

View File

@@ -18,8 +18,6 @@
package forge.itemmanager;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import forge.card.*;
import forge.deck.DeckProxy;
import forge.deck.io.DeckPreferences;
@@ -33,8 +31,6 @@ import forge.itemmanager.ItemColumnConfig.SortState;
import forge.limited.DraftRankCache;
import forge.model.FModel;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.Map.Entry;
import java.util.regex.Pattern;
@@ -341,7 +337,7 @@ public enum ColumnDef {
if (deck == null) {
return null;
}
return StringUtils.join(Iterables.transform(deck.getFormats(), GameFormat.FN_GET_NAME) , ", ");
return deck.getFormatsString();
}
}),
DECK_EDITION("Set", "Set of oldest card in deck", 38, true, SortState.DESC,