From b9e85280292481f79c7a3d62fc41806c8cd714bb Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Sun, 17 Jun 2018 07:30:41 +0100 Subject: [PATCH] Fixed bug where adding random cards to deck would mess up land count - also shuffling random cards before adding. This code is only executed for rare cases where the learnt archetypes have a very tight cardlist, so if cards are non-AI playable or get randomly removed from the pool, the generator has a way to validly fill the gap. --- .../src/main/java/forge/limited/CardThemedDeckBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java index 69beb21aa3c..7753ae3e709 100644 --- a/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java @@ -58,7 +58,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase { // Views for aiPlayable protected Iterable onColorCreaturesAndSpells; - protected static final boolean logToConsole = false; + protected static final boolean logToConsole = true; protected static final boolean logColorsToConsole = false; protected Iterable keyCards; @@ -314,11 +314,15 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase { } + //Extend to playsets for non land cards to fill out deck for when no other suitable cards are available protected void extendPlaysets(int numSpellsNeeded){ Map currentCounts = new HashMap<>(); List cardsToAdd = new ArrayList<>(); int i=0; for(PaperCard card: deckList){ + if(card.getRules().getType().isLand()){ + continue; + } if(currentCounts.containsKey(card)){ currentCounts.put(card, currentCounts.get(card) + 1); }else{ @@ -606,6 +610,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase { possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName())); } //Iterator iRandomPool = CardRanker.rankCardsInDeck(possibleList.subList(0, targetSize <= possibleList.size() ? targetSize : possibleList.size())).iterator(); + Collections.shuffle(possibleList); Iterator iRandomPool = possibleList.iterator(); while (deckList.size() < targetSize) { if (logToConsole) {