Improved handling of color selection for deckbuilding and land selection in card-based random decks - including fixing a few bugs with dual land detection regexs

This commit is contained in:
austinio7116
2017-05-11 23:58:47 +00:00
parent a4d15b6b86
commit 4aa9408000
5 changed files with 41 additions and 12 deletions

1
.gitattributes vendored
View File

@@ -20939,6 +20939,7 @@ forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java -text
forge-gui/src/main/java/forge/limited/CustomLimited.java svneol=native#text/plain
forge-gui/src/main/java/forge/limited/DeckColors.java svneol=native#text/plain
forge-gui/src/main/java/forge/limited/DraftRankCache.java -text
forge-gui/src/main/java/forge/limited/FullDeckColors.java -text
forge-gui/src/main/java/forge/limited/GauntletMini.java -text
forge-gui/src/main/java/forge/limited/IBoosterDraft.java svneol=native#text/plain
forge-gui/src/main/java/forge/limited/LimitedDeckBuilder.java -text

View File

@@ -393,7 +393,7 @@ public abstract class DeckGeneratorBase {
*/
protected List<String> getDualLandList() {
System.out.println("Dual Land Colors: " + colors.toEnumSet().toString());
if (colors.countColors() > 3) {
addCardNameToList("Rupture Spire", dLands);
addCardNameToList("Undiscovered Paradise", dLands);
@@ -445,7 +445,7 @@ public abstract class DeckGeneratorBase {
}
public List<String> regexFetchLandSearch(Iterable<PaperCard> landCards){
final String fetchPattern="Search your library for a ([^\\s]*) or ([^\\s]*) card";
final String fetchPattern="Search your library for an* ([^\\s]*) or ([^\\s]*) card";
//final List<String> dLands = new ArrayList<String>();
Map<String,String> colorLookup= new HashMap<>();
colorLookup.put("Plains","W");

View File

@@ -60,6 +60,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
protected Iterable<PaperCard> keyCards;
protected static final boolean logToConsole = false;
protected static final boolean logColorsToConsole = false;
/**
@@ -84,11 +85,18 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
deckColors.addColorsOf(c);
}
}
this.colors = deckColors.getChosenColors();
colors = deckColors.getChosenColors();
if (logColorsToConsole) {
System.out.println(keyCard.getName());
System.out.println("Pre Colors: " + colors.toEnumSet().toString());
}
if(!colors.hasAllColors(keyCard.getRules().getColorIdentity().getColor())){
colors = ColorSet.fromMask(colors.getColor() | keyCard.getRules().getColorIdentity().getColor());
}
if (logColorsToConsole) {
System.out.println(keyCard.getName());
System.out.println("Pre Colors: " + colors.toEnumSet().toString());
}
findBasicLandSets();
}
@@ -110,7 +118,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
public Deck buildDeck() {
// 1. Prepare
hasColor = Predicates.or(new MatchColorIdentity(colors), COLORLESS_CARDS);
if (logToConsole) {
if (logColorsToConsole) {
System.out.println(keyCard.getName());
System.out.println("Colors: " + colors.toEnumSet().toString());
}
@@ -174,7 +182,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
// 7. If not enough cards yet, try to add a third color,
// to try and avoid adding purely random cards.
addThirdColorCards(numSpellsNeeded - deckList.size());
if (logToConsole) {
if (logColorsToConsole) {
System.out.println("Post 3rd colour : " + deckList.size());
System.out.println("Colors: " + colors.toEnumSet().toString());
}
@@ -188,7 +196,17 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
if (logToConsole) {
System.out.println("Post Randoms : " + deckList.size());
}
//TODO: update colors
FullDeckColors finalDeckColors = new FullDeckColors();
for(PaperCard c:deckList){
if(finalDeckColors.canChoseMoreColors()){
finalDeckColors.addColorsOf(c);
}
}
colors = finalDeckColors.getChosenColors();
if (logColorsToConsole) {
System.out.println("Final Colors: " + colors.toEnumSet().toString());
}
// 10. Add non-basic lands that were drafted.
addWastesIfRequired();
List<String> duals = getDualLandList();
@@ -833,11 +851,11 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
}
/**
* @param colors
* @param colors0
* the colors to set
*/
public void setColors(final ColorSet colors) {
this.colors = colors;
public void setColors(final ColorSet colors0) {
colors = colors0;
}
/**

View File

@@ -28,7 +28,7 @@ public class DeckColors {
private ColorSet chosen;
private int colorMask;
public final static int MAX_COLORS = 2;
public int MAX_COLORS = 2;
public ColorSet getChosenColors() {
if (null == chosen) {
@@ -47,7 +47,7 @@ public class DeckColors {
return;
}
for (final byte color : MagicColor.WUBRGC) {
for (final byte color : MagicColor.WUBRG) {
if (toAdd.hasAnyColor(color)) {
colorMask |= color;
chosen = null; // invalidate color set

View File

@@ -0,0 +1,10 @@
package forge.limited;
/**
* Created by maustin on 11/05/2017.
*/
public class FullDeckColors extends DeckColors {
public FullDeckColors(){
MAX_COLORS = 5;
}
}