mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- 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.
This commit is contained in:
@@ -21,6 +21,7 @@ import com.google.common.base.Predicate;
|
|||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import forge.StaticData;
|
||||||
|
|
||||||
import forge.card.*;
|
import forge.card.*;
|
||||||
import forge.card.mana.ManaCost;
|
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);
|
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");
|
return landPool.contains("Plains");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +197,12 @@ public abstract class DeckGeneratorBase {
|
|||||||
|
|
||||||
// attempt to optimize basic land counts according to colors of picked cards
|
// attempt to optimize basic land counts according to colors of picked cards
|
||||||
final Map<String, Integer> clrCnts = countLands(tDeck);
|
final Map<String, Integer> 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
|
// total of all ClrCnts
|
||||||
float totalColor = 0;
|
float totalColor = 0;
|
||||||
for (Entry<String, Integer> c : clrCnts.entrySet()) {
|
for (Entry<String, Integer> c : clrCnts.entrySet()) {
|
||||||
@@ -216,20 +223,17 @@ public abstract class DeckGeneratorBase {
|
|||||||
// just to prevent a null exception by the deck size fixing code
|
// just to prevent a null exception by the deck size fixing code
|
||||||
cardCounts.put(basicLandName, nLand);
|
cardCounts.put(basicLandName, nLand);
|
||||||
|
|
||||||
PaperCard cp;
|
|
||||||
if (!landPool.contains("Plains")) {//in case none of the cards came from a set with all basic lands
|
if (!landPool.contains("Plains")) {//in case none of the cards came from a set with all basic lands
|
||||||
setBasicLandPool("BFZ");
|
setBasicLandPool("ORI");
|
||||||
basicLandEdition="BFZ";
|
basicLandEdition="ORI";
|
||||||
}
|
|
||||||
if (edition != null) {
|
|
||||||
cp = landPool.getCard(basicLandName, edition);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cp = landPool.getCard(basicLandName, basicLandEdition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nLand; i++) {
|
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;
|
landsLeft -= nLand;
|
||||||
|
|||||||
Reference in New Issue
Block a user