mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Improved deck generation code - ensure keycard is non-land for LDA deck generation and improve handling of basic lands to ensure no colour is missed.
This commit is contained in:
@@ -230,7 +230,13 @@ public class DeckgenUtil {
|
|||||||
*/
|
*/
|
||||||
public static Deck buildLDACArchetypeDeck(Archetype archetype, GameFormat format, boolean isForAI){
|
public static Deck buildLDACArchetypeDeck(Archetype archetype, GameFormat format, boolean isForAI){
|
||||||
List<Pair<String, Double>> preSelectedCardNames = archetype.getCardProbabilities();
|
List<Pair<String, Double>> preSelectedCardNames = archetype.getCardProbabilities();
|
||||||
PaperCard card = StaticData.instance().getCommonCards().getUniqueByName(preSelectedCardNames.get(0).getLeft());
|
PaperCard card = null;
|
||||||
|
for(Pair<String, Double> pair : preSelectedCardNames){
|
||||||
|
card = StaticData.instance().getCommonCards().getUniqueByName(pair.getLeft());
|
||||||
|
if(!card.getRules().getType().isLand()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
List<PaperCard> selectedCards = new ArrayList<>();
|
List<PaperCard> selectedCards = new ArrayList<>();
|
||||||
for(Pair<String, Double> pair:preSelectedCardNames){
|
for(Pair<String, Double> pair:preSelectedCardNames){
|
||||||
String name = pair.getLeft();
|
String name = pair.getLeft();
|
||||||
@@ -248,7 +254,7 @@ public class DeckgenUtil {
|
|||||||
int removeCount=0;
|
int removeCount=0;
|
||||||
int i=0;
|
int i=0;
|
||||||
for(PaperCard c:selectedCards){
|
for(PaperCard c:selectedCards){
|
||||||
if(MyRandom.getRandom().nextInt(100)>70+(15-(i/selectedCards.size())*selectedCards.size()) && removeCount<4 //randomly remove some cards - more likely as distance increases
|
if( i > 4 && MyRandom.getRandom().nextInt(100)>70+(15-(i/selectedCards.size())*selectedCards.size()) && removeCount<4 //randomly remove some cards - more likely as distance increases
|
||||||
&&!c.getName().contains("Urza")){ //avoid breaking Tron decks
|
&&!c.getName().contains("Urza")){ //avoid breaking Tron decks
|
||||||
toRemove.add(c);
|
toRemove.add(c);
|
||||||
removeCount++;
|
removeCount++;
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
|||||||
targetSize=deckFormat.getMainRange().getMinimum();
|
targetSize=deckFormat.getMainRange().getMinimum();
|
||||||
FullDeckColors deckColors = new FullDeckColors();
|
FullDeckColors deckColors = new FullDeckColors();
|
||||||
int cardCount=0;
|
int cardCount=0;
|
||||||
int colourCheckAmount = 20;
|
int colourCheckAmount = 30;
|
||||||
if (targetSize < 60){
|
if (targetSize < 60){
|
||||||
colourCheckAmount = 10;//lower amount for planar decks
|
colourCheckAmount = 10;//lower amount for planar decks
|
||||||
}
|
}
|
||||||
@@ -623,12 +623,20 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
|||||||
numColors++;
|
numColors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// add one of each land required first so that any rounding errors do not remove the only land of a colour
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
if (clrCnts[i] > 0) {
|
||||||
|
deckList.add(getBasicLand(i));
|
||||||
|
landsNeeded--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// do not update landsNeeded until after the loop, because the
|
// do not update landsNeeded until after the loop, because the
|
||||||
// calculation involves landsNeeded
|
// calculation involves landsNeeded
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
if (clrCnts[i] > 0) {
|
if (clrCnts[i] > 0) {
|
||||||
// calculate number of lands for each color
|
// calculate remaining number of lands for each color
|
||||||
float p = (float) clrCnts[i] / (float) totalColor;
|
float p = (float) clrCnts[i] / (float) totalColor;
|
||||||
int nLand = Math.round(landsNeeded * p); // desired truncation to int
|
int nLand = Math.round(landsNeeded * p); // desired truncation to int
|
||||||
if (logToConsole) {
|
if (logToConsole) {
|
||||||
|
|||||||
Reference in New Issue
Block a user