mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
FIXED bug for unique filter with missing break statement and reverse for correct iteration
This commit is contained in:
@@ -70,7 +70,7 @@ public class CardManager extends ItemManager<PaperCard> {
|
|||||||
ListMultimap<CardEdition, Entry<PaperCard, Integer>> entriesByEdition = Multimaps.newListMultimap(new HashMap<>(), CollectionSuppliers.arrayLists());
|
ListMultimap<CardEdition, Entry<PaperCard, Integer>> entriesByEdition = Multimaps.newListMultimap(new HashMap<>(), CollectionSuppliers.arrayLists());
|
||||||
for (Entry<PaperCard, Integer> entry : entries) {
|
for (Entry<PaperCard, Integer> entry : entries) {
|
||||||
CardEdition ed = StaticData.instance().getCardEdition(entry.getKey().getEdition());
|
CardEdition ed = StaticData.instance().getCardEdition(entry.getKey().getEdition());
|
||||||
if (ed != null && StaticData.instance().getCardArtPreference().accept(ed))
|
if (ed != null)
|
||||||
entriesByEdition.put(ed, entry);
|
entriesByEdition.put(ed, entry);
|
||||||
}
|
}
|
||||||
if (entriesByEdition.size() == 0)
|
if (entriesByEdition.size() == 0)
|
||||||
@@ -102,10 +102,9 @@ public class CardManager extends ItemManager<PaperCard> {
|
|||||||
List<CardEdition> acceptedEditions) {
|
List<CardEdition> acceptedEditions) {
|
||||||
// Use standard sort + index, for better performance!
|
// Use standard sort + index, for better performance!
|
||||||
Collections.sort(acceptedEditions);
|
Collections.sort(acceptedEditions);
|
||||||
int selectionIndex = 0;
|
|
||||||
if (StaticData.instance().cardArtPreferenceIsLatest())
|
if (StaticData.instance().cardArtPreferenceIsLatest())
|
||||||
selectionIndex = acceptedEditions.size()-1;
|
Collections.reverse(acceptedEditions);
|
||||||
CardEdition uniqueEdition = acceptedEditions.get(selectionIndex);
|
CardEdition uniqueEdition = acceptedEditions.get(0);
|
||||||
|
|
||||||
// These are now the entries to add to Cards Map
|
// These are now the entries to add to Cards Map
|
||||||
List<Entry<PaperCard, Integer>> uniqueEntries = entriesByEdition.get(uniqueEdition);
|
List<Entry<PaperCard, Integer>> uniqueEntries = entriesByEdition.get(uniqueEdition);
|
||||||
@@ -122,13 +121,7 @@ public class CardManager extends ItemManager<PaperCard> {
|
|||||||
|
|
||||||
if (entriesToAdd.size() < entriesToReturn) {
|
if (entriesToAdd.size() < entriesToReturn) {
|
||||||
// some are missing, keep exploring other editions
|
// some are missing, keep exploring other editions
|
||||||
int start = 1;
|
for (int editionIndex = 1; editionIndex < acceptedEditions.size(); editionIndex++) {
|
||||||
int end = acceptedEditions.size();
|
|
||||||
if (selectionIndex != 0) { // latest art case: the last was selected
|
|
||||||
start = 0;
|
|
||||||
end = acceptedEditions.size() - 1;
|
|
||||||
}
|
|
||||||
for (int editionIndex = start; editionIndex < end; editionIndex++) {
|
|
||||||
CardEdition edition = acceptedEditions.get(editionIndex);
|
CardEdition edition = acceptedEditions.get(editionIndex);
|
||||||
for (Entry<PaperCard, Integer> entry : entriesByEdition.get(edition)) {
|
for (Entry<PaperCard, Integer> entry : entriesByEdition.get(edition)) {
|
||||||
if (!entry.getKey().hasImage())
|
if (!entry.getKey().hasImage())
|
||||||
@@ -137,6 +130,8 @@ public class CardManager extends ItemManager<PaperCard> {
|
|||||||
if (entriesToAdd.size() == entriesToReturn)
|
if (entriesToAdd.size() == entriesToReturn)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (entriesToAdd.size() == entriesToReturn)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// if at this stage, there are still entries to add, fill missing ones from the original list
|
// if at this stage, there are still entries to add, fill missing ones from the original list
|
||||||
for (Entry<PaperCard, Integer> entry : uniqueEntries) {
|
for (Entry<PaperCard, Integer> entry : uniqueEntries) {
|
||||||
|
|||||||
Reference in New Issue
Block a user