Fix duplicating cards in quest mode

This commit is contained in:
tool4EvEr
2022-05-01 17:03:21 +02:00
parent 8f883168fa
commit b41d76749c

View File

@@ -91,8 +91,10 @@ public class DeckController<T extends DeckBase> {
} }
public void loadDeck(Deck deck, boolean substituteCurrentDeck) { public void loadDeck(Deck deck, boolean substituteCurrentDeck) {
boolean isStored; boolean isStored;
if (view.getCatalogManager().isInfinite()) { boolean isInfinite = view.getCatalogManager().isInfinite();
Deck currentDeck = view.getHumanDeck(); Deck currentDeck = view.getHumanDeck();
if (isInfinite) {
if (substituteCurrentDeck || currentDeck.isEmpty()) { if (substituteCurrentDeck || currentDeck.isEmpty()) {
newModel(); newModel();
isStored = false; isStored = false;
@@ -107,10 +109,12 @@ public class DeckController<T extends DeckBase> {
isStored = false; isStored = false;
} }
Deck currentDeck = view.getHumanDeck();
for (DeckSection section: EnumSet.allOf(DeckSection.class)) { for (DeckSection section: EnumSet.allOf(DeckSection.class)) {
if (view.isSectionImportable(section)) { if (view.isSectionImportable(section)) {
CardPool sectionCards = currentDeck.getOrCreate(section); CardPool sectionCards = currentDeck.getOrCreate(section);
if (!isInfinite) {
sectionCards.clear();
}
sectionCards.addAll(deck.getOrCreate(section)); sectionCards.addAll(deck.getOrCreate(section));
} }
} }