From d26a31d581910e8ff8d6a955e17ad81b6cd23d33 Mon Sep 17 00:00:00 2001 From: Agetian Date: Tue, 23 May 2017 06:35:42 +0000 Subject: [PATCH] - Some improvements and fixes in DeckGeneratorBase. Enables the ability to generate colorless decks (e.g. in Planar Conquest mode on Random events) and add basic lands to them. --- .../deck/generation/DeckGeneratorBase.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 0cda57d832a..1710215278d 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -21,6 +21,7 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import forge.StaticData; import forge.card.*; import forge.card.mana.ManaCost; @@ -123,7 +124,7 @@ public abstract class DeckGeneratorBase { isSetBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard.FN_GET_RULES); } - landPool = new DeckGenPool(format.getCardPool(fullCardDB).getAllCards(isSetBasicLand)); + landPool = new DeckGenPool(StaticData.instance().getCommonCards().getAllCards(isSetBasicLand)); return landPool.contains("Plains"); } @@ -196,6 +197,12 @@ public abstract class DeckGeneratorBase { // attempt to optimize basic land counts according to colors of picked cards final Map clrCnts = countLands(tDeck); + + if (cnt > 0 && clrCnts.isEmpty()) { + // The deck is completely colorless. Add some Plains then to fill the deck. + clrCnts.put(MagicColor.Constant.BASIC_LANDS.get(0), cnt); + } + // total of all ClrCnts float totalColor = 0; for (Entry c : clrCnts.entrySet()) { @@ -216,20 +223,17 @@ public abstract class DeckGeneratorBase { // just to prevent a null exception by the deck size fixing code cardCounts.put(basicLandName, nLand); - PaperCard cp; if (!landPool.contains("Plains")) {//in case none of the cards came from a set with all basic lands - setBasicLandPool("BFZ"); - basicLandEdition="BFZ"; - } - if (edition != null) { - cp = landPool.getCard(basicLandName, edition); - } - else { - cp = landPool.getCard(basicLandName, basicLandEdition); + setBasicLandPool("ORI"); + basicLandEdition="ORI"; } for (int i = 0; i < nLand; i++) { - tDeck.add(landPool.getCard(basicLandName, basicLandEdition, -1), 1); + PaperCard cp = landPool.getCard(basicLandName, edition != null ? edition : basicLandEdition, -1); + if (cp == null) { + cp = fullCardDB.getCard(basicLandName, edition != null ? edition : basicLandEdition, -1); + } + tDeck.add(cp, 1); } landsLeft -= nLand;