add getUniqueCardsNoAlt for mobile

This commit is contained in:
Anthony Calosa
2021-03-29 13:35:20 +08:00
parent 3d1e130b1e
commit d554a7ee97
2 changed files with 12 additions and 3 deletions

View File

@@ -56,10 +56,11 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
public final static String foilSuffix = "+";
public final static char NameSetSeparator = '|';
// need this to obtain cardReference by name+set+artindex
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
// for deck editor only
private final ListMultimap<String, PaperCard> allCardsByNameNoAlt = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
private final Map<String, PaperCard> uniqueCardsByNameNoAlt = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
// need this to obtain cardReference by name+set+artindex
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
private final Map<String, PaperCard> uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
private final Map<String, CardRules> rulesByName;
private final Map<String, ICardFace> facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
@@ -275,9 +276,13 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
private void reIndex() {
uniqueCardsByName.clear();
uniqueCardsByNameNoAlt.clear();
for (Entry<String, Collection<PaperCard>> kv : allCardsByName.asMap().entrySet()) {
uniqueCardsByName.put(kv.getKey(), getFirstWithImage(kv.getValue()));
}
for (Entry<String, Collection<PaperCard>> kv : allCardsByNameNoAlt.asMap().entrySet()) {
uniqueCardsByNameNoAlt.put(kv.getKey(), getFirstWithImage(kv.getValue()));
}
}
private static PaperCard getFirstWithImage(final Collection<PaperCard> cards) {
@@ -565,6 +570,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
return uniqueCardsByName.values();
}
public Collection<PaperCard> getUniqueCardsNoAlt() {
return uniqueCardsByNameNoAlt.values();
}
public PaperCard getUniqueByName(final String name) {
return uniqueCardsByName.get(getName(name));
}

View File

@@ -1156,7 +1156,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
// fall through to below
default:
if (cardManager.getWantUnique()) {
cardManager.setPool(editorType.applyCardFilter(ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class), additionalFilter), true);
cardManager.setPool(editorType.applyCardFilter(ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(), PaperCard.class), additionalFilter), true);
}
else {
cardManager.setPool(editorType.applyCardFilter(ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCardsNoAlt(), PaperCard.class), additionalFilter), true);